
Simon Brandhof asks: Is it possible to discover bundles at runtime in cal10n ? I can't list all the available locales of LocaleData at compile time. Thanks Answer: Yes, as long as you don't expect automatic verification, @LocaleData information is entirely optional. The default implementation of IMessageConveyor, namely MessageConveyor, will discover bundles for any locale. For example, here is a mininal enum: @BaseName("minimal") public enum Minimal { A; } Assuming the file "minimal_de.properties" exists on your class path, and contains: A=etwas auf deutch the following code will return work: MessageConveyor mc = new MessageConveyor(Locale.GERMAN); assertEquals("etwas auf deutch", mc.getMessage(Minimal.A)); However, the encoding for minimal_de.properties will be assumed to be the system's default encoding. You can also have a mixed approach, where you specify some encodings and not others. @BaseName("minimal") @LocaleData( defaultCharset="UTF8", value = { @Locale("en_UK"), @Locale("fr_FR") } ) public enum Minimal { A; } In the above example, tooling which comes with CAL10N will verify the consistency for en_UK and fr_FR. The default encoding will be "UTF8" for all bundles, including the bundle "minimal_de.properties" for German (which remains undeclared). You could also mix default encoding, bundle specific encoding and undeclared bundles. For example, @BaseName("minimal") @LocaleData( defaultCharset="UTF8", value = { @Locale("en_UK"), @Locale("fr_FR"), @Locale(value="tr_TR", charset="ISO8859_3") } ) public enum Minimal { A; } In the above example, tooling which comes with CAL10N will verify the consistency for en_UK, fr_FR and tr_TR. The default encoding will be "UTF8" for all bundles, including the bundle "minimal_de.properties" for German (which remains undeclared) but excluding "minimal_tr_TR.properties" (Turkish) which will be encoded in ISO8859_3 (Turkish). HTH, -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch

I forgot to mention that CAL10N's main feature, verification of keys used in java classes, is performed by the Java compiler and remains totally independent of any @LocaleData declarations. Ceki Gulcu wrote:
Simon Brandhof asks:
Is it possible to discover bundles at runtime in cal10n ? I can't list all the available locales of LocaleData at compile time. Thanks
Answer:
Yes, as long as you don't expect automatic verification, @LocaleData information is entirely optional. The default implementation of IMessageConveyor, namely MessageConveyor, will discover bundles for any locale. For example, here is a mininal enum:
@BaseName("minimal") public enum Minimal { A; }
Assuming the file "minimal_de.properties" exists on your class path, and contains:
A=etwas auf deutch
the following code will return work:
MessageConveyor mc = new MessageConveyor(Locale.GERMAN); assertEquals("etwas auf deutch", mc.getMessage(Minimal.A));
However, the encoding for minimal_de.properties will be assumed to be the system's default encoding.
You can also have a mixed approach, where you specify some encodings and not others.
@BaseName("minimal") @LocaleData( defaultCharset="UTF8", value = { @Locale("en_UK"), @Locale("fr_FR") } ) public enum Minimal { A; }
In the above example, tooling which comes with CAL10N will verify the consistency for en_UK and fr_FR. The default encoding will be "UTF8" for all bundles, including the bundle "minimal_de.properties" for German (which remains undeclared).
You could also mix default encoding, bundle specific encoding and undeclared bundles. For example,
@BaseName("minimal") @LocaleData( defaultCharset="UTF8", value = { @Locale("en_UK"), @Locale("fr_FR"), @Locale(value="tr_TR", charset="ISO8859_3") } ) public enum Minimal { A; }
In the above example, tooling which comes with CAL10N will verify the consistency for en_UK, fr_FR and tr_TR. The default encoding will be "UTF8" for all bundles, including the bundle "minimal_de.properties" for German (which remains undeclared) but excluding "minimal_tr_TR.properties" (Turkish) which will be encoded in ISO8859_3 (Turkish).
HTH,
-- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch

29th of October 2009 - Release of CAL10N 0.7.2 I am happy to announce the immediate availability of CAL10N version 0.7.2. This release adds OSGi manifest information in cal10n artifacts. Please refer to the the news page for precise details. http://cal10n.qos.ch/news.html You can download cal10n, including full source code, class files and documentation on our download page, shown below. http://cal10n.qos.ch/download.html You can receive cal10n related announcements by subscribing to the qos.ch announce mailing list. To subscribe to qos.ch announce list, please visit the following URL. http://www.qos.ch/mailman/listinfo/announce Best regards, -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch
participants (1)
-
Ceki Gulcu