aspose file tools*
The moose likes Java in General and the fly likes unicode encoding vs property files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "unicode encoding vs property files" Watch "unicode encoding vs property files" New topic
Author

unicode encoding vs property files

Tony Smith
Ranch Hand

Joined: Mar 15, 2005
Posts: 77
We're i18n'ing an application, and the rubber is hitting the road.

Properties files have the form file_'lang'_'region'.properties.

This allows us to generate different text (for example) for a single property for British English, US English, and French (assuming French is my default locale.)

My question involves Unicode. We have to store Unicode in a database, but there are times where we'd prefer to use properties files. Out plan is to generate the properties files from the database so there is one official source.

Finally:
Does unicode take region into account? For example, US English could be defined in the following file: file_en_US.properties while British English could be in file_en_BR.properties.

If encoding takes region into account then my phrase table needs the language and the region. If it doesn't, then it only needs the language.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
Unicode encoding is independent of either language or region. It's a question of content: if you have content for en_US that is different from en_GB, then you need two property files, otherwise one "en" file would be sufficient.
[ September 12, 2006: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
How are you reading your properties files? The java.util.Properties class requires them to be in ISO 8859-1, not any Unicode encoding, doesn't it?


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
That's where the native2ascii utility comes into play.
Tony Smith
Ranch Hand

Joined: Mar 15, 2005
Posts: 77
Thank you. Your point that the unicode and language is subtle but interesting.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Originally posted by Ulf Dittmer:
That's where the native2ascii utility comes into play.


Well, yes, but that's a bit of a clunky way to work, isn't it? If your data really does have lots of international characters in it, wouldn't it be better to choose a file format that copes properly? E.g. XML.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
It's an additional step to use native2ascii, but in a big Ant build, what's another step out of 30 or so

But seriously, property files are the way to go for Java to pick up Locale-specific content, without anything that needs to be programmed to make it work. How would you teach the JVM to use XML files - by writing your own ResourceBundle implementation?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unicode encoding vs property files