Repository navigation
Set the admin console html lang attribute from the user locale - #55491
Open
Ahmed-Manai wants to merge 1 commit into
Open
Ahmed-Manai wants to merge 1 commit into
Ahmed-Manai wants to merge 1 commit into
Conversation
The admin console always rendered lang=en, so screen readers, font fallback and :lang() rules treated every translation as English. Set lang in the same effect that already sets dir. Closes keycloak#55490 Signed-off-by: ahmed manai <manaii.ahmed9896@gmail.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the update that aligns the admin console’s HTML language with the user’s locale.
No open issues 🎉
What changed in this PR
Fixes #55490 by setting the admin console’s HTML language from the user’s locale, helping screen readers and browsers interpret translated content correctly.
Changes:
- Sets
<html lang>alongside the existing direction handling, falling back to English. - Adds a regression test checking
lang="ar"anddir="rtl"for an Arabic-locale user.
| File | Description |
|---|---|
js/apps/admin-ui/test/masthead/main.spec.ts |
Tests language and direction attributes after signing in with an Arabic locale. |
js/apps/admin-ui/src/context/whoami/WhoAmI.tsx |
Updates the HTML language attribute from the user’s locale with a default fallback. |
Review effort: Balanced
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.
Closes #55490
The admin console always rendered
<html lang="en">, whatever language the user picked.WhoAmI.tsxalready setsdir="rtl"for right-to-left locales; this setslangin the same effect, from the user's locale, falling back toen.With the right
lang, screen readers pronounce the console in the user's language, browsers choose fallback fonts for that language (for example for Persian, see #55023), and:lang()rules in custom themes match.Tests
Added
Sets the page language and direction from the user's localeto the existing right-to-left tests intest/masthead/main.spec.ts. It signs in as a user with thearlocale and checkslang="ar"anddir="rtl"on<html>.Ran
test/masthead/main.spec.tsagainst the nightly server with the admin console served from Vite (KC_ADMIN_VITE_URL):Expected: "ar",Received: "en")