Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unicode encoding vs property files

 
Tony Smith
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's where the native2ascii utility comes into play.
 
Tony Smith
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. Your point that the unicode and language is subtle but interesting.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic