diff --git a/superset-frontend/src/views/App.tsx b/superset-frontend/src/views/App.tsx index 270a344d817..4f30a552e94 100644 --- a/superset-frontend/src/views/App.tsx +++ b/superset-frontend/src/views/App.tsx @@ -49,6 +49,14 @@ setupAGGridModules(); const bootstrapData = getBootstrapData(); +// 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 to BCP-47 format by replacing underscores with hyphens +// so region subtags like "pt_BR" become valid "pt-BR" rather than being dropped. +const locale = + bootstrapData.common?.locale || window.navigator.language || 'en'; +document.documentElement.lang = String(locale).replace(/_/g, '-'); + let lastLocationPathname: string; const boundActions = bindActionCreators({ logEvent }, store.dispatch);