Native Language Support

From LQWiki
Jump to navigation Jump to search

Native Language Support, or more commonly NLS, is giving programs support for internationalization and localization. Before a program can benifit from NLS, it must support it. Glibc has facilities to do this, refer to its manual under Message Translation and Localization for more info. Most distributions contain NLS enabled programs.

Making Use of NLS

By convention, programs with NLS enabled should refer to the environment variables when deciding what locale to use. The default locale is C or POSIX, they are the same locale, with different names. The language in this locale is English. The environment variables expect the name of a locale to use, this is either a path name to the locale, or the name of the locale from the system wide locale repository. To list what locales are installed, the command locale -a will list currently installed, system wide locals in the repository.

The format of the locales is commonly language[_dialect][.encoding][@modifier]. The language is the abbreviation of the language, and likewise with the dialect, the character set is optional, and the modifier field is almost never used. The modifier is simply another version of the same locale, much like how a dialect is related to a language.

And now for a list of environment variables you can change:

  • LANG effects all of NLS unless another variable is set, which will override this.
  • LC_ALL effects all of NLS, and cant be overridden.
  • LC_COLLATE effects collating of text, such as shorting.
  • LC_CTYPE effects the identification of types of characters, such as text, and numbers.
  • LC_MESSAGES effects the handling of messages, such as simple user input, and output text.
  • LC_MONETARY effects money related number formating.
  • LC_NUMERIC effects number formating.
  • LC_TIME effects date and time formating.