diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2007-11-08 16:33:20 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2007-11-08 16:33:20 +0000 |
commit | 2048db8902dad7b19e88ea351f456071ca6903cf (patch) | |
tree | 7c23930227d835b775079375bd7b505fb3eda413 /perl-install/lang.pm | |
parent | 54710bb802a25da8901931250652fb1dd85ee780 (diff) | |
download | drakx-2048db8902dad7b19e88ea351f456071ca6903cf.tar drakx-2048db8902dad7b19e88ea351f456071ca6903cf.tar.gz drakx-2048db8902dad7b19e88ea351f456071ca6903cf.tar.bz2 drakx-2048db8902dad7b19e88ea351f456071ca6903cf.tar.xz drakx-2048db8902dad7b19e88ea351f456071ca6903cf.zip |
- localedrake:
o fix handling variant together with charset (eg: uz.UTF-8@Latn) (#35090)
Diffstat (limited to 'perl-install/lang.pm')
-rw-r--r-- | perl-install/lang.pm | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/perl-install/lang.pm b/perl-install/lang.pm index eeb773355..c5f968bdd 100644 --- a/perl-install/lang.pm +++ b/perl-install/lang.pm @@ -461,25 +461,35 @@ our @locales = qw(aa_DJ aa_ER aa_ER@saaho aa_ET af_ZA am_ET an_ES ar_AE ar_BH ar sub standard_locale { my ($lang, $country, $prefer_lang) = @_; - if (member("${lang}_${country}", @locales)) { - "${lang}_${country}"; + my $lang_ = force_lang_country($lang, $country); + if (member($lang_, @locales)) { + $lang_; } elsif ($prefer_lang && member($lang, @locales)) { $lang; } else { - my $main_locale = locale_to_main_locale($lang); - if ($main_locale ne $lang) { - standard_locale($main_locale, $country, $prefer_lang); - } else { - ''; - } + ''; } } -sub fix_variant { - my ($lang) = @_; - #- uz@Cyrl_UZ -> uz_UZ@Cyrl - $lang =~ s/(.*)(\@\w+)(_.*)/$1$3$2/; - $lang; +sub force_lang_country { + my ($lang, $country) = @_; + my $h = analyse_locale_name($lang); + $h->{country} = $country; + analysed_to_lang($h); +} + +sub force_lang_charset { + my ($lang, $charset) = @_; + my $h = analyse_locale_name($lang); + $h->{charset} = $charset; + analysed_to_lang($h); +} + +sub analysed_to_lang { + my ($h) = @_; + $h->{main} . '_' . $h->{country} . + ($h->{charset} ? '.' . $h->{charset} : '') . + ($h->{variant} ? '@' . $h->{variant} : ''); } sub analyse_locale_name { @@ -495,12 +505,12 @@ sub locale_to_main_locale { sub getlocale_for_lang { my ($lang, $country, $o_utf8) = @_; - fix_variant((standard_locale($lang, $country, 'prefer_lang') || l2locale($lang)) . ($o_utf8 ? '.UTF-8' : '')); + force_lang_charset(standard_locale($lang, $country, 'prefer_lang') || l2locale($lang), $o_utf8 && 'UTF-8'); } sub getlocale_for_country { my ($lang, $country, $o_utf8) = @_; - fix_variant((standard_locale($lang, $country, '') || c2locale($country)) . ($o_utf8 ? '.UTF-8' : '')); + force_lang_charset(standard_locale($lang, $country, '') || c2locale($country), $o_utf8 && 'UTF-8'); } sub getLANGUAGE { |