Language and Locale

The language of an application is associated not only with a character set, but with regional conventions for sorting, for expressing numbers, currency, date and time, and so on. The combination of language and region is known as locale.

For example, the locale can affect the way data is displayed:

Effect of Locale on Data Display
Locale Code Locale Currency and Numeric Separators Date Time
en_US English (United States) $12,345.67 Wednesday, December 2, 2009 4:08:42 PM
en_GB English (United Kingdom) £12,345.67 Wednesday, 2 December 2009 16:08:42
fr_FR French (France) 12 345,67 € mercredi 2 décembre 2009 16:08:42
fr_CA French (Canada) 12 345,67 $ mercredi 2 décembre 2009 16:08:42
nl_NL Dutch (Netherlands) € 12.345,67 woensdag 2 december 2009 16:08:42
ja_JP Japanese (Japan) ¥12,346 2009年12月2日水曜日 16:08:42
bg_BU Bulgarian (Bulgaria) 12 345,67 лв. 02 декември 2009, сряда 16:08:42

The locale can also affect the sorting and searching (pattern matching). Diacritical symbols may be ignored or applied when sorting, depending on the language and region. For example, Swedish sorts the letters v and w as the same base letter, so searching should do the same. Non-alphabetic languages may be sorted phonetically or by the character appearance.

Uniface makes use of International Components for Unicode (ICU) and Common Locale Data Repository (CLDR) for locale and language support.

Uniface supports locale-based processing using collation and formatting functionality provided by ICU (International Components for Unicode). It applies the UTS #10: Unicode Collation Algorithm and locales available from CLDR - Unicode Common Locale Data Repository. You can find out more about the rules applicable to specific locales from these web sites.

Note: In dynamic server pages (DSPs), JavaScript libraries are used for locale-based processing in the DSP client. To set the locale for the DSP client, you can use $webinfo("locale") rather than the NLS locale settings described below. However, the NLS locale settings are used on the server-side of a DSP. For more information, see Dynamic Server Pages and $webinfo("Locale").

Setting the NLS Locale

You can specify the locale using the $NLS_LOCALE or the $nlslocale ProcScript function. The value can be:

  • classic—locale-based processing is turned off, and Uniface behaves as it did prior to version 9.4.01.
  • system—sorting and formatting behavior is based on the locale defined for the local (client) system; Windows only.
  • Locale —locale base processing is applied.

    The Locale specifies a two-letter language code and two-letter country code, for example, fr_CA for French (Canada).

    Uniface applies locale-specific rules for:

    • Displaying numeric, floating point, currency, and date and time data.
    • Sorting entities and lists in ProcScript, and ordering hitlists that have not been ordered using DBMS order by functionality.
    • Searching for strings that match a specific pattern.
    • Transforming strings between uppercase and lowercase in ProcScript

The value of the NLS locale determines the default behavior of other settings that govern specific aspects of locale-based processing. If NLS locale is set to system or a locale, these other settings can be used to override and fine-tune the locale-based behavior.

Fine-Tuning Locale-Based Processing

There may be circumstances when you want the locale to be ignored. For example, you may want sorting routines to apply locale-based rules, but case transformation code to ignore them.

The Uniface mechanism for controlling locale-based processing is based on the NLS locale. If it is set to a locale (or to system), and no other settings are applied, NLS processing rules are applied in all circumstances. To switch off locale-based processing, you can use NLS assignment settings and ProcScript functions that control specific areas of locale-related functionality.

NLS Assignment Settings and ProcScript Functions
Assignment Setting Equivalent ProcScript Function Default Value Description
  $nlslocalelist N/A Return the list of locales, or the locale in use on the current system.
$NLS_LOCALE $nlslocale classic Set (or return) the NLS locale setting, which determines how Uniface handles locale-base processing.
$NLS_FORMAT $nlsformat nlslocale Set (or return) the NLS format setting, which specifies how locale-sensitive data, such as number, currency, and date and time, are displayed.

Note:  The value of this setting also affects the data type conversion performed by ProcScript functions such as $number and $date ProcScript functions.

$NLS_SORT_ORDER $nlssortorder nlslocale Set (or return) the NLS sort order setting, which specifies whether locale-based locale-based sorting is applied when sorting lists or entities.
$NLS_CASE $nlscase nlslocale Set (or return) the NLS case setting, which specifies whether locale-based case conversion rules are applied when using $uppercase and $lowercase
$NLS_DATE_UNIFACE_PARSER

$NLS_DATETIME_UNIFACE_PARSER

For specified NLS date formats, have Uniface parse numeric input (apart from the separator) for the day of the month, month, and year.

By default, the ICU parser is used for short, medium, long or full Date formats. If the input doesn't meet the ICU requirements, the displayed date can be unpredictable. The Uniface parser is more flexible.

NLS assignment settings enable you to set the default behavior for the application, and NLS ProcScript functions enable you to override these values in ProcScript.

The default value of $NLS_LOCALE is classic, ensuring that behavior is compatible with previous versions. The default value of the other settings is nlslocale, ensuring that they follow the value set by $NLS_LOCALE. This fall-through mechanism ensures that you can turn NLS processing on or off as required.

Other ProcScript instructions, as well as display formats have options that enable you to apply or ignore locale-based rules on a case-by-case basis, providing fine-grained control over locale-based processing:

Mechanisms for Fine-Grained NLS Control
Mechanism Description
sort

sort/list

$sortlist

$sortlistid

An optional Type parameter enables you to apply or ignore locale-based processing when sorting entities and lists, or to use case-sensistive or case-insensitive sorting. The value specified here overrides the current value $nlssortorder.
$lowercase

$uppercase

An optional second parameter enables you to apply or ignore locale-based case transformations, overriding the current value of $nlscase.

$lowercase (String, "classic")

Display formats NLS display formats are available for data of type Numeric, Float, Date, Time, and Datetime, overriding the current value of $nlsformat.
Syntax strings Syntax strings can include codes that turn case-sensitive pattern matching on or off, or apply locale-based rules. These are applicable for pattern-matching behavior in syntax strings and ProcScript functions, such as $scan, $rscan, $ltrim and $rtrim.

Disable Locale-Based Processing

To turn locale-based processing off for the entire application:

;Application assignment file
[SETTINGS]
$NLS_LOCALE = classic

Override Locale-Based Processing

Set the application default to turn locale-based processing off for case conversion:

;Assignment file
[SETTINGS]
$NLS_LOCALE = fr_CA
$NLS_CASE = classic   ;turns locale-based processing off for case conversion

Related Topics