Custom locale messages do not apply

Hello guys,

I try to add a custom locale support to a Keycloak installation and the texts do not load.
I can see that the locale is chosen (I look at the locale select and see it selected) but the texts that are loaded are the default fallback English ones.

This is my theme folder structure:

image

This is the contents of messages_he.properties:

image

This is theme.properties:

image

What am I doing wrong?
Please help

Hi, before you investigate any further, can you try the following :

  • set the theme for Keycloak’s default theme (not sure which one you have been using);
  • set “he” as your default locale for the realm your are testing;
  • expire your realm cache;
  • open a new Incognito/Private window in your browser and check if the text for your Login screen was changed - you should also have an option to switch to another locale;
  • if it remains in English, try restarting your server and see if it works.

If you are using RH SSO, I believe locales do not work the same way.

Hi, lvillaca I tried all of your suggestions but unfortunately it did not work, including restarting the server.

I tried adding the French language to the supported languages and it worked fine. It seems like only the custom language I’ve added is not working.
Even overrides I added for French in my theme worked.

There is no issue with the Hebrew script, I know that from adding the “locale_he” message to the messages_en.properties file with a value in Hebrew.

Do you have any more suggestions, please?

Hi @gabguy, I was about to tell you to try using unicode instead of actual hebrew letters, but it seems like those are working fine for you.

Did you provide messages_he.properties only for your “labos” theme? It seems you are extending not only login part of the theme, but also email and account - you may want to check this post. You can also try adding the message bundle it to keycloak / base theme login dir structure and check if it makes any difference. Good luck there!

Thank you very much for your responses.
Unfortunately, I’ve tried adding the messages_he files to the base theme which my theme extends and it still did not work.
I also added the file to each part of the theme login / account / email and enabled my theme for all three in KC admin settings, but that also did not solve the issue.

Might be a bug with KC?

You mentioned about a test you performed validating some Hebrew letters:

There is no issue with the Hebrew script, I know that from adding the “locale_he” message to the messages_en.properties file with a value in Hebrew.

I wonder if there is any character that could be causing an issue with freemarker.

Can you try getting your English values to messages_he.properties - maybe you can keep the Hebrew value you tested - and see Keycloak recognizes this he file? Then you could maybe migrate the remaining values in blocks, and find a culprit char (if there is one).

Either that or the other way around - replace the full messages_en.properties oil with all your Hebrew values and check if that works.

Thanks again.

Well I tried putting my Hebrew strings in the messages_en file and it works well.
So it just seems like the messages_he file is not loading for some reason and there is no issue with the strings (or chars) themselves.

Any further ideas?

try removing the locales line from the theme.properties file and see if that makes a difference

I have a minimal theme under https://github.com/zonaut/keycloak-extensions/tree/master/theme-minimal/src/main/resources and don’t have that locales property

Thanks, unfortunately this did not work.

Hello,
I’m having the exact same issue - did you manage to resolve it, or find a way around it?

@shunit Unfortunately still no solution for this issue

I believe newer Java runtimes convert he to iw for OS compatibility. Can you try changing your file to messages_iw.properties?

1 Like

@ben.overcash - Thank you! Using “iw” instead of “he” works!

Update
Yes, indeed. You cannot name the files messages_he.properties. Any other name works.
I named mine messages_heb.properties and it works well