1 package Packages::I18N::Locale;
9 our @ISA = qw( Exporter );
10 # the reason we have both _g and _ is simply that there
11 # seem to be some situations where Perl doesn't handle _
12 # correctly. If in doubt use _g
13 our @EXPORT = qw( get_locale get_charset _g N_ );
15 my %lang2loc = ( en => "en_US",
24 # this can probably be removed now that all locales are available in UTF-8
33 return "$lang2loc{default}.".get_charset() unless $lang;
35 if ( length($lang) == 2 ) {
36 $locale = $lang2loc{$lang} || ( "${lang}_" . uc $lang );
37 } elsif ( $lang !~ /^[a-z][a-z]_[A-Z][A-Z]$/ ) {
38 warn "get_locale: couldn't determine locale\n";
41 $locale .= ".".get_charset($lang);
48 return $lang2charset{default} unless $lang;
49 return $lang2charset{$lang} || $lang2charset{default};
52 sub _g { return gettext( $_[0] ) }
53 sub N_ { return $_[0] }