[cal10n-user] Undeclared locales?
Ceki Gulcu
ceki at qos.ch
Fri Sep 18 15:07:34 CEST 2009
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
More information about the cal10n-user
mailing list