A Developer Gateway To IT World...

Techie Uncle Software Testing Core Java Java Spring C Programming Operating System HTML 5 Java 8 ES6 Project

Localization in java

Create the following file in a folder:


java code:

import java.util.Enumeration;
import java.util.Locale;
import java.util.ResourceBundle;


public class PropertiesDemo
{
    public static void main(String args[])
    {
        Locale[] supportedLocales = { Locale.FRANCE, Locale.GERMAN,   Locale.ENGLISH };
       
        ResourceBundle labels = ResourceBundle.getBundle("LabelsBundle_de", supportedLocales[0]);
        //ResourceBundle labels = ResourceBundle.getBundle("LabelsBundle", supportedLocales[1]);
        Enumeration bundleKeys = labels.getKeys();

        while (bundleKeys.hasMoreElements())
        {
        String key = (String)bundleKeys.nextElement();
        String value = labels.getString(key);
        System.out.println("key = " + key + ", " + "value = " + value);
        }
    }
}





Output:





LEARN TUTORIALS

.

.