just thinking about the use of cal10n in OSGI environment
1. some bundles with enumerations and also l10n resourcebundles
2. other bundles need localized enum literals - I want to provide this
thru a service from inside Enum bundles
1. has dependency to ICAL10N, but ICAL10N also needs to know the bundles
containing the enum,
because ICAL10N tries to find the ResourceBundle from classpath
but I dont like to use Dynamic-Import *, and also want to avoid Eclipse
Buddy policy
--
how to solve the dependency from ICAL10N to all these bundles containing
resourceBundle .properties files ?
I looked into source of MessageConveyor and have seen that I need a
different cache and lookup implementation
so it seems that the only way is to write a new implementation -
soething like
MessageConveyorOSGI implementing IMessageConveyor
or do you have another idea ?
ekke
--
ekke (ekkehard gentz)
independent software-architect
senior erp-consultant
eclipse | osgi | equinox | mdsd | oaw | emf | uml
max-josefs-platz 30, D-83022 rosenheim, germany
mailto:ekke@ekkes-corner.org
homepage (de): http://gentz-software.de
blog (en): http://ekkes-corner.org
twitter: @ekkescorner
skype: ekkes-corner
Steuer-Nr: 156/220/30931 FA Rosenheim, UST-ID: DE189929490
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