views:

172

answers:

3

Does Java have an equivalent to .NET resource (.resx) files for localization?

In .NET, you can define resources as key-value pairs within a standard XML document.

The resource files are named according to the culture. For example:

myresources.resx

myresources.en-us.resx

myresources.fr-fr.resx

myresources.de-de.resx

Is there an equivalent in Java? Are the similar naming conventions used for files?

+1  A: 

What you are looking for is ResourceBundles in Java. Here is a nice link

Jeff Beck
A: 

ResourceBundles should be the Java equivalent. Refer to http://java.sun.com/javase/6/docs/api/java/util/ResourceBundle.html

+3  A: 

The Java equivalent is called ResourceBundle. Resource Bundle are java properties file (with a .properties file extension that can be accessed using java.util.ResourceBundle class) that contains locale-specific data.

From your example,

myresources.resx
myresources.en-us.resx
myresources.fr-fr.resx
myresources.de-de.resx

Is equivalent to (in java)

myresources.properties
myresources_en_US.properties
myresources_fr_FR.properties
myresources_de_DE.properties

For Technical data on ResourceBundle check this Sun article here: http://java.sun.com/developer/technicalArticles/Intl/ResourceBundles/

The Elite Gentleman
Even Wikipedia has something to say: http://en.wikipedia.org/wiki/Java_resource_bundle
The Elite Gentleman
I believe they are underscore separated, and country code is capitalized - e.g., myresources_en_US.properties
Jack Leow
Yeah, I saw the issue....I already had fixed that.
The Elite Gentleman