Skip to content

Add inspector to infer languages - #139

Open
chocolatkey wants to merge 1 commit into
developfrom
feat/infer-language
Open

chocolatkey wants to merge 1 commit into
developfrom
feat/infer-language

Conversation

@chocolatkey

@chocolatkey chocolatkey commented Nov 23, 2026 •

Copy link
Copy Markdown
Member
  • The manifest command now infers the languages of a publication's text when --inspect-html is combined with --infer-a11y=split. The publication's (X)HTML documents are scanned through their guided navigation representation, and the languages declared in them (lang or xml:lang) are listed under language in the inferred accessibility object, as BCP-47 tags ordered by the number of strings found in each language, most used first. Like metadata.language, a single language is written as a string instead of a one-item array
    • A string is a block of text, or a run of text in another language inside of one (e.g. <i lang="fr">). Text with no declared language is not counted, so nothing is inferred for publications that don't declare any
    • Tags are normalized (en_us becomes en-US) and keep their region and script, so en and en-US are listed separately. Tags that are not valid are ignored
    • This inference is never merged into the publication's own metadata: nothing is inferred with --infer-a11y=merged

Closes #90

@chocolatkey
chocolatkey requested a balanced review from Copilot November 23, 2026 08:43
@chocolatkey chocolatkey added the manifest Related to the manifest command label Nov 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 Languages inspector 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 language output.
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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manifest Related to the manifest command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inferred list of languages

2 participants