You can use ResourceBundle.getBundle( name ) , which returns the correct set according to the user's locale and receives specific messages.
How the ResouceBundle class works, try downloading a package (usually a .properties file) with localized messages. For example, you can:
messages_en.properties ----- greeting = "Hello "
and
messages_es.properties ----- greeting = "Hola "
and use it as follows.
... void main( ... . { ResourceBundle bundle = ResourceBundle.getBundle( "messages", userLocale ); System.out.println( bundle.getString("greeting" ) + " Steve " ); }
And he will print
Hello Steve
if the user language is English (ru) and
Hola Steve
if user language is spanish (es)
The ResouceBundle.getBundle () method not only downloads .properties files, if available, it can also load a class, which in turn can load a message from the database.
See also:
Resourcebundle
Internationalization Brief Introduction
OscarRyz
source share