Вы находитесь на странице: 1из 31

Internationalization

Lecture-04
Distributed Component-Based Software Development
Internationalization
(I18n)
Objectives
Applications that display data in formats
appropriate to the culture and display locale
appropriate strings in the user interface are
considered globally ready applications.
You can create globally ready applications with
use of Net beans and Visual Studio IDE by
taking advantage of the built-in support for
globalization and localization.
In this lesson, you will learn how to implement
localization and globalization in a Windows
Forms application.

What is Internationalization?
You want to have an application that
works in English and French today, and
tomorrow could easily have Spanish
added.
How do you do it?


Globalization and Localization
Globalization and localization are different
processes of internationalization.
Globalization
Refers to formatting existing data in
formats appropriate for the current culture
setting.
Localization
On the other hand, refers to retrieving
appropriate data based on the culture.
Globalization / Localization
Globalization
Designing applications to be adopted to the global
marketplace
In some countries, currency is formatted using a period (.) as a
thousand separator and a comma (,) as a decimal separator,
while other countries use the opposite convention. A globalized
application formats existing currency data with the appropriate
thousand separator and decimal separator based on the current
culture settings.


Globalization / Localization
Localizability
Separate culture dependencies from code. The title of a form is
displayed in a given language based on the locale in which
it is deployed. A localized application retrieves the appropriate
string and displays it based on the current culture settings.


Localization(I10n)
Adapting applications for a particular market
Content translation, feature customization
Changes independent of compiled source

What To Localize?
Static Application Content
Usually hard-coded for presentation
For example
Menu captions
Control captions
Labels, buttons, selection options, list options
Web page content
*.aspx, *.ascx, *.html, *.xml

What To Localize?
Dynamic Application Content
Content populated at runtime from XML files,
databases, and other data sources

Need location of content to be organized by
culture
What is Unicode?

Unicode provides a unique number for
every character,
no matter what the platform,
no matter what the program,
no matter what the language.

Unicode
Sinhala -0D80 0DFF
Tamil -0B80 0BFF


www.unicode.org

Culture
Culture refers to cultural information about the country or
region in which the application is deployed.
The cultures are represented by a culture code that
represents the current language.

Internationalization
Locale/Culture
International Standards Organization (ISO)
Conventions
Language Code - ISO 639-1
I.e., en, fr, de, es, si
Country Code - ISO 3166
I.e., CA, US, EC, ES, LK
Together, they identify culture
I.e., en-CA, en-US, es-EC, es-ES, si-LK


.net Approach

Using VS IDE
Set the forms Localizable
Property to true.
Then use the specific
Locale to define the UI
Changing the Current Culture

Your application automatically reads the culture settings of the system
and implements them. Thus, in most circumstances, you will not have
to manually change the culture settings.

You can, however, change the current culture of your application in
code by setting the current culture to a new instance of the CultureInfo
class.
The CultureInfo class contains information about a particular culture
and how it interacts with the application and system.

For example, the CultureInfo class contains information
about the type of calendar, date formatting, currency formatting etc. for
a specific culture.

To set the current culture of an application programmatically by setting
the CurrentThread.CurrentCulture and CurrentUICulture properties to a
new instance of the CultureInfo class.
:

Java Internationalization
Locale object
ResourceBundle object
Properties files
Using NetBeans IDE
Key/Value Pairs

To create a locale
After Internationalization
MessagesBundle_de_DE.properties
greetings = Hallo. farewell = Tsch. inquiry = Wie
geht's?
MessagesBundle_en_US.properties
greetings = Hello. farewell = Goodbye. inquiry = How
are you?
MessagesBundle_fr_FR.properties
greetings = Bonjour. farewell = Au revoir. inquiry =
Comment allez-vous?

Properties Files

Stores information about the
characteristics of a program or
environment.
Is in plain-text format.
You can create the file with just about any
text editor.
Define the Locale

The Locale object identifies a particular
language and country
Eg:
aLocale = new Locale("en","US");
caLocale = new Locale("fr","CA");
frLocale = new Locale("fr","FR");
Sample Language Codes

Language
Code
Description
de
German
en
English
fr
French
ja
Japanese
jw
Javanese
ko
Korean
zh
Chinese
You can find a full list of the ISO-639 codes at
http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt
Sample Country Codes
Country Code Description
CN
China
DE
Germany
FR
France
IN
India
US
United States
A copy of ISO-3166 can be found at http://www.chemie.fu-
berlin.de/diverse/doc/ISO_3166.html
Using the ResourceBundle

contain locale-specific objects
Use to isolate locale-sensitive data, (such
as translatable text )
message = ResourceBundle.getBundle("MessagesBundle",
currentLocale);

Eg : MessagesBundle_en_US.properties
Fetch the Text from the ResourceBundle

The properties files contain key-value
pairs

String msg1 = messages.getString("greetings");

Key greetings
Thank You

Вам также может понравиться