Description
Before reporting an issue
- I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.
Area
login/ui
Describe the bug
Hello Keycloak team,
I’d like to highlight an important issue that may require your attention:
When users create an account in Keycloak, they are not assigned a language unless they explicitly select one from the dropdown on the login page.
As a result, confirmation and password reset emails are sent in the realm’s default language.
Version
Likely all versions, certainly the latest.
Regression
- The issue is a regression
Expected behavior
Typically, an application provides the ui_locales
query parameter when redirecting to the authorization URL.
If ui_locales
is not explicitly provided, Keycloak checks the Accept-Language
header and attempts to match it with an enabled language in the realm. If no match is found, the page is rendered in the realm’s default locale.
The locale determined through this process should be assigned to the user upon account creation.
Actual behavior
Unless the user explicitly selects a language from the dropdown, the account is created without a defined locale, causing emails to be sent in the realm's default language.
This happens almost every time, as users have no reason to use the language selector when the login page is already displayed in their preferred language—either because the client application set it via ui_locales
or Keycloak detected it based on the browser's language preferences.
How to Reproduce?
You may have your own way of running Keycloak, but here's how to do it using the Keycloakify tooling:
git clone https://github.com/keycloakify/keycloakify-starter
cd keycloakify-starter
yarn
npx keycloakify start-keycloak
# Select any Keycloak version
- Enable the default theme (this issue does not occur with the Keycloakify theme, as it has been fixed there).
Navigate to https://localhost:8080 and log in withadmin:admin
. - Select "myrealm".
- In the Themes tab, enable the default login theme.
- Open https://my-theme.keycloakify.dev.
- Append
&ui_locales=es
to the URL and reload the page. - Create an account.
- Go back to the Admin Console and check the newly created user—the language has not been set.
Anything else?
I fixed this in Keycloakify by making a fetch request to login-action/registrations?kc_locale=xx, but this shouldn’t be necessary.
Wishing you all the best!