Skip to content

fix(a11y): WCAG 3.1.2 — set HTML lang attribute dynamically from locale#39243

Merged
rusackas merged 2 commits intoapache:masterfrom
Aitema-gmbh:fix/wcag-3.1.2-language-of-parts
Apr 20, 2026
Merged

fix(a11y): WCAG 3.1.2 — set HTML lang attribute dynamically from locale#39243
rusackas merged 2 commits intoapache:masterfrom
Aitema-gmbh:fix/wcag-3.1.2-language-of-parts

Conversation

@Aitema-gmbh
Copy link
Copy Markdown
Contributor

SUMMARY

Implements WCAG 2.1 criterion 3.1.2 (Language of Parts, Level AA).

  • Set document.documentElement.lang from bootstrapData.common.locale on app initialization
  • Converts locale formats like pt_BR or de-DE to BCP-47 primary subtag (pt, de)
  • Falls back to window.navigator.language or en
  • Screen readers now select the correct pronunciation engine

TESTING INSTRUCTIONS

  1. Open Superset with a non-English locale configured
  2. Inspect <html> element → lang attribute should match the configured locale
  3. Screen reader should announce content in the correct language

ADDITIONAL INFORMATION

@dosubot dosubot Bot added change:frontend Requires changing the frontend design:accessibility Related to accessibility standards labels Apr 9, 2026
Copy link
Copy Markdown
Contributor

@bito-code-review bito-code-review Bot left a comment

Choose a reason for hiding this comment

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

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

AI Code Review powered by Bito Logo

Comment thread superset-frontend/src/views/App.tsx Outdated
Comment on lines +52 to +57
// 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];
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.

Accessibility: Incomplete BCP-47 locale normalization

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
Suggested change
// 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

…ng region subtag

Address Bito code review finding: preserve region subtags like pt_BR as pt-BR
so screen readers get locale-specific pronunciation hints, instead of
collapsing to primary tag only (pt).
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 19, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 1317b53
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/69e500aaa46a5d0008fd9a96
😎 Deploy Preview https://deploy-preview-39243--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Aitema-gmbh
Copy link
Copy Markdown
Contributor Author

Thanks for the review @bito-code-review.

Addressed the finding in 1317b53d: locale is now normalized to BCP-47 by replacing underscores with hyphens (pt_BRpt-BR) instead of collapsing to the primary subtag (pt). Screen readers get the region-specific pronunciation hint when available.

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented Apr 19, 2026

Code Review Agent Run #d7441e

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 41410f6..1317b53
    • 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

AI Code Review powered by Bito Logo

Copy link
Copy Markdown
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

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

LGTM! This one's easier than the rest :D

@rusackas
Copy link
Copy Markdown
Member

Approving CI 🤞 Will merge if it turns green.

@rusackas rusackas added merge-if-green If approved and tests are green, please go ahead and merge it for me review:checkpoint Last PR reviewed during the daily review standup labels Apr 20, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.37%. Comparing base (5815665) to head (1317b53).
⚠️ Report is 112 commits behind head on master.

Files with missing lines Patch % Lines
superset-frontend/src/views/App.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #39243      +/-   ##
==========================================
- Coverage   64.37%   64.37%   -0.01%     
==========================================
  Files        2550     2550              
  Lines      132180   132182       +2     
  Branches    30661    30662       +1     
==========================================
  Hits        85096    85096              
- Misses      45599    45601       +2     
  Partials     1485     1485              
Flag Coverage Δ
javascript 65.91% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rusackas rusackas merged commit 4f2fa41 into apache:master Apr 20, 2026
75 of 76 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend design:accessibility Related to accessibility standards merge-if-green If approved and tests are green, please go ahead and merge it for me review:checkpoint Last PR reviewed during the daily review standup size/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants