i18n stands for internationalization (there are 18 characters between the beginning i and
the final n). The act of getting ready internationally is called internationalization.
l10n stands for localization (10 characters between the first l and the final n).Localization
is the means by which i18n applications can be used for local regions.
the final n). The act of getting ready internationally is called internationalization.
l10n stands for localization (10 characters between the first l and the final n).Localization
is the means by which i18n applications can be used for local regions.
What is Locale?
A Locale is a relatively simple object. It identifies a specific language and a geographic
region. It represents the language and cultural preferences of a geographic area. A Locale's
language is specified by the ISO 639 standard, which describes valid language codes that
can be used to construct a Locale object.
A Locale is a relatively simple object. It identifies a specific language and a geographic
region. It represents the language and cultural preferences of a geographic area. A Locale's
language is specified by the ISO 639 standard, which describes valid language codes that
can be used to construct a Locale object.
The Locale class has the following important constructors:-
Locale(String language, String country)
Locale(String language,String country, String variant)
Language represents the language code en English, fr French, zh Chinese, ja Japanese etc.
Country represents country code US United States, FR France, CA Canada etc.
Variant can be used to create a more specific Locale than what's possible with just language and country codes.
How do we display numbers, currency and Dates according to proper
Locale format?
When we say 1,456 is one thousand and four hundred and fifty six in USA but its one and
four fifty six in France. That can be easily achieved by java.text.NumberFormat.To
instantiate a NumberFormat object, use the factory method getInstance, which returns a
NumberFormat object suitable for your default locale. You can, of course, ask for anobject with a specific locale in mind. To specify a locale other than your default, use
getInstance (Locale locale).
Same holds true for currency. Each locale has its own preferences for currency symbols,
negative amount format, leading zeros, group separators, decimal point symbol, and
currency symbol position. Currency and numbers have a lot in common. Although you
still use NumberFormat, you call a different factory method to get a currency format
object, getCurrencyInstance. This method will return a currency format object for the
default locale. You can use this factory method just like you used the number factory
method; call getCurrencyInstance(Locale locale) to specify a specific locale. Again, use
the format method to produce a user visible String object. The currency formatter will
handle all the details of selecting the correct currency symbol, placing that symbol in the
string, and applying grouping rules.
The java.text.DateFormat class provides the getDateInstance method that creates a
formatter for your default locale. The format method works in the same way as the other
format methods covered so far, and applies the specific format rules for your chosen
locale.