How do we Internationalization in java
Usually applications are developed in english, but when we want our applications
to target users or customers of different countries, Sun provides Internationalization concept in java.
Internalization or I18n is set of java classes or interfaces provided by java to support the global application in java. It means java applications works with multiple languages and multiple countries.
What are items to do in Internationalization
4. Message Format
when we target above things, application is named as internationalized applications
In simple terms, we develop applications in one langugae and can change to different local or localize the applications by doing the above things.
In java, java.util.Locale class holds localized information
For example, have coded for creating button in swing
JButton buttonEx=new JButton("Upload");
here, button label message is hard coded, It is very difficult if we want to develop this application to target different regions.
To Localize the application, we have to separate the labels and place them in property or resource file.
label message in resource file for US country is
button.upload.label =Upload– label_en_US.property
In the same way we need to create one resource property file for each country or language. This can be added to application after application development is done.
button.upload.label = starten– app_de_DE.property
In java, Java.util.ResourceBundle is used to read resource bundles or property files.
In order to read resource files we can use java.util.ResourceBundle.
ResourceBundle rb = ResourceBundle.getBundle(basename, locale);
The above code will read the locale specific resource file , if it is not found, default locale resource is considered.
In Java applications, java.text.DateFormat,
java.text.NumberFormat, java.text.MessageFormat are used to achieve Internationalization
If you like this post, please share by clicking google +1 button