Keycloakify
HomeGitHubStorybookAlternative to keycloak-js
v11 (Legacy)
  • Documentation
  • Release Notes & Upgrade Instructions
  • FAQ
v11 (Legacy)
  • 👨‍💻Quick start
  • 🧪Testing your Theme
    • In Storybook
    • In a Keycloak Docker Container
    • With Vite or Webpack in dev mode
  • 🔩Integrating Keycloakify in your Codebase
    • In your React Project
      • In your Vite Project
      • In your Webpack Project
    • As a Subproject of your Monorepo
      • Turborepo
      • Nx Integrated Monorepo
      • Package Manager Workspaces
  • 🎨Customization Strategies
    • CSS Level Customization
      • Basic example
      • Removing the default styles
      • Applying your own classes
      • Page specific styles
      • Using Tailwind
      • Using custom assets
        • .css, .sass or .less
        • CSS-in-JS
    • Component Level Customization
      • Using custom assets
  • 🖋️Custom Fonts
  • 🌎Internationalization and Translations
    • Base principles
    • Adding Support for Extra Languages
    • Previewing you Pages In Different Languages
    • Adding New Translation Messages Or Changing The Default Ones
  • 🎭Theme Variants
  • 📝Customizing the Register Page
  • 👤Account Theme
    • Single-Page
    • Multi-Page
  • 📄Terms and conditions
  • 🖇️Styling a Custom Page Not Included In Base Keycloak
  • 🔧Accessing the Server Environment Variables
  • 🎯Targetting Specific Keycloak Versions
  • 📧Email Customization
  • 🚛Passing URL Parameters to your Theme
  • 🤵Admin theme
  • 📥Importing the JAR of Your Theme Into Keycloak
  • 🔛Enabling your Theme in the Keycloak Admin Console
  • 🤓Taking ownership of the kcContext
  • 📖Configuration Options
    • --project
    • keycloakVersionTargets
    • environmentVariables
    • themeName
    • startKeycloakOptions
    • themeVersion
    • postBuild
    • XDG_CACHE_HOME
    • kcContextExclusionsFtl
    • keycloakifyBuildDirPath
    • groupId
    • artifactId
    • Webpack specific options
      • projectBuildDirPath
      • staticDirPathInProjectBuildDirPath
      • publicDirPath
  • FAQ & HELP
    • 🤝Comunity resources
    • ⬆️Migration Guides
      • ⬆️v10->v11
      • ⬆️v9 -> v10
      • ⬆️CRA -> Vite
      • ⬆️v8 -> v9
      • ⬆️v7 -> v8
      • ⬆️v6 -> v7
      • ⬆️v6.x -> v6.12
      • ⬆️v5 -> v6
    • 😞Can't identify the page to customize?
    • 🤔How it Works
    • 😖Some values you need are missing from in kcContext type definitions?
    • ❓Can I use it with Vue or Angular
      • Angular
    • ⚠️Limitations
    • 🛑Errors Keycloak in Logs
    • 🙋How do I add extra pages?
    • 🤓Can I use react-hooks-form?
    • 🚀Redirecting your users to the login/register pages
    • 💟Contributing
    • 🍪Google reCaptcha and End of third-party Cookies
    • 🔖Accessing the Realm Attributes
  • ⭐Sponsors
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Internationalization and Translations

Adding Support for Extra Languages

Keycloak, out of the box come with availaible translation for the following languages:

  1. ar - Arabic

  2. ca - Catalan

  3. cs - Czech

  4. da - Danish

  5. de - German

  6. el - Greek

  7. en - English

  8. es - Spanish

  9. fa - Persian (Farsi)

  10. fi - Finnish

  11. fr - French

  12. hu - Hungarian

  13. it - Italian

  14. ja - Japanese

  15. ka - Georgian

  16. lt - Lithuanian

  17. lv - Latvian

  18. nl - Dutch

  19. no - Norwegian

  20. pl - Polish

  21. pt-BR - Portuguese (Brazilian)

  22. pt - Portuguese

  23. ru - Russian

  24. sk - Slovak

  25. sv - Swedish

  26. th - Thai

  27. tr - Turkish

  28. uk - Ukrainian

  29. zh-CN - Chinese (Simplified)

  30. zh-TW - Chinese (Traditional)

Let's see how to add support for an extra language so you can enable it in the Keycloak Admin UI.

In this example we're going to add Hindi (hi).

To acheive this first step is to create a TypeScript file containing Hindi translation of all the default message keys. I sugest creating this file as src/login/i18n.hi.ts but it can be located anywhere under your src directory.

src/login/i18n.hi.ts
import type { MessageKey_defaultSet } from "keycloakify/login";

const messages: Record<MessageKey_defaultSet, string> = {
    // cspell: disable
    doLogIn: "साइन इन करें",
    doRegister: "रजिस्टर करें",
    doRegisterSecurityKey: "रजिस्टर करें",
    // ... translation for all the other default messages
    // cspell: enable
};

export default messages;

Wait before panicking realizing that there are hundreds of message keys. ChatGPT can do this for you!

Just take the English translation of the message a reference and ask it to translate for you (you'll have to press continue several times).

You can find the English translations in your repo at:

node_modules/keycloakify/src/login/i18n/messages_defaultSet/en.ts

Do not customize the translations messages to fit your usecase!

This is not the place to do it. Theses translation should be as generic as they can be.

Next step is to index the translation file that you have created, edit the src/login/i18n.ts file as follow:

src/login/i18n.ts
import { i18nBuilder } from "keycloakify/login";
import type { ThemeName } from "../kc.gen";

/** @see: https://docs.keycloakify.dev/i18n */
const { useI18n, ofTypeI18n } = i18nBuilder
    .withThemeName<ThemeName>()
    .withExtraLanguages({
        hi: {
            // cspell: disable-next-line
            label: "हिन्दी",
            getMessages: () => import("./i18n.hi")
        }
    })
    .build();

type I18n = typeof ofTypeI18n;

export { useI18n, type I18n };

That's it! Now, you should be able to enable Hindi in the Account Console of the Keycloak where your theme is loaded.

Now let's see how to preview the your pages in different languages during devlopement.

Last updated 7 months ago

Was this helpful?

If the languages you with to support is included in this list, great, you can otherwise keep reading.

This process is just a temporary sollution until Keycloak add support for your language, you should be prepared to to delete the file as soon as it's no longer nessesary. For customizing the translation messages and adding your custom messages see .

🌎
skip to the next section
this section
Previewing you Pages In Different Languages
Hindi appear as a supported locales option in the Keycloak Account UI
Hindi appear as an option in the language select dropdown