fix(a11y): WCAG 3.1.2 — set HTML lang attribute dynamically from locale#39243
fix(a11y): WCAG 3.1.2 — set HTML lang attribute dynamically from locale#39243Aitema-gmbh wants to merge 1 commit intoapache:masterfrom
Conversation
…le for screen readers
There was a problem hiding this comment.
Code Review Agent Run #95bf01
Actionable Suggestions - 1
-
superset-frontend/src/views/App.tsx - 1
- Accessibility: Incomplete BCP-47 locale normalization · Line 52-57
Review Details
-
Files reviewed - 1 · Commit Range:
41410f6..41410f6- superset-frontend/src/views/App.tsx
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.
Documentation & Help
| // WCAG 3.1.2: Set the HTML lang attribute based on the current locale | ||
| // so screen readers announce the correct language for the page content. | ||
| // Converts locale formats like "pt_BR" or "de-DE" to BCP-47 primary tag ("pt", "de"). | ||
| const locale = | ||
| bootstrapData.common?.locale || window.navigator.language || 'en'; | ||
| document.documentElement.lang = String(locale).split(/[_-]/)[0]; |
There was a problem hiding this comment.
The locale handling strips region subtags unnecessarily, which reduces precision for screen readers. BCP-47 recommends including region subtags when meaningful. Consider normalizing 'pt_BR' to 'pt-BR' instead of 'pt' for better accessibility compliance.
Code suggestion
Check the AI-generated fix before applying
| // WCAG 3.1.2: Set the HTML lang attribute based on the current locale | |
| // so screen readers announce the correct language for the page content. | |
| // Converts locale formats like "pt_BR" or "de-DE" to BCP-47 primary tag ("pt", "de"). | |
| const locale = | |
| bootstrapData.common?.locale || window.navigator.language || 'en'; | |
| document.documentElement.lang = String(locale).split(/[_-]/)[0]; | |
| // WCAG 3.1.2: Set the HTML lang attribute based on the current locale | |
| // so screen readers announce the correct language for the page content. | |
| // Normalize locale to BCP-47 format by replacing underscores with hyphens. | |
| const locale = | |
| bootstrapData.common?.locale || window.navigator.language || 'en'; | |
| document.documentElement.lang = String(locale).replace(/_/g, '-'); |
Code Review Run #95bf01
Should Bito avoid suggestions like this for future reviews? (Manage Rules)
- Yes, avoid them
SUMMARY
Implements WCAG 2.1 criterion 3.1.2 (Language of Parts, Level AA).
document.documentElement.langfrombootstrapData.common.localeon app initializationpt_BRorde-DEto BCP-47 primary subtag (pt,de)window.navigator.languageorenTESTING INSTRUCTIONS
<html>element →langattribute should match the configured localeADDITIONAL INFORMATION
Part of a series of 16 individual WCAG 2.1 accessibility PRs. See also fix(a11y): Accessibility improvements for WCAG 2.1 Level A compliance #38342.