Go to main content

International Language Environments Guide for Oracle® Solaris 11.4

Exit Print View

Updated: November 2020

Creating a New Locale Based on a System Locale

To customize and thus create a new locale from existing locales, you need to prepare at least three locale definition source files:

  • localedef source file – Contains necessary definitions for the locale.

  • charmap source file – Contains mappings between code point values and human-readable symbolic names. The symbolic names are used in the localedef source file. The charmap source file also contains other definitions, such as the codeset name of the locale, the maximum number of bytes that can be represented in a locale code point, and so on.

  • extension source file – Contains mappings of standard interfaces such as strcoll(3C) and fgetwc(3C) to internal locale methods, and other information needed for the proper operation of the locale.

The locales provided by the system have their respective locale definition data files available in source/locale/localedef package. These can be useful when only a slight change in existing system locale is required.

How to Create a Custom Locale

  1. Install the necessary package by typing the following command:
    $ pkg install source/locale/localedef
  2. Prepare the workspace by using the following commands:
    # mkdir mynewlocale
    # cd mynewlocale 
    # cp /usr/lib/localedef/src/charmaps/UTF-8.charmap \
    /usr/lib/localedef/src/extensions/UTF-8.x \
  3. Make changes to the localedef, charmap, or extension source files as necessary.
  4. Build the custom locale.
    # localedef -f UTF-8.charmap -x UTF-8.x -i fr_FR.UTF-8.src fr_FR.UTF-8@custom
  5. Install the custom locale.
    # mkdir /usr/lib/locale/fr_FR.UTF-8\@custom 
    # cp fr_FR.UTF-8\@custom /usr/lib/locale/fr_FR.UTF-8\@custom/
  6. Type the following command to start using the locale:
    $ export LANG=fr_FR.UTF-8@custom