[cal10n-dev] Better annotations?

Ceki Gulcu ceki at qos.ch
Fri Sep 4 18:39:44 CEST 2009


Ralph Goers wrote:

> 
> This is fragile as it will break if someone uses a different charset 
> than what is now hardcoded in the software. This information should be 
> obtained from the file itself.

True. However, once the encoding for a given translation is
established, it won't change frequently. So it should be more or less
acceptable to hard code it in the enum. This does not mean that your
suggestion to place the encoding information in the file is not a good
one. It's not so easy to accomplish however. To correctly interpret
the encoding information contained in the file, you have to open it
with the correct charset... the chicken or the egg?

>>
>> but the compiler forbids multiple instances of the same annotation.
>>
>> Can you think of a more elegant approach which still allows the user
>> to designate the charset for a given locale?
> 
> Yes. At the risk of repeating myself, build your framework using XML 
> files and let the XML parser use the encoding specified in the file. 
> Property files were not designed for this.  If you insist on using 
> ResourceBundles then require Java 6 and use XML prooperty files and 
> ResourceBundle.Control as described at 
> http://java.sun.com/javase/6/docs/api/java/util/ResourceBundle.Control.html in 
> Example 2.

XML files are necessarily more verbose than property files. Also note that a 
large number of shops do their localization using property files.

I will now go read ResourceBundle.Control.


> Ralph

-- 
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch


More information about the cal10n-dev mailing list