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 # most of them can probably changed to UTF-8 in Sarge
25 # as there are more available UTF-8 locales then
36 return "$lang2loc{default}.".get_charset() unless $lang;
38 if ( length($lang) == 2 ) {
39 $locale = $lang2loc{$lang} || ( "${lang}_" . uc $lang );
40 } elsif ( $lang !~ /^[a-z][a-z]_[A-Z][A-Z]$/ ) {
41 warn "get_locale: couldn't determine locale\n";
44 $locale .= ".".get_charset($lang);
51 return $lang2charset{default} unless $lang;
52 return $lang2charset{$lang} || $lang2charset{default};
55 sub _g { return gettext( $_[0] ) }
56 sub N_ { return $_[0] }