keycloak: Localization: Admin UI doesn't pick up message bundles from realms other than master

Before reporting an issue

Area

admin/ui

Describe the bug

I use the User Profile functionality and inside Admin UI -> Users -> User detail I should be able to provide translated names, but this only works for non-english locales.

Version

22.0.1

Expected behavior

I add a custom property in the User profile section with a translated name ${customAttribute}, then I add a message bundle with the correct translations users:customAttribute. Then I should see my users:customAttribute value in the User details page.

Actual behavior

I see customAttribute written there, but if I do the same procedure for eg. german, than it works!

How to Reproduce?

  1. Add a new custom attribute with name customAttribute in the user profile.
  2. Add a displayname of ${customAttribute}
  3. Add a message bundle users:customAttribute
  4. Look at a user profile

Anything else?

As far as I can tell, there is a difference between how the english translation is handled and any other.

After my procedure I see that the Admin UI is loading the translations from: http://localhost:8080/admin/realms/master/localization/en

But if I switch the language to german the translations are loaded from: http://localhost:8080/admin/realms/my-realm/localization/de

Or if I don’t login through the master realm the english translations also work and are loaded from: http://localhost:8080/admin/realms/my-realm/localization/en

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 19 (19 by maintainers)

Commits related to this issue

Most upvoted comments

In my opinion it would make sense to respect the Realm Settings -> Localization of the non-master realm. At the moment this is where to set localizations which are then applied at:

  • The login theme (e.g. registration screen)
  • The realm specific admin console (/admin/${realm_name}/console/ - this one picks up the realm specific localizations instead of the once from the master)

Where these localizations are currently not applied at:

  • /admin/master/console/ - when managing user details of a non master realm.
  • Account Console (V2)

Imho having it in the theme comes with some big disadvantage:

  • You would potentially have to have a theme per realm (as different realms might need different user profile settings or different translations)
  • You loose the possibility of managing the translations in the UI - also allowing admin users to self-service the translations.
  • Changing or adding a translation would mean: adapting the theme, then packaging and deploying it.

We should probably put a warning message on the internationalization tab to let users know what they are doing is probably wrong and then point them to the documentation.

The “right” way is to first decide if your localized message should apply at the theme level or at the realm level. Usually, the answer is that you want the message to be localized for any realm that uses the theme. So, “theme level” is usually the right answer.

If the message is at the realm level then use the admin console UI.

If the message is at the theme level, override the message bundle in your theme according to https://www.keycloak.org/docs/latest/server_development/#messages. Note that for admin console V2, you will override json files instead of properties files.