[keycloak-dev] i18n/l10n: English text in java code

Stan Silvert ssilvert at redhat.com
Wed Oct 7 12:42:58 EDT 2015


Marko brought this to my attention yesterday.  For some things, we 
dynamically create UI.  In this case, the java code contains the English 
text and it needs to be localized.  Luckily, the solution was pretty 
straightforward.  We just replace the English text with a key into the 
message bundle.  The html template that displays this text already pulls 
from an Angular scope so we just leave that alone and pass it through 
the |translate filter.  You do need to also add the double-colon.

One nice side effect is that if the key is not found in the bundle then 
the output of the translate filter is the unchanged text.  This means 
that any code which has not converted to using bundle keys will still 
work as expected.   And, any third-party providers can just pass in 
plain text if they don't care about l10n.  If they ever do care about 
l10n we will just need to provide a means for them to add key/value 
pairs to the resource bundles.

Here is an example for anyone who needs to localize English text 
embedded in java:
https://github.com/ssilvert/keycloak/commit/c9437595b70810c4472325373dd8833c37be8549

Stan


More information about the keycloak-dev mailing list