1I18N::Langinfo(3pm)    Perl Programmers Reference Guide    I18N::Langinfo(3pm)
2
3
4

NAME

6       I18N::Langinfo - query locale information
7

SYNOPSIS

9         use I18N::Langinfo;
10

DESCRIPTION

12       The langinfo() function queries various locale information that can be
13       used to localize output and user interfaces.  The langinfo() requires
14       one numeric argument that identifies the locale constant to query: if
15       no argument is supplied, $_ is used.  The numeric constants appropriate
16       to be used as arguments are exportable from I18N::Langinfo.
17
18       The following example will import the langinfo() function itself and
19       three constants to be used as arguments to langinfo(): a constant for
20       the abbreviated first day of the week (the numbering starts from Sunday
21       = 1) and two more constants for the affirmative and negative answers
22       for a yes/no question in the current locale.
23
24           use I18N::Langinfo qw(langinfo ABDAY_1 YESSTR NOSTR);
25
26           my ($abday_1, $yesstr, $nostr) =
27               map { langinfo($_) } (ABDAY_1, YESSTR, NOSTR);
28
29           print "$abday_1? [$yesstr/$nostr] ";
30
31       In other words, in the "C" (or English) locale the above will probably
32       print something like:
33
34           Sun? [yes/no]
35
36       but under a French locale
37
38           dim? [oui/non]
39
40       The usually available constants are
41
42           ABDAY_1 ABDAY_2 ABDAY_3 ABDAY_4 ABDAY_5 ABDAY_6 ABDAY_7
43           ABMON_1 ABMON_2 ABMON_3 ABMON_4 ABMON_5 ABMON_6
44           ABMON_7 ABMON_8 ABMON_9 ABMON_10 ABMON_11 ABMON_12
45           DAY_1 DAY_2 DAY_3 DAY_4 DAY_5 DAY_6 DAY_7
46           MON_1 MON_2 MON_3 MON_4 MON_5 MON_6
47           MON_7 MON_8 MON_9 MON_10 MON_11 MON_12
48
49       for abbreviated and full length days of the week and months of the
50       year,
51
52           D_T_FMT D_FMT T_FMT
53
54       for the date-time, date, and time formats used by the strftime()
55       function (see POSIX)
56
57           AM_STR PM_STR T_FMT_AMPM
58
59       for the locales for which it makes sense to have ante meridiem and post
60       meridiem time formats,
61
62           CODESET CRNCYSTR RADIXCHAR
63
64       for the character code set being used (such as "ISO8859-1", "cp850",
65       "koi8-r", "sjis", "utf8", etc.), for the currency string, for the radix
66       character used between the integer and the fractional part of decimal
67       numbers (yes, this is redundant with POSIX::localeconv())
68
69           YESSTR YESEXPR NOSTR NOEXPR
70
71       for the affirmative and negative responses and expressions, and
72
73           ERA ERA_D_FMT ERA_D_T_FMT ERA_T_FMT
74
75       for the Japanese Emperor eras (naturally only defined under Japanese
76       locales).
77
78       See your langinfo(3) for more information about the available
79       constants.  (Often this means having to look directly at the langinfo.h
80       C header file.)
81
82       Note that unfortunately none of the above constants are guaranteed to
83       be available on a particular platform.  To be on the safe side you can
84       wrap the import in an eval like this:
85
86           eval {
87               require I18N::Langinfo;
88               I18N::Langinfo->import(qw(langinfo CODESET));
89               $codeset = langinfo(CODESET()); # note the ()
90           };
91           if ($@) { ... failed ... }
92
93   EXPORT
94       By default only the "langinfo()" function is exported.
95

SEE ALSO

97       perllocale, "localeconv" in POSIX, "setlocale" in POSIX,
98       nl_langinfo(3).
99
100       The langinfo() is just a wrapper for the C nl_langinfo() interface.
101

AUTHOR

103       Jarkko Hietaniemi, <jhi@hut.fi>
104
106       Copyright 2001 by Jarkko Hietaniemi
107
108       This library is free software; you can redistribute it and/or modify it
109       under the same terms as Perl itself.
110
111
112
113perl v5.26.3                      2018-03-01               I18N::Langinfo(3pm)
Impressum