๐Internationalization and Translations
Or i18n for short
Internationalization and Translation, referred as i18n is the set of feature that enables you to make your pages available in multiple languages.
Base principles
When in your components you see instructions like:

msg("backToLogin")
gets rendered as ยซ Back to LoginOverriding the base message or adding custom ones
In the theme
If you want to see the base message translations you can navigate to the node_modules/keycloakify/src/login/i18n/messages_defaultSet/ directory:

As you can see, the translation message for the key backToLogin in English (en.ts) is:
We are <strong>sorry</strong> ...
As a result:
Keycloakify let's you overwrite the values of the translations messages and define new ones. This is how to do it:
The messageBundle that you provide as argument of the createUseI18n
function must be statically valuable. You can't import from external files. All the translations must be declared inline.
This is because Keycloakify will analyze your code at build time to make Keycloak aware of your modifications of the base messages so that server side generated feedback messages can use your translations.
If you don't provide translation for all the language that are enabled in the realm configuration it will fallback to english (or your first translation declared).
In the Keycloak Realm configuration
Some relevant messages, namely termsText
and all the messages used in the User Profile Attributes like for example the Display name, the helper text or the select option labels can be defined at the realm level and it will work as you would expect:



Note that if you try to use:
It will work at runtime, you'll get Favourite Pet
but typescript will complain because "profile.attributes.favourite_pet"
or string
isn't a known i18n message key, it makes sense as it's only defined on the server.
This is why you'll see in some place in the code the usage of advancedMsg(attribute.displayName)
, advancedMsg()
is basically equivalent to msg()
except that TypeScript won't complain if the key isn't part of the statically defined set.
More details.
See also:
Stories in different languages
Changing the language directly using the dropdown select in Storybook isn't supported. To preview your component in different languages, create separate stories for each language. Example:
If you want all your story to by by default in an other language you can edit:
What do do if my language is not in the default set
Support for adding extra language will be added soon. In the meantime see https://github.com/keycloakify/keycloakify/issues/599
As of writing theses line Keycloak support 27 languages.

What to do is your language isn't one of them? Like Hebrew for example.
Unfortunately, Keycloak doesn't provide a way to easily add a new language however there's a workaround with Keycloakify. You can overrides the translation of an other language to add your translations. Here is an example:
Last updated
Was this helpful?