Locale (Internationalization/ i18n) in Java.

Locale (Internationalization/ i18n) in Java.


Posted in : Java Posted on : November 23, 2011 at 6:37 PM Comments : [ 0 ]

In this tutorial you will learn about Locale class.

Locale (Internationalization) in Java.

In this tutorial you will learn about Locale class.

Some times it is required to make an application to keep in mind that it can be used in different region and different geographical areas, users of different region may not necessary to know the language into which the application has been developed and there is also may not necessary that the time is the same as the place where the application has been developed. Due to such problem the application which has been developed can not be broadly used.

So the solution of such problem is reduced in java by introducing the Locale class for java developer. Locale class is a class of java.util package. To use this class, object's can be created using the following constructor's. :

Locale( String lang/langCode);

Locale( String lang/langCode, String country/countryCode);

Locale( String lang/langCode, String country/countryCode, String variant);

List of langCode and countryCode supported by java can be found from the site http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt, and http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html respectively.

Locale is nothing, it is only a process that identifies the object's you want to get.

Method :

There are various methods of Locale class, some of the commonly used methods are as follows :

getAvailableLocales() : This method is used to find out the list of installed locales.

getCountry() : This method is used to find out the list of country/region code.

getDisplayCountry() : This method is used to find out the suitable name for the locale's country.

getDisplayLanguage() : This method is used to find out the suitable name for the locale's language.

getDisplayVariant() : This method is used to find out the suitable name for the locale's variant code.

getVariant() : This method is used to find the variant code for current locale.

etc.

Besides these this class has some static constant fields that can be used directly for their locale.

Constants for Countries are :

CANADA, CANADA_FRENCH, CHINA, FRANCE, GERMANY, ITALY, JAPAN, KOREA, PRC, TAIWAN, UK, US.

Constants for Languages are :

CHINESE, ENGLISH, FRENCH, GERMAN, ITALIAN, JAPANESE, KOREAN, SIMPLIFIED_CHINESE, TRADITIONAL_CHINESE.

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics