Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option for ui_localales query param for proper login page localization #21

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

molequetu
Copy link

@molequetu molequetu commented Jan 4, 2021

Hello, we had the request to retrieve the login page based on the current ui culture set on the application using the adapter,
so we add the option in order to set the desired locale for retrieving the login page. By default keycloack wil render the login page localized based on these conditions:

With internationalization enabled, the locale is resolved in the following priority:

  1. kc_locale query parameter
  2. KEYCLOAK_LOCALE cookie value
  3. User’s preferred locale if a user instance is available
  4. ui_locales query parameter
  5. Accept-Language request header
  6. Realm’s default language

So, our issue was, suppose our application was starting with a defined uiCulture, the login page was rendered base on 5(Accept-Language) header, which many times was different from the defined in the application.

All you need, which is optional, is to configure your adapter with this parameter, e.g

app.UseKeycloakAuthentication(new KeycloakAuthenticationOptions {
....other initialiation config options
 UiLocales = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName
}

Be carefull to have your desired ui culture(based on web.config or whatever) before keycloak initialization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant