International Language Environments Guide for Oracle® Solaris 11.2

Exit Print View

Updated: July 2014
 
 

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 packages by typing the following command:
    $ sudo pkg install system/header source/locale/localedef
  2. Ensure you have the Oracle Solaris Studio C compiler in your PATH:
    $ export PATH=<oracle-studio-path>/bin:$PATH
  3. Prepare the workspace by using the following commands:
    $ mkdir mynewlocale
    $ cd mynewlocale 
    $ mkdir amd64 
    $ cp /usr/lib/locale/common/methods_unicode.so.3 . 
    $ cp /usr/lib/locale/common/amd64/methods_unicode.so.3 amd64/ 
    $ cp /usr/lib/localedef/src/charmaps/UTF-8.charmap \
    /usr/lib/localedef/src/extensions/UTF-8.x \
    /usr/lib/localedef/src/locales/fr_FR.UTF-8.src .
  4. Make changes to the localedef, charmap, or extension source files as necessary.
  5. Build the 64-bit locale object.
    $ localedef -m lp64 -f UTF-8.charmap -x UTF-8.x -i fr_FR.UTF-8.src \
    -L "-R\\\$ORIGIN/../../common/amd64 -Bdirect -M /usr/lib/ld/map.pagealign \
    -M /usr/lib/ld/map.noexdata" fr_FR.UTF-8@custom
    $ mv fr_FR.UTF-8@custom.so.3 amd64/
  6. Build the 32-bit locale object.
    $ localedef -m ilp32 -f UTF-8.charmap -x UTF-8.x -i fr_FR.UTF-8.src \
    -L "-R\\\$ORIGIN/../common" fr_FR.UTF-8@custom
  7. Install the custom locale.
    $ sudo mkdir -p /usr/lib/locale/fr_FR.UTF-8\@custom/amd64 
    $ sudo cp fr_FR.UTF-8\@custom.so.3 /usr/lib/locale/fr_FR.UTF-8\@custom/ 
    $ sudo cp amd64/fr_FR.UTF-8\@custom.so.3 /usr/lib/locale/fr_FR.UTF-8\@custom/amd64/
  8. Type the following command to start using the locale:
    $ export LANG=fr_FR.UTF-8@custom