[keycloak-dev] i18n/l10n: English text in java code
Thomas Raehalme
thomas.raehalme at aitiofinland.com
Thu Oct 8 05:08:28 EDT 2015
On Thu, Oct 8, 2015 at 7:54 AM, Stian Thorgersen <sthorger at redhat.com>
wrote:
> Default message bundles are Java properties. For Java developers it may be
> expected that they are encoded in ISO-8859-1, but for other people they
> probably expect UTF-8. Java property files are nice as the format is simple
> (key=value is much nicer and easier to write than { "key" : "value" }).
> There's also support for translating property files backed into IDEs.
>
At the moment if you use Java properties with ResourceBundle the file
encoding must be ISO-8859-1. I think Java 9 may introduce support for UTF-8
(http://openjdk.java.net/jeps/226).
Best regards,
Thomas
>
> On 8 October 2015 at 06:48, Thomas Raehalme <
> thomas.raehalme at aitiofinland.com> wrote:
>
>>
>> On Oct 8, 2015 6:53 AM, "Stian Thorgersen" <sthorger at redhat.com> wrote:
>> >
>> > With regards to internationalization I have two questions:
>> >
>> > * Should we fallback to English messages if a key is missing in a
>> translation? Alternative is to show key, but that's not going to help anyone
>>
>> A missing key is a bug and showing the message in the default locale may
>> hide the problem.
>>
>> Even though showing the key does not help the end user it helps the
>> developer and identifies the problem. For this reason I think showing the
>> key would be a good idea.
>>
>> > * Should we change message bundles to UTF-8? Or is ISO 8859-1 going to
>> work for all languages?
>>
>> Depends what those all languages are :-)
>>
>> I think UTF-8 is the best choice as it will handle practically any
>> character.
>>
>> But if you're referring to Java resource bundles the encoding for
>> .properties is ISO-8859-1 but there are means to handle any UTF-8 character.
>>
>> Best regards,
>> Thomas
>>
>> >
>> > On 7 October 2015 at 18:42, Stan Silvert <ssilvert at redhat.com> wrote:
>> >>
>> >> 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
>> >> _______________________________________________
>> >> keycloak-dev mailing list
>> >> keycloak-dev at lists.jboss.org
>> >> https://lists.jboss.org/mailman/listinfo/keycloak-dev
>> >
>> >
>> >
>> > _______________________________________________
>> > keycloak-dev mailing list
>> > keycloak-dev at lists.jboss.org
>> > https://lists.jboss.org/mailman/listinfo/keycloak-dev
>>
>
>
--
*Thomas Raehalme*
*CTO, teknologiajohtaja*
Mobile +358 40 545 0605
*Aitio Finland Oy*
Väinönkatu 26 A
40100 JYVÄSKYLÄ, Finland
Tel. +358 10 322 0040
www.aitiofinland.com <http://www.codecenter.fi>
*Codecenter on nyt Aitio – me kun ei vain koodata!*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-dev/attachments/20151008/637e846d/attachment.html
More information about the keycloak-dev
mailing list