Skip to content

Normalize metadata language to BCP 47 for HTML lang attributes#147

Merged
kosarko merged 1 commit into
accessibility-existing-issues-allfrom
worktree-139-bcp47-lang-normalization
Jun 5, 2026
Merged

Normalize metadata language to BCP 47 for HTML lang attributes#147
kosarko merged 1 commit into
accessibility-existing-issues-allfrom
worktree-139-bcp47-lang-normalization

Conversation

@kosarko
Copy link
Copy Markdown
Member

@kosarko kosarko commented Jun 4, 2026

Problem

PR #139 adds HTML lang attributes to metadata/description text via
[attr.lang]="…?.language || null". But DSpace stores the metadata language
field as Java-style locales and a wildcard — en_US, de_DE, cs_CZ, *,
NULL. None of the underscore forms or * are valid BCP 47 / HTML lang
values (BCP 47 uses -; * is not a tag and, being truthy, is not dropped by
|| null). Assistive technology ignores invalid tags, so the accessibility
feature is effectively inert for the most common stored values.

DB value Before After
en_US lang="en_US" lang="en-US"
cs_CZ lang="cs_CZ" lang="cs-CZ"
* lang="*" (attribute omitted) ✓
NULL (omitted) ✓ (omitted) ✓

Change

  • metadata-language.util.tsmetadataLangToBcp47(): single source of
    truth. */empty/nullish → null; _-. Minimal by design (no case
    canonicalization / tag validation — BCP 47 is case-insensitive).
  • ds-lang.pipe.tsdsLang pipe delegating to the helper, registered in
    SharedModule.
  • Routed every PR Accessibility existing issues all #139 lang binding through it: the pipe in the 7 templates
    (grid/list/file/metadata-values), the helper directly in the 3 .ts sites
    (clarin-item-box-view, clarin-description-item-field, org-unit-sidebar).
  • Declared DsLangPipe in the 5 spec locations that render the pipe
    (NO_ERRORS_SCHEMA does not suppress missing pipes), incl. the shared
    getEntityGridElementTestComponent factory.

Testing

  • yarn run lint --quiet
  • yarn run check-circ-deps ✓ (helper is a leaf)
  • yarn run test:headless (targeted) ✓ — new helper + pipe unit specs, the 5
    affected component specs, and a DOM assertion that en_US renders as
    lang="en-US" (never raw en_US).

Targets accessibility-existing-issues-all (#139) since the bindings being
fixed only exist on that branch.

@kosarko kosarko requested a review from amadulhaxxani June 4, 2026 15:40
PR #139 binds [attr.lang] straight from the DSpace metadata language field,
which is stored as Java-style locales (en_US, cs_CZ) or the wildcard *. None
of those are valid BCP 47 / HTML lang values, so assistive technology ignores
them and the accessibility improvement is inert for the common stored values.

Add a single shared metadataLangToBcp47() helper (*/empty/nullish -> null,
"_" -> "-") and a thin dsLang pipe that delegates to it. Route all of PR #139's
lang bindings through it: the pipe in the seven templates, the helper directly
in the three .ts sites. Declare DsLangPipe in the specs that render the pipe
(NO_ERRORS_SCHEMA does not suppress missing pipes), including the shared grid
element test factory. Add unit specs for the helper and pipe plus a DOM
assertion that en_US renders as lang="en-US".
@kosarko kosarko force-pushed the worktree-139-bcp47-lang-normalization branch from d8566b4 to 83b63fd Compare June 4, 2026 17:00
Copy link
Copy Markdown

@amadulhaxxani amadulhaxxani left a comment

Choose a reason for hiding this comment

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

the normalization approach using pipe providing a single source of truth looks good.
As a minimal solution no issue, otherwise we could also check for whitespaces only if needed

Approved

@kosarko kosarko merged commit 4430bce into accessibility-existing-issues-all Jun 5, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants