Quantcast
Channel: Magnus K Karlsson
Viewing all articles
Browse latest Browse all 526

Internationalization (i18n) with ResourceBundle and Properties

$
0
0

To externalize local messages, Java have the java.util.ResourceBundle class.

Create a properties file for the default locale. Then create a new properties for each locale with the suffix _<language>_<COUNTRY>, in the same way you initialize java.util.Locale.Locale(String, String).

Example

To load the localized text, use java.util.ResourceBundle.getString(String).

Example

messages.properties

messages_sv_SE.properties

And the Java code to load them.

Output


Viewing all articles
Browse latest Browse all 526