Go to main content

man pages section 1: User Commands

Exit Print View

Updated: Wednesday, July 27, 2022



localedef - define locale environment


localedef [-c] [-f charmap] 
     [-i sourcefile] [-u code_set_name]
     [-x extensions_file] localename


The localedef utility converts source definitions for locale categories into a format usable by the functions and utilities whose operational behavior is determined by the setting of the locale environment variables; see environ(7).

The utility reads source definitions for one or more locale categories belonging to the same locale from the file named in the –i option (if specified) or from standard input.

Each category source definition is identified by the corresponding environment variable name and terminated by an END category-name statement. The following categories are supported.


Defines character classification and case conversion.


Defines collation rules.


Defines the format and symbols used in formatting of monetary information.


Defines the decimal delimiter, grouping and grouping symbol for non-monetary numeric editing.


Defines the format and content of date and time information.


Defines the format and values of affirmative and negative responses.


The following options are supported:


Creates permanent output even if warning messages have been issued.

–f charmap

Specifies the pathname of a file containing a mapping of character symbols and collating element symbols to actual character encodings. This option must be specified if symbolic names (other than collating symbols defined in a collating-symbol keyword) are used. If the –f option is not present, the default character mapping will be used.

–i sourcefile

The path name of a file containing the source definitions. If this option is not present, source definitions will be read from standard input.

–u code_set_name

Specifies the name of a codeset used as the target mapping of character symbols and collating element symbols whose encoding values are defined in terms of the ISO/IEC 10646-1: 2000 standard position constant values. See NOTES.

–x extensions_file

Specifies the name of an extension file where various localedef options are listed. See locale(7).


The following operand is supported:


Identifies the locale. If the name contains one or more slash characters, localename will be interpreted as a path name where the created locale definitions will be stored. This capability may be restricted to users with appropriate privileges. (As a consequence of specifying one localename, although several categories can be processed in one execution, only categories belonging to the same locale can be processed.)


localedef generates a locale data file named localename at the current directory for both 32-bit and 64-bit environments.

The locale data file must be moved to /usr/lib/locale/localename/localename to be recognized and supported as a locale.

Environment Variables

See environ(7) for definitions of the following environment variables that affect the execution of localedef: LANG, LC_ALL, LC_COLLATE, LC_CTYPE, LC_MESSAGES, and NLSPATH.

Exit Status

The following exit values are returned:


No errors occurred and the locales were successfully created.


Warnings occurred and the locales were successfully created.


The locale specification exceeded implementation limits or the coded character set or sets used were not supported by the implementation, and no locale was created.


The capability to create new locales is not supported by the implementation.


Warnings or errors occurred and no output was created.

If an error is detected, no permanent output will be created.



Describes what a generic EUC locale uses as the extensions file in the system. This file is used by default.


Describes a generic single-byte file used as the extensions file in the system.


The locale data file for both 32-bit and 64-bit environments.


See attributes(7) for descriptions of the following attributes:

Interface Stability

See Also

locale(1), iconv_open(3C), nl_langinfo(3C), strftime(3C), attributes(7), charmap(7), environ(7), extensions(7), locale(7), standards(7)


If warnings occur, permanent output will be created if the –c option was specified. The following conditions will cause warning messages to be issued:

  • If a symbolic name not found in the charmap file is used for the descriptions of the LC_CTYPE or LC_COLLATE categories (for other categories, this will be an error conditions).

  • If optional keywords not supported by the implementation are present in the source.

  • Use of no longer supported options and option arguments such as –C, –L, –m, and –W.


When the –u option is used, the code_set_name option-argument is interpreted as a name of a codeset to which the ISO/IEC 10646-1: 2000 standard position constant values are converted. Both the ISO/IEC 10646-1: 2000 standard position constant values and other formats (decimal, hexadecimal, or octal) are valid as encoding values within the charmap file. The codeset can be any codeset that is supported by the iconv_open(3C) function on the system.

When conflicts occur between the charmap specification of code_set_name, mb_cur_max, or mb_cur_min and the corresponding value for the codeset represented by the –u option-argument code_set_name , the localedef utility fails as an error.

When conflicts occur between the charmap encoding values specified for symbolic names of characters of the portable character set and the character encoding values defined by the US-ASCII, the result is unspecified.

If a non-printable character in the charmap has a width specified that is not -1, localedef generates a warning.

The options such as –C, –L, –m, and –W with their option arguments will still be accepted, but they are not used and not supported. Use of any of these will display a warning message specifying that they are no longer needed.