Skip to content

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

Open
Aitema-gmbh wants to merge 1 commit intoapache:masterfrom
Aitema-gmbh:fix/wcag-3.1.2-language-of-parts
Open

fix(a11y): WCAG 3.1.2 — set HTML lang attribute dynamically from locale#39243
Aitema-gmbh wants to merge 1 commit intoapache:masterfrom
Aitema-gmbh:fix/wcag-3.1.2-language-of-parts

Conversation

@Aitema-gmbh
Copy link
Copy Markdown

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 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

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 size/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant