kashpatel
kashpatel

Reputation: 725

How to initialize keycloak with locale in i18n Angular app?

We use keycloak [https://www.keycloak.org/] server for user authentication in our Angular 6 app. We also use this wrapper library https://github.com/mauriciovigolo/keycloak-angular to interact with the underneath JavaScript keycloak Adapter and initialization.

Keycloak is the first thing in the app that gets initialized (from provided configuration) via Angular's APP_INITIALIZER provider.

Since we use Angular with internationalization and ahead of time compilation, we have deployed our apps like this:

   https://my-site/en
   https://my-site/fr

I want to render login page in respective locale when navigated. If navigated to my-site/fr keycloak login page should render in french and so on. But there is no way to provide locale in keyclaok config while app initialization.

PS: Keycloak realm is already configured to allow internationalization and user can change language from login page. I know keycloak adapter's login method takes "locale" param but I can only access that after app has been initialized.

Has anyone encountered this problem?

Thank you

Upvotes: 1

Views: 2834

Answers (1)

mauriciovigolo
mauriciovigolo

Reputation: 306

For those facing a similar problem, the resolution may be found at How to initialize keycloak with locale in i18n Angular app.

Upvotes: 1

Related Questions