Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1260600
  • 博文数量: 264
  • 博客积分: 10772
  • 博客等级: 上将
  • 技术积分: 2325
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-25 11:54
文章分类

全部博文(264)

文章存档

2012年(4)

2011年(51)

2010年(31)

2009年(57)

2008年(51)

2007年(70)

分类: LINUX

2007-08-17 20:35:37

What Is a Locale?

A key concept for application programs is that of a program's locale. The locale is an explicit model and definition of a native-language environment. The notion of a locale is explicitly defined and included in the library definitions of the ANSI C Language standard.

A locale consists of a number of categories for which country-dependent formatting or other specifications exist. A program's locale defines its code sets, date and time formatting conventions, monetary conventions, decimal formatting conventions, and collation (sort) order.

A locale can be composed of a base language, country (territory) of use, and an optional codeset. Codeset is usually assumed. For example, German is de, an abbreviation for Deutsch, while Swiss German is de_CH, CH being an abbreviation for Confederation Helvetica. This convention allows for specific differences by country, such as currency unit notation.

More than one locale can be associated with a particular language, which allows for regional differences. For example, an English-speaking user in the United States can select the en_US locale (English for the United States), while an English-speaking user in Great Britain can select en_GB (English for Great Britain).

Generally the locale name is specified by the LANG environment variable. Locale categories are subordinate to LANG but can be set separately, in which case they override LANG. If the LC_ALL operand is set, it overrides LANG and all the separate locale categories.

The locale naming convention is:

language[_territory][.codeset] [@modifier]

where a two-letter language code is from ISO 639, a two-letter territory code is from ISO 3166, codeset is the name of the codeset that is being used in the locale, and modifier is the name of the characteristics that differentiate the locale from the locale without the modifier.

All Solaris product locales preserve the Portable Character Set characters with US-ASCII code values.

For more information on the portable character set, refer to “X/Open CAE Specification: System Interface Definitions, Issue 5” (ISBN 1–85912–186–1).

A single locale can have more than one locale name. For example, POSIX is the same locale as C.

C Locale – the Default Locale

The C locale, also known as the POSIX locale, is the POSIX system default locale for all POSIX-compliant systems. The Solaris Operating System is a POSIX system. The Single UNIX Specification, Version 3, defines the C locale. Register to read and download the specification at:

You can specify that your internationalized programs run in the C locale, in one of two ways:

  • Unset all locale environment variables.

    system% unsetenv LC_ALL LANG LC_CTYPE LC_COLLATE LC_NUMERIC \
    					LC_TIME LC_MONETARY LC_MESSAGES

    Unsets all locale environment variables. Runs the application in the C locale.

  • Explicitly set the locale to C or POSIX.

    system% setenv LC_ALL C
    system% setenv LANG C

    Some applications check the LANG environment variables without actually calling setlocale(3C) to reference the current locale. In this case, setenv explicitly sets the C locale by specifying the LC_ALL and LANG locale environment variables. For the precedence relationship among locale environment variables, see the setlocale(3C) man page.

To check the current locale settings in a terminal environment, run the locale(1) command.

system% locale

Full and Partial Locales

A full Solaris locale has all of the listed functions and the localized system messages in the relevant language. Partial locales have no localized messages installed. All locales in the Solaris environment are capable of displaying localized messages, provided that localized messages for the relevant language are installed. For example, the following locales can be either partial or full locales:

  • de_DE.ISO8859–1

  • de_DE.ISO8859–15

  • de_DE.UTF-8

  • de_AT.ISO8859–1

  • de_AT.ISO8859–15

  • de_CH.ISO8859–1

When the German message translations are installed from the Languages CD, all of the above locales become full locales because they have access to a fully translated desktop. The Languages CD contains message translations for the following languages and locales:

  • German

  • French

  • Spanish

  • Swedish

  • Italian

  • Japanese

  • Korean

  • Simplified Chinese locale

  • Traditional Chinese locale

All partial locales are available on the Software CD. Message translations are available on the Languages CD.

All English locales are also full locales and are available on the Software CD.

Behavior Affected by Locales

Different cultures often use different conventions to format numbers, to write the date and time, to delimit words and phrases, or to quote written and spoken material. A locale determines how the following operations, files, formats, and expressions are handled for different regions:

  • Encoding and processing of text data

  • Language identification and encoding of resource files

  • Rendering and layout of text strings

  • Interchange of text between clients

  • Input method selection to meet the codeset and text processing requirements of the chosen script

  • Font and icon files that are culturally specific

  • Actions and file types

  • User Interface Definition (UID) files

  • Date and time formats

  • Numeric formats

  • Monetary formats

  • Collation order

  • Regular expression handling specific to the locale

  • Format for informative and diagnostic messages and interactive responses

The Solaris environment separates language and culture-dependent information from the application and saves the information outside the application. This method eliminates the need to translate, rewrite, or recompile the application for each market. The only requirement to enter a new market is to localize the external information to the local language and customs.

Locale Categories

The locale categories are as follows:

LC_CTYPE

Controls the behavior of character handling functions.

LC_TIME

Specifies date and time formats, including month names, days of the week, and common full and abbreviated representations.

LC_MONETARY

Specifies monetary formats, including the currency symbol for the locale, thousands separator, sign position, the number of fractional digits, and so forth.

LC_NUMERIC

Specifies the decimal delimiter (or radix character), the thousands separator, and the grouping.

LC_COLLATE

Specifies a collation order and regular expression definition for the locale.

LC_MESSAGES

Specifies the language in which the localized messages are written, and affirmative and negative responses of the locale (yes and no strings and expressions).

LO_LTYPE

Specifies the layout engine that provides information about language rendering. Language rendering (or text rendering) depends on the shape and direction attributes of a script.

阅读(1072) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~