Normalize metadata language to BCP 47 for HTML lang attributes#147
Merged
kosarko merged 1 commit intoJun 5, 2026
Merged
Conversation
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".
d8566b4 to
83b63fd
Compare
amadulhaxxani
approved these changes
Jun 5, 2026
amadulhaxxani
left a comment
There was a problem hiding this comment.
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
4430bce
into
accessibility-existing-issues-all
6 of 7 checks passed
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.
Problem
PR #139 adds HTML
langattributes to metadata/description text via[attr.lang]="…?.language || null". But DSpace stores the metadata languagefield as Java-style locales and a wildcard —
en_US,de_DE,cs_CZ,*,NULL. None of the underscore forms or*are valid BCP 47 / HTMLlangvalues (BCP 47 uses
-;*is not a tag and, being truthy, is not dropped by|| null). Assistive technology ignores invalid tags, so the accessibilityfeature is effectively inert for the most common stored values.
en_USlang="en_US"✗lang="en-US"✓cs_CZlang="cs_CZ"✗lang="cs-CZ"✓*lang="*"✗NULLChange
metadata-language.util.ts—metadataLangToBcp47(): single source oftruth.
*/empty/nullish →null;_→-. Minimal by design (no casecanonicalization / tag validation — BCP 47 is case-insensitive).
ds-lang.pipe.ts—dsLangpipe delegating to the helper, registered inSharedModule.langbinding through it: the pipe in the 7 templates(grid/list/file/metadata-values), the helper directly in the 3
.tssites(
clarin-item-box-view,clarin-description-item-field,org-unit-sidebar).DsLangPipein the 5 spec locations that render the pipe(
NO_ERRORS_SCHEMAdoes not suppress missing pipes), incl. the sharedgetEntityGridElementTestComponentfactory.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 5affected component specs, and a DOM assertion that
en_USrenders aslang="en-US"(never rawen_US).Targets
accessibility-existing-issues-all(#139) since the bindings beingfixed only exist on that branch.