localedef - define locale environment


localedef [-c][-f charmap][-i sourcefile] name


The localedef utility converts source definitions for locale categories into a format usable by the functions and utilities whose operational behaviour is determined by the setting of the locale environment variables defined in the  Locale specification . It is implementation-dependent whether users have the capability to create new locales, in addition to those supplied by the implementation. Since the symbolic constant {POSIX2_LOCALEDEF} is defined on all POSIX-conformant systems, the system supports the creation of new locales.

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.

The name operand identifies the target locale. The utility supports the creation of public , or generally accessible locales, as well as private , or restricted-access locales. Implementations may restrict the capability to create or modify public locales to users with the appropriate privileges.

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. In addition, the input may contain source for implementation-dependent categories.

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:


-c (null)
Create permanent output even if warning messages have been issued.

-f charmap
Specify the pathname of a file containing a mapping of character symbols and collating element symbols to actual character encodings. The format of the charmap is described under the Character Set Description File specification. 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, an implementation-dependent character mapping will be used.

-i inputfile
The pathname of a file containing the source definitions. If this option is not present, source definitions will be read from standard input. The format of the inputfile is described in the  Locale Definitions specification.


The following operand is supported:

Identifies the locale. See the Locale specification for a description of the use of this name. If the name contains one or more slash characters, name will be interpreted as a pathname where the created locale definitions will be stored. If name does not contain any slash characters, the interpretation of the name is implementation-dependent and the locale will be public. This capability may be restricted to users with appropriate privileges. (As a consequence of specifying one name, although several categories can be processed in one execution, only categories belonging to the same locale can be processed.)


Unless the -i option is specified, the standard input must be a text file containing one or more locale category source definitions, as described in the Locale Definitions specification . When lines are continued using the escape character mechanism, there is no limit to the length of the accumulated continued line.


The character set mapping file specified as the charmap option-argument is described under the Character Set Description File specification . If a locale category source definition contains a copy statement, as defined in the Locale specification , and the copy statement names a valid, existing locale, then localedef will behave as if the source definition had contained a valid category source definition for the named locale.


The following environment variables affect the execution of localedef:

Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.

If set to a non-empty string value, override the values of all the other internationalisation variables.

(This variable has no affect on localedef; the POSIX locale will be used for this category.)

Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files). This variable has no affect on the processing of localedef input data; the POSIX locale is used for this purpose, regardless of the value of this variable.

Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.

Determine the location of message catalogues for the processing of LC_MESSAGES .




The utility will report all categories successfully processed, in an unspecified format.


Used only for diagnostic messages.


The format of the created output is unspecified. If the name operand does not contain a slash, the existence of an output file for the locale is unspecified.




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.

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

Other implementation-dependent conditions may also cause warnings.


The charmap definition is optional, and is contained outside the locale definition. This allows both completely self-defined source files, and generic sources (applicable to more than one codeset). To aid portability, all charmap definitions must use the same symbolic names for the portable character set. As explained in the Character Set Description File specification, it is implementation-dependent whether or not users or applications can provide additional character set description files. Therefore, the -f option might be operable only when an implementation-dependent charmap is named.






locale, Locale Definitions specification.