dmi_locale_setup

Synopsis

#include <opendmi/locale.h>

void dmi_locale_setup(void);

Description

The dmi_locale_setup function sets up the locale of a program from the environment in one call:

  • the LC_CTYPE and LC_MESSAGES categories of the C library are taken from the environment by setlocale(3), so that characters are classified and messages of the system are written in the language of the user;

  • the locale of the library is set by dmi_set_locale to the default locale of the environment, so that printable names are translated as well, and left in English when there is no translation.

Other categories, LC_NUMERIC in particular, are deliberately left in the C locale, so that the decimal point of formatted values does not depend on the environment, and machine-readable output is the same everywhere.

Programs which handle the locale themselves do not need the function, and call setlocale(3) and dmi_set_locale on their own.

In the kernel, which has no locale environment, only the locale of the library is set.

Thread safety

Like dmi_set_locale, the function is not thread-safe. It is meant to be called once, at the start of the program, before the library is used.

Return value

None. A locale which cannot be set leaves printable strings in English.

Errors

None.

See also