Skip to content

Set the admin console html lang attribute from the user locale - #55491

Open
Ahmed-Manai wants to merge 1 commit into
keycloak:mainfrom
Ahmed-Manai:admin-console-html-lang
Open

Ahmed-Manai wants to merge 1 commit into
keycloak:mainfrom
Ahmed-Manai:admin-console-html-lang

Conversation

@Ahmed-Manai

Copy link
Copy Markdown

Closes #55490

The admin console always rendered <html lang="en">, whatever language the user picked. WhoAmI.tsx already sets dir="rtl" for right-to-left locales; this sets lang in the same effect, from the user's locale, falling back to en.

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 locale to the existing right-to-left tests in test/masthead/main.spec.ts. It signs in as a user with the ar locale and checks lang="ar" and dir="rtl" on <html>.

Ran test/masthead/main.spec.ts against the nightly server with the admin console served from Vite (KC_ADMIN_VITE_URL):

Chromium Firefox
Without the change new test fails (Expected: "ar", Received: "en") new test fails (same)
With the change 13 passed 13 passed (twice)

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>
@Ahmed-Manai
Ahmed-Manai requested review from a team as code owners November 24, 2026 17:10
Copilot AI balanced review requested due to automatic review settings November 24, 2026 17:10

Copilot AI left a comment

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.

🟢 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" and dir="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

@stianst stianst added the kind/bug Categorizes a PR related to a bug label Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes a PR related to a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admin console always sets <html lang="en">, whatever the user's language

3 participants