Developing Locale Awareness

Global Internet applications must be aware of the user locale. Locale-sensitive functions, such as date, time, and monetary formatting, are built into programming environments such as Java and SQL. Applications can use locale-sensitive functions to format the HTML pages according to the cultural conventions of the user locale.

Different programming environments represent locales in different ways. For example, the French (Canadian) locale is represented as follows:

Environment Representation Locale Explanation

Java

Java locale object

fr_CA

Java uses the ISO language and country code.

fr is the language code defined in the ISO 639 standard. CA is the country code defined in the ISO 3166 standard.

SQL and PL/SQL

NLS_LANGUAGE and NLS_TERRITORY parameters

NLS_LANGUAGE ="CANADIAN FRENCH"

NLS_TERRITORY ="CANADA"

Refer to the "Working in a Global Environment" chapter in the Oracle Database 2 Day Developer's Guide.

Table 9-1 shows how some of the commonly used locales are defined in Java and Oracle environments.

Table 9-1 Locale Representation in Java, SQL, and PL/SQL Programming Environments

Locale Java NLS_LANGUAGE, NLS_TERRITORY

Chinese (P.R.C)

zh_CN

SIMPLIFIED CHINESE, CHINA

Chinese (Taiwan)

zh_TW

TRADITIONAL CHINESE, TAIWAN

English (U.S.A)

en_US

AMERICAN, AMERICA

English (United Kingdom)

en_GB

ENGLISH, UNITED KINGDOM

French (Canada)

fr_CA

CANADIAN FRENCH, CANADA

French (France)

fr_FR

FRENCH, FRANCE

German (Germany)

de_DE

GERMAN, GERMANY

Italian (Italy)

it_IT

ITALIAN, ITALY

Japanese (Japan)

ja_JP

JAPANESE, JAPAN

Korean (Korea)

ko_KR

KOREAN, KOREA

Portuguese (Brazil)

pt_BR

BRAZILIAN PORTUGUESE, BRAZIL

Portuguese (Portugal)

pt_PT

PORTUGUESE, PORTUGAL

Spanish (Spain)

es_ES

SPANISH, SPAIN

When writing global applications across different programming environments, the user locale settings must be synchronized between environments. For example, Java applications that call PL/SQL procedures should map the Java locales to the corresponding NLS_LANGUAGE and NLS_TERRITORY values and change the parameter values to match the user locale before calling the PL/SQL procedures.