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

SEE ALSO

97       perllocale, "localeconv" in POSIX, "setlocale" in POSIX, nl_lang‐
98       info(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.8.8                       2001-09-21               I18N::Langinfo(3pm)
Impressum