1 package I18N::Langinfo;
11 our @ISA = qw(Exporter);
13 our @EXPORT = qw(langinfo);
75 our $VERSION = '0.11';
84 I18N::Langinfo - query locale information
92 The langinfo() function queries various locale information that can be
93 used to localize output and user interfaces. The langinfo() requires
94 one numeric argument that identifies the locale constant to query:
95 if no argument is supplied, C<$_> is used. The numeric constants
96 appropriate to be used as arguments are exportable from I18N::Langinfo.
98 The following example will import the langinfo() function itself and
99 three constants to be used as arguments to langinfo(): a constant for
100 the abbreviated first day of the week (the numbering starts from
101 Sunday = 1) and two more constants for the affirmative and negative
102 answers for a yes/no question in the current locale.
104 use I18N::Langinfo qw(langinfo ABDAY_1 YESSTR NOSTR);
106 my ($abday_1, $yesstr, $nostr) =
107 map { langinfo($_) } (ABDAY_1, YESSTR, NOSTR);
109 print "$abday_1? [$yesstr/$nostr] ";
111 In other words, in the "C" (or English) locale the above will probably
112 print something like:
116 but under a French locale
120 The usually available constants are
122 ABDAY_1 ABDAY_2 ABDAY_3 ABDAY_4 ABDAY_5 ABDAY_6 ABDAY_7
123 ABMON_1 ABMON_2 ABMON_3 ABMON_4 ABMON_5 ABMON_6
124 ABMON_7 ABMON_8 ABMON_9 ABMON_10 ABMON_11 ABMON_12
125 DAY_1 DAY_2 DAY_3 DAY_4 DAY_5 DAY_6 DAY_7
126 MON_1 MON_2 MON_3 MON_4 MON_5 MON_6
127 MON_7 MON_8 MON_9 MON_10 MON_11 MON_12
129 for abbreviated and full length days of the week and months of the year,
133 for the date-time, date, and time formats used by the strftime() function
136 AM_STR PM_STR T_FMT_AMPM
138 for the locales for which it makes sense to have ante meridiem and post
139 meridiem time formats,
141 CODESET CRNCYSTR RADIXCHAR
143 for the character code set being used (such as "ISO8859-1", "cp850",
144 "koi8-r", "sjis", "utf8", etc.), for the currency string, for the
145 radix character used between the integer and the fractional part
146 of decimal numbers (yes, this is redundant with POSIX::localeconv())
148 YESSTR YESEXPR NOSTR NOEXPR
150 for the affirmative and negative responses and expressions, and
152 ERA ERA_D_FMT ERA_D_T_FMT ERA_T_FMT
154 for the Japanese Emperor eras (naturally only defined under Japanese locales).
156 See your L<langinfo(3)> for more information about the available
157 constants. (Often this means having to look directly at the
158 F<langinfo.h> C header file.)
160 Note that unfortunately none of the above constants are guaranteed
161 to be available on a particular platform. To be on the safe side
162 you can wrap the import in an eval like this:
165 require I18N::Langinfo;
166 I18N::Langinfo->import(qw(langinfo CODESET));
167 $codeset = langinfo(CODESET()); # note the ()
169 if (!$@) { ... failed ... }
173 By default only the C<langinfo()> function is exported.
177 L<perllocale>, L<POSIX/localeconv>, L<POSIX/setlocale>, L<nl_langinfo(3)>.
179 The langinfo() is just a wrapper for the C nl_langinfo() interface.
183 Jarkko Hietaniemi, E<lt>jhi@hut.fiE<gt>
185 =head1 COPYRIGHT AND LICENSE
187 Copyright 2001 by Jarkko Hietaniemi
189 This library is free software; you can redistribute it and/or modify
190 it under the same terms as Perl itself.