I18N::Langinfo#

📦 min

Query locale information - country, language, and cultural conventions from the current locale.

Exports langinfo() together with the item constants it takes: the character set name, the date and time formats, the day and month names, the numeric and currency separators, the era formats, the locale’s yes/no expressions, and glibc’s _NL_* extension items (postal address, identification, measurement, name, paper and telephone formats).

use I18N::Langinfo qw(langinfo CODESET DAY_1 MON_1 RADIXCHAR YESEXPR);
use POSIX qw(setlocale LC_ALL);

setlocale(LC_ALL, "C");
printf "%s | %s %s | radix '%s' | yes %s\n",
    langinfo(CODESET), langinfo(DAY_1), langinfo(MON_1), langinfo(RADIXCHAR), langinfo(YESEXPR);
# ANSI_X3.4-1968 | Sunday January | radix '.' | yes ^[yY]

The answers are the C library’s for the locale in effect, so they change with setlocale. This is a native implementation of the XS half of I18N::Langinfo 0.24; its .pm is used unchanged, and use I18N::Langinfo exports langinfo alone - the item constants are imported by name.

Differences from upstream#

None.

Functions#

Other Functions#

langinfo#

langinfo($item) - the string the current locale gives for one nl_langinfo item code.