Upload
tuan-ngo
View
415
Download
0
Tags:
Embed Size (px)
Citation preview
Internationalization
What is internationalization? the process of creating applications which can adapt and adjust to various countries, languages, regions.
I18N
What is localization? the process of adapting an application for a specific language or country by addition of locale-specific components and translation of text.
L10N
Why need internationalization?
Why need internationalization? Difference: - Language
- Currency
- Date and time
Alternatives to solve the Problem? Develop product
Translate product
Benefits of I18N and L10N No hard coding
No recompilation
Localized quickly
Unicode provide a unique number for every character irrespective of platform, program or language.
Unicode is a 16-bit character encoding
Significance of Unicode Java platform uses Unicode as its native character encoding.
\Uxxxx : X : hexadecimal digit
Internationalization Process
Properties file MessageBundle.properties
MessageBundle_fr_FR.properties
MessageBundle_de_DE.properties
Locale Constructors:
public Locale(String language, String country)
public Locale(String language)
Locale usLocale = new Locale(“en”,”us”)
Methods public static Locale getDefault()
public final String getDisplayCountry()
public final String getDisplayLanguage()
Resource Bundle Localized or translated into different languages
Handled for multiple locales at the same time
Supported for more locales later
Using Resource Bundle ResourceBundle getBundle(String, Locale)
Fetching the text from Resource Bundle public final String getString(String key)
Fetching the text from Resource Bundle public abstract Enumeration <String> getKeys()
Internationalization Elements
Component Captions
Caption text
Dates
Numerals
Percentage
Need for Formatting?
12345678
US 12,345,678
EU 12.345.678
NumberFormat class
getNumberInstance()
getCurrencyInstance()
getPercentInstance()
format()
DateFormat class
DateFormat getDateInstance (style, locale)
Formatting Message
It is not always possible to create a grammatically correct sentences with concatenation of phrases and variables.
So we need MessageFormat.
Steps for MessageFormat. Identify variables
Create template
Create object array
Create instance
Apply and Format