Repository navigation
Add inspector to infer languages - #139
Open
chocolatkey wants to merge 1 commit into
Open
chocolatkey wants to merge 1 commit into
chocolatkey wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change introduces a new Languages inspector plus guide caching and safer per-key inferred-a11y updates, and it is accompanied by targeted tests and documentation with no remaining issues noted in the review evidence.
No open issues 🎉
What changed in this PR
Adds an HTML-based inspector that infers and records a publication’s ordered language list from Guided Navigation output into inferred accessibility metadata (split mode), while preserving unrelated inferred-a11y keys and reusing generated guides across HTML inspectors.
Changes:
- Add
Languagesinspector to infer and rank normalized BCP-47 language tags from guided-navigation text/SSML. - Introduce guided-navigation document caching so multiple HTML inspectors reuse the same generated guides.
- Update inferred-a11y persistence so inspectors set individual keys without overwriting unknown fields.
- Wire the new inspector and caching in the CLI, and document inferred
languageoutput.
| File | Description |
|---|---|
| pkg/inspector/page_break_markers_inspector.go | Updates split-mode inferred-a11y writes to set only the relevant feature key instead of rewriting the entire inferred accessibility object. |
| pkg/inspector/languages_inspector.go | Implements a new inspector that infers an ordered list of normalized language tags from guided-navigation text and SSML language runs and stores it under inferred accessibility language. |
| pkg/inspector/languages_inspector_test.go | Adds tests covering language inference ordering, normalization, SSML inline language handling, split-mode behavior, and interoperability with guide caching/other inspectors. |
| pkg/inspector/inferred_a11y.go | Introduces helper logic to update inferred accessibility metadata by individual key to avoid clobbering unrelated inferred-a11y fields. |
| pkg/inspector/guide_cache.go | Adds a caching wrapper for guided-navigation generation so guides are memoized per resource and reused across inspectors. |
| internal/cli/manifest.go | Wires guided-navigation caching into HTML inspection and conditionally runs the Languages inspector when inferred accessibility metadata is in split mode. |
| go.mod | Adds golang.org/x/text as a direct dependency to support BCP-47 language parsing/canonicalization for inferred languages. |
| docs/manifest.md | Documents the inferred accessibility language output behavior, constraints, and required flags for enabling split-mode inference. |
Review effort: Balanced
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
manifestcommand now infers the languages of a publication's text when--inspect-htmlis combined with--infer-a11y=split. The publication's (X)HTML documents are scanned through their guided navigation representation, and the languages declared in them (langorxml:lang) are listed underlanguagein the inferred accessibility object, as BCP-47 tags ordered by the number of strings found in each language, most used first. Likemetadata.language, a single language is written as a string instead of a one-item array<i lang="fr">). Text with no declared language is not counted, so nothing is inferred for publications that don't declare anyen_usbecomesen-US) and keep their region and script, soenanden-USare listed separately. Tags that are not valid are ignored--infer-a11y=mergedCloses #90