User's Manual
Developing Locale Awareness
Beta Draft Building Global Applications 8-3
Determining User's Locale
In a global environment, your application will need to accept users with different
locale preferences. The application need to determine the user's preferred locale. Once
that is known, the application should construct HTML content in the language of the
locale, and follows the cultural conventions implied by the locale.
One of the most common methods in determining a user's locale, is based on the
default ISO locale setting of the user's browser. Every HTTP request sends the default
ISO locale of the browser, with the Accept-Language HTTP header. If the
Accept-Language header is NULL, then the locale should default to English.
The following PHP code will retrieve the ISO locale from the Accept-Language HTTP
header via the $_SERVER Server variable.
$s = $_SERVER["HTTP_ACCEPT_LANGUAGE"]
Developing Locale Awareness
Once the user's locale preference has been determined, the application can call
locale-sensitive functions, such as date, time, and monetary formatting to format the
HTML pages according to the cultural conventions of the user's locale.
When writing global applications across different programming environment, the user
locale settings must be synchronized between environments. For example, PHP
applications that call PL/SQL procedures should map the ISO locales to the
corresponding NLS_LANGUAGE and NLS_TERRITORY values and change the
parameter values to match the user's locale before calling the PL/SQL procedures.
The table below shows how some of the commonly used locales are defined in ISO and Oracle environ-
ments.
Table 8–1 Locale Representations in ISO, SQL and PL/SQL Programming Environments
Locale Locale ID NLS_LANGUAGE NLS_TERRITORY
Chinese (R.P.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 de GERMAN GERMANY
Italian it ITALIAN ITALY
Japanese ja JAPANESE JAPAN
Korean ko KOREAN KOREA
Portuguese (Brazil) pt-BR BRAZILIAN
PORTUGUESE
BRAZIL