Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 461
frankadelic Avatar asked Mar 13 '10 00:03

frankadelic


2 Answers

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 Oracle article here: https://docs.oracle.com/javase/tutorial/i18n/resbundle/concept.html

like image 186
Buhake Sindi Avatar answered Sep 18 '22 12:09

Buhake Sindi


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

like image 41
Jeff Beck Avatar answered Sep 18 '22 12:09

Jeff Beck