diff options
author | Guillaume Cottenceau <gc@mandriva.com> | 2003-02-08 22:09:29 +0000 |
---|---|---|
committer | Guillaume Cottenceau <gc@mandriva.com> | 2003-02-08 22:09:29 +0000 |
commit | 7fa65d931c24bd00a7d9ec9b26adaf7ad80023b9 (patch) | |
tree | 71e2baa4516d151f4462c692502a3a7dff5ef4df | |
parent | dd9a661c53728a4ea265882a1029c9b323cd6d3c (diff) | |
download | drakx-backup-do-not-use-7fa65d931c24bd00a7d9ec9b26adaf7ad80023b9.tar drakx-backup-do-not-use-7fa65d931c24bd00a7d9ec9b26adaf7ad80023b9.tar.gz drakx-backup-do-not-use-7fa65d931c24bd00a7d9ec9b26adaf7ad80023b9.tar.bz2 drakx-backup-do-not-use-7fa65d931c24bd00a7d9ec9b26adaf7ad80023b9.tar.xz drakx-backup-do-not-use-7fa65d931c24bd00a7d9ec9b26adaf7ad80023b9.zip |
language/country selection change:
- first install step is selection of your language, in your language;
it uses images for that
- language->country is probed, the selection of the country is possible
if there was a problem, in the Summary step
- in the $o big structure, we now use $o->{locale} which contains
three keys: lang, country and utf8
- lang.pm has been cleaned and rewritten a bit
- keyboard probing now done only on language (because this step is
at the beginning of the install)
- timezone probing done on country, if use changes country before
timezone in the Summary, re-probe timezone accordingly
91 files changed, 630 insertions, 703 deletions
diff --git a/perl-install/Makefile b/perl-install/Makefile index e6620bbe6..d62ad5390 100644 --- a/perl-install/Makefile +++ b/perl-install/Makefile @@ -7,7 +7,7 @@ include Makefile.config POFILES = $(shell ls share/po/*.po) MOFILES = $(POFILES:%.po=%.mo) -DISTFILES = *.pm $(PMS_DIRS) Makefile Makefile.config apps.net_monitor ddcprobe drakxtools.spec pam.net_monitor serial_probe share/po share/diskdrake.rc $(STANDALONEPMS) standalone/icons pixmaps standalone/interactive_http rpcinfo-flushed.c standalone/service_harddrake.sh +DISTFILES = *.pm $(PMS_DIRS) Makefile Makefile.config apps.net_monitor ddcprobe drakxtools.spec pam.net_monitor serial_probe share/po share/diskdrake.rc $(STANDALONEPMS) standalone/icons pixmaps pixmaps/langs standalone/interactive_http rpcinfo-flushed.c standalone/service_harddrake.sh OTHERS = $(OTHERDIRS) $(OTHERFILES) OTHERDIRS = tools/ddcprobe tools/serial_probe OTHERFILES = tools/rpcinfo-flushed.c @@ -163,7 +163,7 @@ endif cd share ; cp -a consolefonts $(DEST)/usr/share -cd share ; cp -f *.png *.xpm $(DEST)/usr/share - -cd pixmaps ; cp -f *.png *.xpm $(DEST)/usr/share ; rm -f $(DEST)/usr/share/wiz_* + -cd pixmaps ; cp -af *.png *.xpm langs $(DEST)/usr/share ; rm -f $(DEST)/usr/share/wiz_* cd share ; cp -a themes $(DEST)/usr/share/gtk cd share ; cp compssUsers compssUsers.* rpmsrate $(ROOTDEST)/Mandrake/base diff --git a/perl-install/any.pm b/perl-install/any.pm index ebc8c5973..cdd24ffc6 100644 --- a/perl-install/any.pm +++ b/perl-install/any.pm @@ -604,9 +604,20 @@ sub autologin { sub selectLanguage { my ($in, $lang, $langs_) = @_; my $langs = $langs_ || {}; - my @langs = lang::list(exclude_non_necessary_utf8 => $::isInstall, - exclude_non_installed_langs => !$::isInstall, - ); + #- can't use images after install since the install theme is inverse video :/ + my $using_images = $in->isa('interactive::gtk') && $::isInstall; + + #- to create the default value, use the first location for that value :/ + $lang = first(lang::l2location($lang))."|$lang"; + + my %name2l = map { lang::l2name($_) => $_ } lang::list_langs(); + my $listval2val = sub { $_[0] =~ /\|(.*)/; $1 }; + + my @langs = map { my $l = $_; map { [ "$_|$l", $_, $l ] } lang::l2location($l) } lang::list_langs(exclude_non_installed => !$::isInstall); + #- since gtk version will use images (function image2f) we need to sort differently + my $sort_func = $using_images ? \&lang::l2transliterated : \&lang::l2name; + @langs = map { $_->[0] } sort { $a->[1] cmp $b->[1] || $sort_func->($a->[2]) cmp $sort_func->($b->[2]) } @langs; + $in->ask_from_( { messages => N("Please choose a language to use."), title => 'language choice', @@ -614,21 +625,54 @@ sub selectLanguage { advanced_messages => formatAlaTeX(N("Mandrake Linux can support multiple languages. Select the languages you would like to install. They will be available when your installation is complete and you restart your system.")), - callbacks => { - advanced => sub { $langs->{$lang} = 1 }, - }, + callbacks => { advanced => sub { $langs->{$listval2val->($lang)} = 1 } } }, [ { val => \$lang, separator => '|', - format => \&lang::lang2text, list => \@langs }, + if_($using_images, image2f => sub { $name2l{$_[0]} =~ /^[a-z]/ ? ('', "langs/lang-$name2l{$_[0]}") : $_[0] }), + format => sub { $_[0] =~ /(.*\|)(.*)/; $1.lang::l2name($2) }, + list => \@langs, sort => 0 }, if_($langs_, (map { - { val => \$langs->{$_->[0]}, type => 'bool', disabled => sub { $langs->{all} }, - text => $_->[1], advanced => 1, - } - } sort { $a->[1] cmp $b->[1] } map { [ $_, lang::lang2text($_) ] } lang::list()), - { val => \$langs->{all}, type => 'bool', text => N("All"), advanced => 1 }), + { val => \$langs->{$_->[0]}, type => 'bool', disabled => sub { $langs->{all} }, + text => $_->[1], advanced => 1, + image => "langs/lang-$_->[0]", + } + } sort { $a->[1] cmp $b->[1] } map { [ $_, $sort_func->($_) ] } lang::list_langs()), + { val => \$langs->{all}, type => 'bool', text => N("All"), advanced => 1 }, + if_($::isInstall, + { val => \$in->{locale}{utf8}, type => 'bool', text => N("Use Unicode by default"), advanced => 1 })) ]) or return; - $langs->{$lang} = 1; - $lang; + $langs->{$listval2val->($lang)} = 1; + + #- convert to the default locale for asked language + $listval2val->($lang); +} + +sub selectCountry { + my ($o, $locale) = @_; + + my $country = $locale->{country}; + my @countries = lang::list_countries(exclude_non_installed => !$::isInstall); + my @best = uniq map { if_((/^\Q$locale->{lang}/ || substr($_, 0, 2) eq substr($locale->{lang}, 0, 2)) + && /.._(..)/, $1) } @lang::locales; + @best == 1 and @best = (); + + my ($other, $ext_country); + member($country, @best) or ($ext_country, $country) = ($country, $ext_country); + $o->ask_from_( + { title => N("Country"), + messages => N("Please choose your country."), + advanced_messages => N("Here is the full list of available countries"), + advanced_label => N("More"), + advanced_state => $ext_country && scalar(@best), + callbacks => { changed => sub { $other = $_[0] == 1 } }, + }, + [ if_(@best, { val => \$country, type => 'list', format => \&lang::c2name, + list => \@best, sort => 1 }), + { val => \$ext_country, type => 'list', format => \&lang::c2name, + list => [ difference2(\@countries, \@best) ], advanced => @best } + ]) or return; + + $locale->{country} = $other || !@best ? $ext_country : $country; } sub write_passwd_user { diff --git a/perl-install/install2.pm b/perl-install/install2.pm index 286f05c4a..b2aea0ecc 100644 --- a/perl-install/install2.pm +++ b/perl-install/install2.pm @@ -39,7 +39,7 @@ $o = $::o = { #- packages => [ qw() ], partitioning => { clearall => 0, eraseBadPartitions => 0, auto_allocate => 0 }, #-, readonly => 0 }, authentication => { md5 => 1, shadow => 1 }, - lang => 'en_US', + locale => { lang => 'en_US' }, #- isUpgrade => 0, toRemove => [], toSave => [], @@ -366,8 +366,8 @@ sub main { my ($n, $v) = @_; my $f = ${{ oem => sub { $::oem = $v }, - lang => sub { $o->{lang} = $v }, - flang => sub { $o->{lang} = $v; push @auto, 'selectLanguage' }, + lang => sub { $o->{locale}{lang} = $v }, + flang => sub { $o->{locale}{lang} = $v; push @auto, 'selectLanguage' }, method => sub { $o->{method} = $v }, pcmcia => sub { $o->{pcmcia} = $v }, vga16 => sub { $o->{vga16} = $v }, @@ -539,7 +539,7 @@ sub main { #- needed very early for install_steps_gtk eval { $o->{mouse} = mouse::detect() } if !$o->{nomouseprobe} && !$o->{mouse} && !$::testing; - $o->{lang} = lang::set($o->{lang}) if $o->{lang} ne 'en_US'; #- mainly for defcfg + $o->{locale}{lang} = lang::set($o->{locale}{lang}) if $o->{locale}{lang} ne 'en_US'; #- mainly for defcfg start_i810fb(); diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index 478769d8e..27ee2e42f 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -285,7 +285,7 @@ sub preConfigureTimezone { #- can't be done in install cuz' timeconfig %post creates funny things add2hash($o->{timezone}, timezone::read()) if $o->{isUpgrade}; - $o->{timezone}{timezone} ||= timezone::bestTimezone(lang::lang2text($o->{lang})); + $o->{timezone}{timezone} ||= timezone::bestTimezone($o->{locale}{country}); my $utc = every { !isFat_or_NTFS($_) } @{$o->{fstab}}; my $ntp = timezone::ntp_server($o->{prefix}); @@ -358,7 +358,6 @@ sub setDefaultPackages { $o->{compssUsersChoice}{$_} = 1 foreach 'X', 'MONITORING', 'NETWORKING_REMOTE_ACCESS_SERVER'; } else { $o->{compssUsersChoice}{$_} = 1 foreach 'GNOME', 'KDE', 'CONFIG', 'X'; - $o->{lang} eq 'eu_ES' and $o->{compssUsersChoice}{KDE} = 0; $o->{compssUsersChoice}{$_} = 1 foreach map { @{$o->{compssUsers}{$_}{flags}} } 'Workstation|Office Workstation', 'Workstation|Internet station'; } @@ -393,15 +392,15 @@ sub setDefaultPackages { detect_devices::matching_desc('[nN]Vidia.*Quadro'); - foreach (map { substr($_, 0, 2) } lang::langs($o->{langs})) { + foreach (lang::langs($o->{locale}{langs})) { pkgs::packageByName($o->{packages}, "locales-$_") or next; push @{$o->{default_packages}}, "locales-$_"; $o->{compssUsersChoice}{qq(LOCALES"$_")} = 1; #- mainly for zh in case of zh_TW.Big5 } - foreach (lang::langsLANGUAGE($o->{langs})) { + foreach (lang::langsLANGUAGE($o->{locale}{langs})) { $o->{compssUsersChoice}{qq(LOCALES"$_")} = 1; } - $o->{compssUsersChoice}{'CHARSET"' . lang::lang2charset($o->{lang}) . '"'} = 1; + $o->{compssUsersChoice}{'CHARSET"' . lang::l2charset($o->{locale}{lang}) . '"'} = 1; } sub unselectMostPackages { @@ -1046,7 +1045,7 @@ sub copy_advertising { my $f; my $source_dir = "Mandrake/share/advertising"; - foreach ("." . $o->{lang}, "." . substr($o->{lang},0,2), '') { + foreach ("." . $o->{locale}{lang}, "." . substr($o->{locale}{lang},0,2), '') { $f = getFile("$source_dir$_/list") or next; $source_dir = "$source_dir$_"; } diff --git a/perl-install/install_gtk.pm b/perl-install/install_gtk.pm index 61812af12..cad0c0348 100644 --- a/perl-install/install_gtk.pm +++ b/perl-install/install_gtk.pm @@ -46,27 +46,22 @@ sub install_theme { load_rc($_) foreach "themes-$o->{theme}", "install", "themes"; my %pango_font_name; - if (my $pango_font = lang::lang2pango_font($o->{lang})) { + if (my $pango_font = lang::l2pango_font($o->{locale}{lang})) { $pango_font_name{10} = "font_name = \"$pango_font 10\""; $pango_font_name{12} = "font_name = \"$pango_font 12\""; } - if (my ($font, $font2) = lang::get_x_fontset($o->{lang}, $::rootwidth < 800 ? 10 : 12)) { - $font2 ||= $font; - Gtk2::Rc->parse_string(qq( + Gtk2::Rc->parse_string(qq( style "default-font" { - fontset = "$font,*" $pango_font_name{12} } style "small-font" { - fontset = "$font2,*" $pango_font_name{10} } widget "*" style "default-font" )); - } gtkset_background(@background1) unless $::live; #- || testing; create_logo_window($o); diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm index 724b5f99c..d5c7b5854 100644 --- a/perl-install/install_steps.pm +++ b/perl-install/install_steps.pm @@ -88,31 +88,36 @@ sub set_help { 1 } #------------------------------------------------------------------------------ sub selectLanguage { my ($o) = @_; - lang::set($o->{lang}, !$o->isa('interactive::gtk')); - $o->{langs} ||= { $o->{lang} => 1 }; + lang::set($o->{locale}{lang}, !$o->isa('interactive::gtk')); + $o->{locale}{langs} ||= { $o->{locale}{lang} => 1 }; - log::l("selectLanguage: pack_langs ", lang::pack_langs($o->{langs})); + if (!exists $o->{locale}{country}) { + lang::l2locale($o->{locale}{lang}) =~ /^.._(..)/; + $o->{locale}{country} = $1; + } + + log::l("selectLanguage: pack_langs ", lang::pack_langs($o->{locale}{langs})); #- for auto_install compatibility with old $o->{keyboard} containing directly $o->{keyboard}{KEYBOARD} $o->{keyboard} = { KEYBOARD => $o->{keyboard} } if $o->{keyboard} && !ref($o->{keyboard}); if (!$o->{keyboard} || $o->{keyboard}{unsafe}) { - $o->{keyboard} = keyboard::from_usb() || keyboard::lang2keyboard($o->{lang}); + $o->{keyboard} = keyboard::from_usb() || keyboard::lang2keyboard($o->{locale}{lang}); $o->{keyboard}{unsafe} = 1; keyboard::setup($o->{keyboard}) if !$::live; } addToBeDone { - lang::write_langs($o->{prefix}, $o->{langs}); + lang::write_langs($o->{prefix}, $o->{locale}{langs}); } 'formatPartitions' unless $::g_auto_install; addToBeDone { - lang::write($o->{prefix}, $o->{lang}); + lang::write($o->{prefix}, $o->{locale}); } 'installPackages' unless $::g_auto_install; } #------------------------------------------------------------------------------ sub selectKeyboard { my ($o) = @_; - $o->{keyboard}{KBCHARSET} = lang::lang2charset($o->{lang}); + $o->{keyboard}{KBCHARSET} = lang::l2charset($o->{locale}{lang}); keyboard::setup($o->{keyboard}); addToBeDone { @@ -165,7 +170,7 @@ sub doPartitionDisksAfter { } fs::set_removable_mntpoints($o->{all_hds}); - fs::set_all_default_options($o->{all_hds}, $o->{useSupermount}, $o->{security}, lang::fs_options($o->{lang})) + fs::set_all_default_options($o->{all_hds}, $o->{useSupermount}, $o->{security}, lang::fs_options($o->{locale})) if !$o->{isUpgrade}; $o->{fstab} = [ fsedit::get_all_fstab($o->{all_hds}) ]; @@ -454,14 +459,14 @@ EOF $o->install_urpmi; - if ($o->{lang} =~ /^(zh_TW|th|vi|be|bg)/) { + if ($o->{locale}{lang} =~ /^(zh_TW|th|vi|be|bg)/) { #- skip since we don't have the right font (it badly fails at least for zh_TW) - } elsif (my $LANG = lang::lang2LANG($o->{lang})) { - my $kde_charset = lang::charset2kde_charset(lang::lang2charset($o->{lang})); + } else { + my $kde_charset = lang::charset2kde_charset(lang::l2charset($o->{locale}{lang})); my $welcome = c::to_utf8(N("Welcome to %s", '%n')); substInFile { s/^(GreetString)=.*/$1=$welcome/; - s/^(Language)=.*/$1=$LANG/; + s/^(Language)=.*/$1=$o->{locale}{lang}/; if (!member($kde_charset, 'iso8859-1', 'iso8859-15')) { #- don't keep the default for those s/^(StdFont)=.*/$1=*,12,5,$kde_charset,50,0/; diff --git a/perl-install/install_steps_auto_install.pm b/perl-install/install_steps_auto_install.pm index 79277b846..bc2a07fe6 100644 --- a/perl-install/install_steps_auto_install.pm +++ b/perl-install/install_steps_auto_install.pm @@ -107,7 +107,7 @@ sub errorInStep { sub selectLanguage { my ($o) = @_; $o->install_steps::selectLanguage; - lang::load_console_font($o->{lang}); + lang::load_console_font($o->{locale}); } sub installPackages { diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm index b1e9876fe..9df720bf9 100644 --- a/perl-install/install_steps_interactive.pm +++ b/perl-install/install_steps_interactive.pm @@ -54,7 +54,7 @@ sub charsetChanged {} sub selectLanguage { my ($o) = @_; - $o->{lang} = any::selectLanguage($o, $o->{lang}, $o->{langs} ||= {}); + $o->{locale}{lang} = any::selectLanguage($o, $o->{locale}{lang}, $o->{locale}{langs} ||= {}); install_steps::selectLanguage($o); $o->charsetChanged; @@ -68,7 +68,7 @@ that it is listed means there is some support for it anyway. That is, once GNU/Linux will be installed, you will be able to at least read and write in that language; and possibly more (various fonts, spell checkers, various programs translated etc. that -varies from language to language).")) if $o->{lang} !~ /^en/ && !lang::load_mo(); +varies from language to language).")) if $o->{locale}{lang} !~ /^en/ && !lang::load_mo(); } else { #- no need to have this in po since it is never translated $o->ask_warn('', "The characters of your language can't be displayed in console, @@ -93,9 +93,9 @@ sub selectKeyboard { my ($o, $clicked) = @_; my $from_usb = keyboard::from_usb(); - my $l = keyboard::lang2keyboards(lang::langs($o->{langs})); + my $l = keyboard::lang2keyboards(lang::langs($o->{locale}{langs})); - if ($::expert || $clicked || !($from_usb || @$l && $l->[0][1] >= 90) || listlength(lang::langs($o->{langs})) > 1) { + if ($::expert || $clicked || !($from_usb || @$l && $l->[0][1] >= 90) || listlength(lang::langs($o->{locale}{langs})) > 1) { add2hash($o->{keyboard}, $from_usb); my @best = uniq($from_usb ? $from_usb->{KEYBOARD} : (), (map { $_->[0] } @$l), 'us_intl'); @@ -802,6 +802,7 @@ sub configureTimezone { $o->{timezone}{ntp} = ''; } install_steps::configureTimezone($o); + 1; } #------------------------------------------------------------------------------ @@ -825,6 +826,23 @@ sub summary { my $format_mouse = sub { $mouse_name = translate($o->{mouse}{type}) . ' ' . translate($o->{mouse}{name}) }; &$format_mouse; + my $timezone_manually_set; + my $timezone_name = $o->{timezone}{timezone}; #- I want to update it from the country callback + + my $country_name; + my $format_country = sub { $country_name = lang::c2name($o->{locale}{country}) }; + &$format_country; + my $change_country = sub { + any::selectCountry($o, $o->{locale}) or return; + lang::write($o->{prefix}, $o->{locale}); + &$format_country; + if (!$timezone_manually_set) { + delete $o->{timezone}; + install_any::preConfigureTimezone($o); #- now we can precise the timezone thanks to the country + $timezone_name = $o->{timezone}{timezone}; + } + }; + #- format printer description in a better way my $format_printers = sub { my $printer = $o->{printer}; @@ -861,13 +879,14 @@ sub summary { }, [ { label => N("Mouse"), val => \$mouse_name, clicked => sub { $o->selectMouse(1); mouse::write($o, $o->{mouse}); &$format_mouse } }, { label => N("Keyboard"), val => \$o->{keyboard}, clicked => sub { $o->selectKeyboard(1) }, format => sub { translate(keyboard::keyboard2text($_[0])) } }, -{ label => N("Timezone"), val => \$o->{timezone}{timezone}, clicked => sub { $o->configureTimezone(1) } }, +{ label => N("Country"), val => \$country_name, clicked => sub { $change_country->() } }, +{ label => N("Timezone"), val => \$timezone_name, clicked => sub { my $ok = $o->configureTimezone(1); $timezone_manually_set ||= $ok; $timezone_name = $o->{timezone}{timezone} } }, { label => N("Printer"), val => \$o->{printer}, clicked => sub { $o->configurePrinter(1) }, format => $format_printers }, { label => N("Bootloader"), val => \$o->{bootloader}, clicked => sub { any::setupBootloader($o, $o->{bootloader}, $o->{all_hds}, $o->{fstab}, $o->{security}) }, format => sub { "$o->{bootloader}{method} on $o->{bootloader}{boot}" } }, { label => N("Graphical interface"), val => \$o->{raw_X}, clicked => sub { configureX($o, 'expert') }, format => sub { $o->{raw_X} ? Xconfig::various::to_string($o->{raw_X}) : N("not configured") } }, { label => N("Network"), val => \$o->{netcnx}{type}, format => sub { $_[0] || N("not configured") }, clicked => sub { require network::netconnect; - network::netconnect::main($o->{prefix}, $o->{netcnx} ||= {}, $o->{netc}, $o->{mouse}, $o, $o->{intf}, 0, $o->{lang} eq "fr_FR" && $o->{keyboard}{KEYBOARD} eq "fr", 1); + network::netconnect::main($o->{prefix}, $o->{netcnx} ||= {}, $o->{netc}, $o->{mouse}, $o, $o->{intf}, 0, 0, 1); } }, (map { my $device = $_; @@ -917,9 +936,7 @@ sub configurePrinter { my $printer = $o->{printer} ||= {}; eval { add2hash($printer, printer::main::getinfo($o->{prefix})) }; - $printer->{PAPERSIZE} = ($o->{lang} =~ /^en_US/ || - $o->{lang} =~ /^en_CA/ || - $o->{lang} =~ /^fr_CA/) ? 'Letter' : 'A4'; + $printer->{PAPERSIZE} = ($o->{locale}{lang} eq 'en_US' || $o->{locale}{country} eq 'CA') ? 'Letter' : 'A4'; printer::printerdrake::main($printer, $o, $ask_multiple_printer, sub { install_interactive::upNetwork($o, 'pppAvoided') }); } diff --git a/perl-install/install_steps_newt.pm b/perl-install/install_steps_newt.pm index 0b70e2039..e3d10243e 100644 --- a/perl-install/install_steps_newt.pm +++ b/perl-install/install_steps_newt.pm @@ -52,7 +52,7 @@ sub exitInstall { sub selectLanguage { my ($o) = @_; $o->SUPER::selectLanguage; - lang::load_console_font($o->{lang}); + lang::load_console_font($o->{locale}); } diff --git a/perl-install/install_steps_stdio.pm b/perl-install/install_steps_stdio.pm index a2cfdd0f5..66b104147 100644 --- a/perl-install/install_steps_stdio.pm +++ b/perl-install/install_steps_stdio.pm @@ -34,7 +34,7 @@ sub leavingStep { sub selectLanguage { my ($o, $first_time) = @_; $o->SUPER::selectLanguage($first_time); - lang::load_console_font($o->{lang}); + lang::load_console_font($o->{locale}); } 1; diff --git a/perl-install/keyboard.pm b/perl-install/keyboard.pm index af99cde76..d4b0632b9 100644 --- a/perl-install/keyboard.pm +++ b/perl-install/keyboard.pm @@ -34,37 +34,18 @@ my %lang2keyboard = 'cs' => 'cz_qwerty:70 cz:50', 'cy' => 'uk:90', 'da' => 'dk:90', - 'de' => 'de_nodeadkeys:70 de:50', -'de_AT' => 'de_nodeadkeys:70 de:50', -'de_BE' => 'be:70 de_nodeadkeys:60 de:50', -'de_CH' => 'ch_de:70 ch_fr:25 de_nodeadkeys:20 de:15', -'de_DE' => 'de_nodeadkeys:70 de:50', -'de_LU' => 'de_nodeadkeys:70 de:50 fr:40 be:35', + 'de' => 'de_nodeadkeys:70 de:50 be:50 ch_de:50', 'el' => 'gr:90', 'en' => 'us:90 us_intl:50', -'en_US' => 'us:90 us_intl:50', -'en_AU' => 'uk:70 us:60 us_intl:50', -'en_CA' => 'qc:60 us:50 uk:40 us_intl:30', -'en_GB' => 'uk:89 us:60 us_intl:50', -'en_IE' => 'uk:89 us:60 us_intl:50', -'en_NZ' => 'uk:70 us:60 us_intl:50', -'en_ZA' => 'us:80 uk:50 us_intl:40', +'en_US' => 'us:89 us_intl:50 qc:50 uk:50', +'en_GB' => 'uk:89 us:60 us_intl:50 us:50', 'eo' => 'us_intl:89 dvorak:20', 'es' => 'es:85 la:80 us_intl:50', -'es@tr' => 'es:85 la:80 us_intl:50', -'es_AR' => 'la:80 us_intl:50 es:20', -'es_ES' => 'es:90', -'es_MX' => 'la:80 us_intl:50 es:20', 'et' => 'ee:90', 'eu' => 'es:89 fr:15', 'fa' => 'ir:90', 'fi' => 'fi:90', - 'fr' => 'fr:90', -'fr_BE' => 'be:85 fr:5', -'fr_CA' => 'qc:85 fr:5', -'fr_CH' => 'ch_fr:70 ch_de:15 fr:10', -'fr_FR' => 'fr:90', -'fr_LU' => 'fr:70 de_nodeadkeys:50 de:40 be:35', + 'fr' => 'fr:89 qc:85 be:85 ch_fr:70', 'ga' => 'uk:90', 'gd' => 'uk:90', 'gl' => 'es:90', @@ -78,9 +59,7 @@ my %lang2keyboard = 'id' => 'us:90 us_intl:20', 'is' => 'is:90', 'iu' => 'iu:90', - 'it' => 'it:90', -'it_CH' => 'ch_fr:80 ch_de:60 it:50', -'it_IT' => 'it:90', + 'it' => 'it:89 ch_fr:50 ch_de:50', 'ja' => 'jp:80 us:50 us_intl:20', 'ka' => 'ge_la:80 ge_ru:50', 'kl' => 'dk:80 us_intl:30', @@ -98,8 +77,7 @@ my %lang2keyboard = 'mt' => 'mt:55 mt_us:35 us_intl:10', 'my' => 'mm:90', 'nb' => 'no:85 dvorak_no:10', -'nl_BE' => 'be:80 nl:10 us_intl:5', -'nl_NL' => 'us_intl:80 nl:15 us:10 uk:5', + 'nl' => 'us_intl:80: be:70 nl:10 us:5', 'nn' => 'no:85 dvorak_no:10', 'no' => 'no:85 dvorak_no:10', 'oc' => 'fr:90', @@ -108,21 +86,15 @@ my %lang2keyboard = 'pl' => 'pl:80 pl2:60', 'pp' => 'br:80 la:20 pt:10 us_intl:30', 'pt_BR' => 'br:80 la:20 pt:10 us_intl:30', -'pt_PT' => 'pt:80', + 'pt' => 'pt:80', 'ro' => 'ro2:80 ro:40 us_intl:10', - 'ru' => 'ru:85 ru_yawerty:80', -'ru_RU' => 'ru:85 ru_yawerty:80', -'ru_UA' => 'ua:50 ru:40 ru_yawerty:30', + 'ru' => 'ru:85 ru_yawerty:80 ua:50', 'sk' => 'sk_qwerty:80 sk:70', 'sl' => 'si:80 hr:50', 'sp' => 'sr:80', -'sp_YU' => 'sr:80', 'sq' => 'al:80', 'sr' => 'yu:80', -'sr_YU' => 'yu:80', - 'sv' => 'se:85 fi:30 dvorak_se:10', -'sv_FI' => 'fi:85 sv:20', -'sv_SE' => 'se:85 fi:20', + 'sv' => 'se:85 fi:30 dvorak_se:10 sv:10', 'ta' => 'tscii:80 tml:20', 'tg' => 'tj:80 ru_yawerty:40', 'th' => 'th:90', @@ -133,7 +105,6 @@ my %lang2keyboard = 'vi' => 'vn:80 us:60 us_intl:50', 'wa' => 'be:85 fr:5', 'zh_CN' => 'us:60', -'zh_HK' => 'us:60', 'zh_TW' => 'us:60', ); @@ -371,6 +342,7 @@ sub lang2keyboards { } sub lang2keyboard { my ($l) = @_; + my $kb = lang2keyboards($l)->[0][0]; { KEYBOARD => $keyboards{$kb} ? $kb : 'us' }; #- handle incorrect keyboard mapping to us. } @@ -525,10 +497,10 @@ sub check { $not_ok = 1; }; - if (my @l = grep { is_empty_array_ref(lang2keyboards($_)) } lang::list()) { + if (my @l = grep { is_empty_array_ref(lang2keyboards($_)) } lang::list_langs()) { $warn->("no keyboard for langs " . join(" ", @l)); } - foreach my $lang (lang::list()) { + foreach my $lang (lang::list_langs()) { my $l = lang2keyboards($lang); foreach (@$l) { 0 <= $_->[1] && $_->[1] <= 100 or $err->("invalid value $_->[1] in $lang2keyboard{$lang} for $lang in \%lang2keyboard keyboard.pm"); diff --git a/perl-install/lang.pm b/perl-install/lang.pm index b5dcacd8e..9520d862a 100644 --- a/perl-install/lang.pm +++ b/perl-install/lang.pm @@ -2,172 +2,225 @@ package lang; # $Id$ use diagnostics; use strict; - -#-###################################################################################### -#- misc imports -#-###################################################################################### use common; use log; -#-###################################################################################### -#- Globals -#-###################################################################################### -#- key (to be used in $LC_ALL), [0] = english name, [1] = charset encoding, -#- [2] = value for $LANG used by DrakX, [3] = value for LANGUAGE (a list of -#- possible languages, carefully choosen), [4] = use utf8 or not (boolean) -#- -#- when adding a new language here, also add a line in keyboards list - -#- -#- NOTE: we cheat for a lot of locales (in particular UTF-8, in DrakX they are -#- the 8bit ones); it's easier like that now. Of course, on the installed -#- system a real UTF-8 locale will be used -#- - -my %languages = my @languages = ( -'en_US' => [ 'English|United States', 'C', 'en', 'en_US:en' ], -'en_AU' => [ 'English|Australia', 'iso-8859-15', 'en', 'en_CA:en_GB:en' ], -'en_CA' => [ 'English|Canada', 'iso-8859-15', 'en', 'en_CA:en_GB:en' ], -'en_GB' => [ 'English|United Kingdom', 'iso-8859-15', 'en', 'en_GB:en' ], -'en_IE' => [ 'English|Ireland', 'iso-8859-15', 'en', 'en_IE:en_GB:en' ], -'en_NZ' => [ 'English|New Zealand', 'iso-8859-15', 'en', 'en_CA:en_GB:en' ], -'en_ZA' => [ 'English|South Africa', 'iso-8859-15', 'en', 'en_ZA:en_GB:en' ], -'en_US.UTF-8' => [ 'English|UTF-8', 'iso-8859-15', 'en', 'en_US:en', 'UTF-8', ], -'af_ZA' => [ 'Afrikaans', 'iso-8859-1', 'af', 'af:en_ZA:en_GB' ], -'am_ET.UTF-8' => [ 'Amharic', 'utf_am', 'am', 'am', 'UTF-8' ], -'ar_EG.UTF-8' => [ 'Arabic', 'iso-8859-6', 'ar', 'ar', 'UTF-8' ], -'az_AZ.UTF-8' => [ 'Azeri (Latin)', 'iso-8859-9e', 'az', 'az:tr', 'UTF-8' ], -'be_BY' => [ 'Belarussian (CP1251)', 'cp1251', 'be', 'be:be_BY.CP1251:ru_RU.CP1251' ], -'be_BY.UTF-8' => [ 'Belarussian (UTF-8)', 'cp1251', 'be', 'be:be_BY.CP1251:ru_RU.CP1251', 'UTF-8' ], -#- provide aliases for some not very standard names used in po files... -'bg_BG' => [ 'Bulgarian (CP1251)', 'cp1251', 'bg', 'bg:bg.CP1251:bg_BG.CP1251:bg_BG' ], -'bg_BG.UTF-8' => [ 'Bulgarian (UTF-8)', 'cp1251', 'bg', 'bg:bg.CP1251:bg_BG.CP1251:bg_BG', 'UTF-8' ], -'br_FR' => [ 'Brezhoneg', 'iso-8859-15', 'br', 'br:fr_FR:fr' ], -'bs_BA' => [ 'Bosnian', 'iso-8859-2', 'bs', 'bs' ], -'ca_ES' => [ 'Catalan', 'iso-8859-15', 'ca', 'ca:es_ES:es' ], -'cs_CZ' => [ 'Czech', 'iso-8859-2', 'cs', 'cs' ], -'cy_GB.UTF-8' => [ 'Cymraeg (Welsh)', 'iso-8859-14', 'cy', 'cy:en_GB:en', 'UTF-8' ], -'da_DK' => [ 'Danish', 'iso-8859-15', 'da', 'da' ], -'de_AT' => [ 'German|Austria', 'iso-8859-15', 'de', 'de_AT:de' ], -'de_BE' => [ 'German|Belgium', 'iso-8859-15', 'de', 'de_BE:de' ], -'de_CH' => [ 'German|Switzerland', 'iso-8859-15', 'de', 'de_CH:de' ], -'de_DE' => [ 'German|Germany', 'iso-8859-15', 'de', 'de_DE:de' ], -'el_GR' => [ 'Greek', 'iso-8859-7', 'el', 'el' ], -'el_GR.UTF-8' => [ 'Greek (UTF-8)', 'iso-8859-7', 'el', 'el', 'UTF-8' ], -'eo_XX' => [ 'Esperanto', 'iso-8859-3', 'eo', 'eo', 'UTF-8' ], -'es_AR' => [ 'Spanish|Argentina', 'iso-8859-1', 'es', 'es_AR:es_UY:es:es_ES' ], -'es_ES' => [ 'Spanish|Spain (modern sorting)', 'iso-8859-15', 'es', 'es_ES:es' ], -'es@tradicional' => [ 'Spanish|Spain (traditional sorting)', 'iso-8859-15', 'es', 'es' ], -'es_ES.UTF-8' => [ 'Spanish|Spain (UTF-8)', 'iso-8859-15', 'es', 'es_ES:es', 'UTF-8' ], -'es_MX' => [ 'Spanish|Mexico', 'iso-8859-1', 'es', 'es_MX:es:es_ES' ], -'et_EE' => [ 'Estonian', 'iso-8859-15', 'et', 'et' ], -'eu_ES' => [ 'Euskara (Basque)', 'iso-8859-15', 'eu', 'eu' ], -'fa_IR.UTF-8' => [ 'Farsi (Iranian)', 'unicode', 'fa', 'fa', 'UTF-8' ], -'fi_FI' => [ 'Finnish (Suomi)', 'iso-8859-15', 'fi', 'fi' ], -#-'fo_FO' => [ 'Faroese', 'iso-8859-1', 'fo', 'fo' ], -'fr_BE' => [ 'French|Belgium', 'iso-8859-15', 'fr', 'fr_BE:fr' ], -'fr_CA' => [ 'French|Canada', 'iso-8859-15', 'fr', 'fr_CA:fr' ], -'fr_CH' => [ 'French|Switzerland', 'iso-8859-15', 'fr', 'fr_CH:fr' ], -'fr_FR' => [ 'French|France', 'iso-8859-15', 'fr', 'fr_FR:fr' ], -'fr_FR.UTF-8' => [ 'French|France (UTF-8)', 'iso-8859-15', 'fr', 'fr_FR:fr', 'UTF-8' ], -'ga_IE' => [ 'Gaeilge (Irish)', 'iso-8859-15', 'ga', 'ga:en_IE:en' ], -#-'gd_GB' => [ 'Scottish gaelic', 'iso-8859-14','gd', 'gd:en_GB:en' ], -'gl_ES' => [ 'Galego (Galician)', 'iso-8859-15', 'gl', 'gl:es_ES:pt_PT:pt_BR:es:pt' ], -#-'gv_GB' => [ 'Manx gaelic', 'iso-8859-14','gv', 'gv:en_GB:en' ], -#- 'iw' was the old code for hebrew language -'he_IL.UTF-8' => [ 'Hebrew', 'iso-8859-8', 'he', 'he:iw_IL', 'UTF-8' ], -'hi_IN.UTF-8' => [ 'Hindi', 'unicode', 'hi', 'hi:en_IN:en_GB', 'UTF-8' ], -'hr_HR' => [ 'Croatian', 'iso-8859-2', 'hr', 'hr' ], -'hu_HU' => [ 'Hungarian', 'iso-8859-2', 'hu', 'hu' ], -'hy_AM.UTF-8' => [ 'Armenian', 'armscii-8', 'hy', 'hy', 'UTF-8' ], -#'ia_XX' => [ 'Interlingua', 'unicode', 'ia', 'ia', 'UTF-8' ], -'id_ID' => [ 'Indonesian', 'iso-8859-1', 'id', 'id', 'UTF-8' ], -'is_IS' => [ 'Icelandic', 'iso-8859-1', 'is', 'is' ], -'it_CH' => [ 'Italian|Switzerland', 'iso-8859-15', 'it', 'it_IT:it' ], -'it_IT' => [ 'Italian|Italy', 'iso-8859-15', 'it', 'it_IT:it' ], -#-'iu_CA' => [ 'Inuktitut', 'utf_iu', 'iu', 'iu', 'UTF-8' ], -'ja_JP' => [ 'Japanese', 'jisx0208', 'ja', 'ja_JP.ujis:ja' ], -'ja_JP.UTF-8' => [ 'Japanese (UTF-8)', 'jisx0208', 'ja', 'ja_JP.ujis:ja', 'UTF-8' ], -'ka_GE.UTF-8' => [ 'Georgian', 'georgian-ps', 'ka', 'ka', 'UTF-8' ], -#-'kl_GL' => [ 'Greenlandic (inuit)', 'iso-8859-1', 'kl', 'kl' ], -'ko_KR' => [ 'Korean', 'ksc5601', 'ko', 'ko' ], -'ko_KR.UTF-8' => [ 'Korean (UTF-8)', 'ksc5601', 'ko', 'ko', 'UTF-8' ], -#-'kw_GB' => [ 'Cornish gaelic', 'iso-8859-14','kw', 'kw:en_GB:en' ], -#-'lo_LA' => [ 'Laotian', 'utf_lo', 'lo', 'lo' ], -'lt_LT' => [ 'Lithuanian', 'iso-8859-13', 'lt', 'lt' ], -'lv_LV' => [ 'Latvian', 'iso-8859-13', 'lv', 'lv' ], -'mi_NZ.UTF-8' => [ 'Maori', 'iso-8859-13', 'mi', 'mi', 'UTF-8' ], -'mk_MK.UTF-8' => [ 'Macedonian (Cyrillic)', 'cp1251', 'mk', 'mk', 'UTF-8' ], -'ms_MY' => [ 'Malay', 'iso-8859-1', 'ms', 'ms', 'UTF-8' ], -'mt_MT.UTF-8' => [ 'Maltese', 'iso-8859-3', 'mt', 'mt', 'UTF-8' ], -'nl_BE' => [ 'Dutch|Belgium', 'iso-8859-15', 'nl', 'nl_BE:nl' ], -'nl_NL' => [ 'Dutch|Netherlands', 'iso-8859-15', 'nl', 'nl_NL:nl' ], -#- 'nb' is the new locale name in glibc 2.2 -'no_NO' => [ 'Norwegian|Bokmaal', 'iso-8859-1', 'no', 'no:nb:nn:no@nynorsk:no_NY' ], -#- no_NY is used by KDE (but not standard); 'nn' is the new locale in glibc 2.2 -'nn_NO' => [ 'Norwegian|Nynorsk', 'iso-8859-1', 'no', 'nn:no@nynorsk:no_NY:no:nb' ], -#-'oc_FR' => [ 'Occitan', 'iso-8859-1', 'oc', 'oc:fr_FR' ], -#-'ph_PH' => [ 'Pilipino', 'iso-8859-1', 'ph', 'ph:tl', 'UTF-8' ], -'pl_PL' => [ 'Polish', 'iso-8859-2', 'pl', 'pl' ], -#-'pp_AN'=> [ 'Papiamento', 'iso-8859-1', 'pp', 'pp' ], -'pt_BR' => [ 'Portuguese|Brazil', 'iso-8859-1', 'pt_BR', 'pt_BR:pt_PT:pt' ], -'pt_PT' => [ 'Portuguese|Portugal', 'iso-8859-15', 'pt', 'pt_PT:pt:pt_BR' ], -'ro_RO' => [ 'Romanian', 'iso-8859-2', 'ro', 'ro' ], -'ru_RU.KOI8-R' => [ 'Russian|KOI8-R', 'koi8-r', 'ru', 'ru_RU:ru' ], -'ru_RU.CP1251' => [ 'Russian|CP1251', 'cp1251', 'ru', 'ru_RU:ru' ], -'ru_RU.UTF-8' => [ 'Russian|UTF-8', 'cp1251', 'ru', 'ru_RU:ru', 'UTF-8' ], -'sk_SK' => [ 'Slovak', 'iso-8859-2', 'sk', 'sk' ], -'sl_SI' => [ 'Slovenian', 'iso-8859-2', 'sl', 'sl' ], -#'sp_YU.ISO-8859-5' => [ 'Serbian|Cyrillic (ISO-8859-5)','iso-8859-5', 'sp', 'sp:sr' ], -#'sp_YU.CP1251' => [ 'Serbian|Cyrillic (CP1251)','cp1251', 'sp', 'sp:sr' ], -'sp_YU.UTF-8' => [ 'Serbian|Cyrillic', 'cp1251', 'sp', 'sp:sr', 'UTF-8' ], -'sr_YU.ISO-8859-2' => [ 'Serbian|Latin (ISO-8859-2)', 'iso-8859-2', 'sr', 'sr' ], -'sr_YU.UTF-8' => [ 'Serbian|Latin (UTF-8)', 'iso-8859-2', 'sr', 'sr', 'UTF-8' ], -'sv_SE' => [ 'Swedish', 'iso-8859-1', 'sv', 'sv' ], -'ta_IN' => [ 'Tamil (TSCII)', 'tscii', 'ta', 'ta' ], -'ta_IN.UTF-8' => [ 'Tamil (UTF-8)', 'unicode', 'ta', 'ta', 'UTF-8' ], -'tg_TJ.UTF-8' => [ 'Tajik', 'koi8-k', 'tg', 'tg', 'UTF-8' ], -'th_TH' => [ 'Thai|TIS-620', 'tis620', 'th', 'th' ], -'th_TH.UTF-8' => [ 'Thai (UTF-8)', 'tis620', 'th', 'th', 'UTF-8' ], -'tr_TR' => [ 'Turkish', 'iso-8859-9', 'tr', 'tr' ], -#-'tt_RU.UTF-8' => [ 'Tatar', 'koi8-k', 'tt', 'tt', 'UTF-8' ], -#-'ur_PK' => [ 'Urdu', 'cp1256', 'ur', 'ur', 'UTF-8' ], -'uk_UA' => [ 'Ukrainian|KOI8-U', 'koi8-u', 'uk', 'uk_UA:uk' ], -'uk_UA.CP1251' => [ 'Ukrainian|CP1251', 'cp1251', 'uk', 'uk_UA:uk' ], -'uk_UA.UTF-8' => [ 'Ukrainian|UTF-8', 'cp1251', 'uk', 'uk_UA:uk', 'UTF-8' ], -'uz_UZ' => [ 'Uzbek', 'iso-8859-1', 'uz', 'uz', 'UTF-8' ], -'vi_VN.UTF-8' => [ 'Vietnamese', 'tcvn', 'vi', 'vi', 'UTF-8' ], -'wa_BE' => [ 'Walon', 'iso-8859-15', 'wa', 'wa:fr_BE:fr' ], -#-'yi' => [ 'Yiddish', 'cp1255', 'yi', 'yi', 'UTF-8' ], -#- NOTE: 'zh' must be in the LANGUAGE list, it is not used for translations -#- themselves but is needed for our selection of locales-xx packages -#- and the language dependent packages resolution -#'zh_HK.Big5' => [ 'Chinese|Traditional|Hong Kong|Big5', 'Big5', 'zh_TW.Big5', 'zh_TW.Big5:zh_TW:zh_HK:zh' ], -#'zh_HK.UTF-8' => [ 'Chinese|Traditional|Hong Kong|UTF-8','Big5','zh_HK', 'zh_HK:zh_TW.Big5:zh_TW:zh', 'UTF-8' ], -'zh_TW.Big5' => [ 'Chinese|Traditional|Big5', 'Big5', 'zh_TW.Big5', 'zh_TW.Big5:zh_TW:zh_HK:zh' ], -'zh_TW.UTF-8' => [ 'Chinese|Traditional|UTF-8', 'Big5', 'zh_TW', 'zh_TW.Big5:zh_TW.big5:zh_TW:zh_HK:zh', 'UTF-8' ], -'zh_CN.GB2312' => [ 'Chinese|Simplified|GB2312', 'gb2312', 'zh_CN.GB2312', 'zh_CN.GB2312:zh_CN:zh' ], -'zh_CN.UTF-8' => [ 'Chinese|Simplified|UTF-8', 'gb2312', 'zh_CN', 'zh_CN.GB2312:zh_CN:zh', 'UTF-8' ], -#- does this one works? -#'zh_CN.GB18030' => [ 'Chinese|Simplified|GB18030','gb2312','zh_CN', 'zh_CN.GB2312:zh_CN:zh' ], +#- key: lang name (locale name for some (~5) special cases needing +#- extra distinctions) +#- [0]: language name (localized, used for sorting, the display is done +#- with a lang-%s.png image, with %s being the key) +#- [1]: transliterated locale name in the locale name (used for sorting) +#- [2]: default locale name to use for that language if there isn't +#- an existing locale for the combination language+country choosen +#- [3]: geographic groups that this language belongs to (for displaying +#- in the menu grouped in smaller lists), 1=Europe, 2=Asia, 3=Africa, +#- 4=Oceania&Pacific, 5=America (if you wonder, it's the order +#- used in the olympic flag) +#- [4]: special value for LANGUAGE variable (if different of the default +#- of 'll_CC:ll_DD:ll' (ll_CC: locale (if exist) resulting of the +#- combination of chosen lang (ll) and country (CC), ll_DD: the +#- default locale shown here (field [2]) and ll: the language (the key)) +my %langs = ( +'en_US' => [ 'English (American)', 'American English', 'en_US', ' 5', 'C' ], +'en_GB' => [ 'English', 'British English', 'en_GB', '12345', 'iso-8859-15' ], +'af' => [ 'Afrikaans', 'Afrikaans', 'af_ZA', ' 3 ', 'iso-8859-1' ], +'am' => [ 'Amharic', 'ZZ Amharic', 'am_ET', ' 3 ', 'utf_am' ], +'ar' => [ 'Arabic', 'AA Arabic', 'ar_EG', ' 23 ', 'iso-8859-6' ], +'az' => [ 'Azeri (Latin)', 'Azerbaijani', 'az_AZ', ' 2 ', 'iso-8859-9e' ], +'be' => [ 'Belarussian', 'Belarussian', 'be_BY', '1 ', 'cp1251' ], +'bg' => [ 'Bulgarian', 'Bulgarian', 'bg_BG', '1 ', 'cp1251' ], +'br' => [ 'Brezhoneg', 'Brezhoneg', 'br_FR', '1 ', 'iso-8859-15', 'br:fr_FR:fr' ], +'bs' => [ 'Bosnian', 'Bosanski', 'bs_BA', '1 ', 'iso-8859-2' ], +'ca' => [ 'Catalan', 'Catala', 'ca_ES', '1 ', 'iso-8859-15', 'ca:es_ES:es' ], +'cs' => [ 'Czech', 'Cestina', 'cs_CZ', '1 ', 'iso-8859-2' ], +'cy' => [ 'Cymraeg (Welsh)', 'Cymraeg', 'cy_GB', '1 ', 'iso-8859-14', 'cy:en_GB:en' ], +'da' => [ 'Danish', 'Dansk', 'da_DK', '1 ', 'iso-8859-15' ], +'de' => [ 'German', 'Deutsch', 'de_DE', '1 ', 'iso-8859-15' ], +'el' => [ 'Greek', 'Ellada', 'el_GR', '1 ', 'iso-8859-7' ], +'eo' => [ 'Esperanto', 'Esperanto', 'eo_XX', '12345', 'iso-8859-3' ], +'es' => [ 'Spanish', 'Espanol', 'es_ES', '1 3 5', 'iso-8859-15' ], +'et' => [ 'Estonian', 'Eesti', 'et_EE', '1 ', 'iso-8859-15' ], +'eu' => [ 'Euskara (Basque)', 'Euskaka', 'eu_ES', '1 ', 'iso-8859-15' ], +'fa' => [ 'Farsi (Iranian)', 'AA Farsi', 'fa_IR', ' 2 ', 'unicode' ], +'fi' => [ 'Finnish (Suomi)', 'Suomi', 'fi_FI', '1 ', 'iso-8859-15' ], +#'fo' => [ 'Faroese', 'Foroysk', 'fo_FO', '1 ', 'iso-8859-1' ], +'fr' => [ 'French', 'Francais', 'fr_FR', '1 345', 'iso-8859-15' ], +'ga' => [ 'Gaeilge (Irish)', 'Gaeilge', 'ga_IE', '1 ', 'iso-8859-15', 'ga:en_IE:en_GB:en' ], +#'gd' => [ 'Scottish gaelic', 'Gaidhlig', 'gb_GB', '1 ', 'iso-8859-14', 'gd:en_GB:en' ], +'gl' => [ 'Galego (Galician)', 'Galego', 'gl_ES', '1 ', 'iso-8859-15', 'gl:es_ES:es:pt:pt_BR' ], +#'gv' => [ 'Manx gaelic', 'Gaelg', 'gv_GB', '1 ', 'iso-8859-14', 'gv:en_GB:en' ], +'he' => [ 'Hebrew', 'AA Hebrew', 'he_IL', ' 2 ', 'iso-8859-8' ], +#waiting-for-image 'hi' => [ 'Hindi', 'hi_IN', ' 2 ', 'unicode' ], +'hr' => [ 'Croatian', 'Hrvatski', 'hr_HR', '1 ', 'iso-8859-2' ], +'hu' => [ 'Hungarian', 'Magyar', 'hu_HU', '1 ', 'iso-8859-2' ], +'hy' => [ 'Armenian', 'ZZ Armenian', 'hy_AM', ' 2 ', 'armscii-8' ], +#'ia' => [ 'Interlingua', 'Interlingua', 'ia_XX', '1 5', 'unicode' ], +'id' => [ 'Indonesian', 'Bahasa Indonesia', 'id_ID', ' 2 ', 'iso-8859-1' ], +'is' => [ 'Icelandic', 'Islenska', 'is_IS', '1 ', 'iso-8859-1' ], +'it' => [ 'Italian', 'Italiano', 'it_IT', '1 ', 'iso-8859-15' ], +#-'iu' => [ 'Inuktitut', 'ZZ Inuktitut', 'iu_CA', ' 5', 'utf_iu' ], +'ja' => [ 'Japanese', 'ZZ Nihongo', 'ja_JP', ' 2 ', 'jisx0208' ], +'ka' => [ 'Georgian', 'ZZ Georgian', 'ka_GE', ' 2 ', 'georgian-ps' ], +#-'kl' => [ 'Greenlandic (inuit)', 'ZZ Inuit', 'kl_GL', ' 5', 'iso-8859-1' ], +'ko' => [ 'Korean', 'ZZ Korea', 'ko_KR', ' 2 ', 'ksc5601' ], +#-'kw' => [ 'Cornish gaelic', 'Kernewek', 'kw_GB', '1 ', 'iso-8859-14', 'kw:en_GB:en' ], +#waiting-for-image 'lo' => [ 'Laotian', 'lo_LA', ' 2 ', 'utf_lo' ], +'lt' => [ 'Lithuanian', 'Lietuviskai', 'lt_LT', '1 ', 'iso-8859-13' ], +'lv' => [ 'Latvian', 'Latviesu', 'lv_LV', '1 ', 'iso-8859-13' ], +'mi' => [ 'Maori', 'Maori', 'mi_NZ', ' 4 ', 'iso-8859-13' ], +'mk' => [ 'Macedonian', 'Macedonian', 'mk_MK', '1 ', 'cp1251' ], +'ms' => [ 'Malay', 'Bahasa Melayu', 'ms_MY', ' 2 ', 'iso-8859-1' ], +'mt' => [ 'Maltese', 'Maltin', 'mt_MT', '1 3 ', 'iso-8859-3' ], +'nb' => [ 'Norwegian Bokmaal', 'Norsk, Bokmal', 'no_NO', '1 ', 'iso-8859-1', 'nb:no' ], +'nl' => [ 'Dutch', 'Nederlands', 'nl_NL', '1 ', 'iso-8859-15' ], +'nn' => [ 'Norwegian Nynorsk', 'Norsk, Nynorsk', 'nn_NO', '1 ', 'iso-8859-1', 'nn:no@nynorsk:no_NY:no:nb' ], +#-'oc' => [ 'Occitan', 'Occitan', 'oc_FR', '1 ', 'iso-8859-1', 'oc:fr_FR:fr' ], +#-'ph' => [ 'Pilipino', 'Pilipino', 'ph_PH', ' 2 ', 'iso-8859-1', 'ph:tl' ], +'pl' => [ 'Polish', 'Polski', 'pl_PL', '1 ', 'iso-8859-2' ], +'pt' => [ 'Portuguese', 'Portugues', 'pt_PT', '1 3 ', 'iso-8859-15', 'pt_PT:pt:pt_BR' ], +'pt_BR' => [ 'Portuguese Brazil', 'Portugues do Brasil', 'pt_BR', ' 5', 'iso-8859-1', 'pt_BR:pt_PT:pt' ], +'ro' => [ 'Romanian', 'Romana', 'ro_RO', '1 ', 'iso-8859-2' ], +'ru' => [ 'Russian', 'Russann', 'ru_RU', '12 ', 'koi8-r' ], +'sk' => [ 'Slovak', 'Slovencina', 'sk_SK', '1 ', 'iso-8859-2' ], +'sl' => [ 'Slovenian', 'Slovenscina', 'sl_SI', '1 ', 'iso-8859-2' ], +'sp' => [ 'Serbian Cyrillic', 'Serbian', 'sp_YU', '1 ', 'cp1251', 'sp:sr' ], +'sr' => [ 'Serbian Latin', 'Serbian', 'sr_YU', '1 ', 'iso-8859-2' ], +'sv' => [ 'Swedish', 'Svenska', 'sv_SE', '1 ', 'iso-8859-1' ], +'ta' => [ 'Tamil', 'ZZ Tamil', 'ta_IN', ' 2 ', 'tscii' ], +'tg' => [ 'Tajik', 'ZZ Tajik', 'tg_TJ', ' 2 ', 'koi8-k' ], +'th' => [ 'Thai', 'ZZ Thai', 'th_TH', ' 2 ', 'tis620' ], +'tr' => [ 'Turkish', 'Turkce', 'tr_TR', ' 2 ', 'iso-8859-9' ], +#-'tt' => [ 'Tatar', 'Tatar', 'tt_RU', ' 2 ', 'koi8-k' ], +'uk' => [ 'Ukrainian', 'Ukrainian', 'uk_UA', '1 ', 'koi8-u' ], +#-'ur' => [ 'Urdu', 'Urdu', 'ur_PK', ' 2 ', 'unicode' ], +'uz' => [ 'Uzbek', 'Ozbekcha', 'uz_UZ', ' 2 ', 'iso-8859-1' ], +'vi' => [ 'Vietnamese', 'Tieng Viet', 'vi_VN', ' 2 ', 'tcvn' ], +'wa' => [ 'Walon', 'Walon', 'wa_BE', '1 ', 'iso-8859-15', 'wa:fr_BE:fr' ], +#-'yi' => [ 'Yiddish', 'AA Yiddish', 'yi_US', '1 5', 'cp1255' ], +'zh_TW' => [ 'Chinese Traditional', 'ZZ Chinese', 'zh_TW', ' 2 ', 'Big5', 'zh_TW.Big5:zh_TW:zh_HK:zh' ], +'zh_CN' => [ 'Chinese Simplified', 'ZZ Chinese', 'zh_CN', ' 2 ', 'gb2312', 'zh_CN.GB2312:zh_CN:zh' ], +); +sub l2name { exists $langs{$_[0]} && $langs{$_[0]}[0] } +sub l2transliterated { exists $langs{$_[0]} && $langs{$_[0]}[1] } +sub l2locale { exists $langs{$_[0]} && $langs{$_[0]}[2] } +sub l2location { + my %geo = (1 => 'Europe', 2 => 'Asia', 3 => 'Africa', 4 => 'Oceania/Pacific', 5 => 'America'); + map { if_($langs{$_[0]}[3] =~ $_, $geo{$_}) } 1..5; +} +sub l2charset { exists $langs{$_[0]} && $langs{$_[0]}[4] } +sub l2language { exists $langs{$_[0]} && $langs{$_[0]}[5] } +sub list_langs { + my (%options) = @_; + my @l = keys %langs; + $options{exclude_non_installed} ? grep { -e "/usr/share/locale/".l2locale($_)."/LC_CTYPE" } @l : @l; +} + +#- key: country name (that should be YY in xx_YY locale) +#- [0]: country name in natural language +#- [1]: default locale for that country +my %countries = ( +'AM' => [ N("Armenia"), 'hy_AM' ], +'AR' => [ N("Argentina"), 'es_AR' ], +'AT' => [ N("Austria"), 'de_AT' ], +'AU' => [ N("Australia"), 'en_AU' ], +'AZ' => [ N("Azerbaijan"), 'az_AZ' ], +'BA' => [ N("Bosnia"), 'bs_BA' ], +'BE' => [ N("Belgium"), 'fr_BE' ], +'BG' => [ N("Bulgaria"), 'bg_BG' ], +'BR' => [ N("Brazil"), 'pt_BR' ], +'BY' => [ N("Belarussia"), 'be_BY' ], +'CA' => [ N("Canada"), 'en_CA' ], +'CH' => [ N("Switzerland"), 'fr_CH' ], +'CN' => [ N("China"), 'zh_CN' ], +'CZ' => [ N("Czech Republic"), 'cs_CZ' ], +'DE' => [ N("Germany"), 'de_DE' ], +'DK' => [ N("Danmark"), 'da_DK' ], +'EE' => [ N("Estonia"), 'et_EE' ], +'ES' => [ N("Spain"), 'es_ES' ], +'FI' => [ N("Finland"), 'fi_FI' ], +'FR' => [ N("France"), 'fr_FR' ], +'GB' => [ N("United Kingdom"), 'en_GB' ], +'GE' => [ N("Georgia"), 'ka_GE' ], +'GL' => [ N("Greenland"), 'kl_GL' ], +'GR' => [ N("Greece"), 'el_GR' ], +'HR' => [ N("Croatia"), 'hr_HR' ], +'HU' => [ N("Hungary"), 'hu_HU' ], +'ID' => [ N("Indonesia"), 'id_ID' ], +'IE' => [ N("Ireland"), 'en_IE' ], +'IL' => [ N("Israel"), 'he_IL' ], +'IN' => [ N("India"), 'hi_IN' ], +'IR' => [ N("Iran"), 'fa_IR' ], +'IS' => [ N("Iceland"), 'is_IS' ], +'IT' => [ N("Italy"), 'it_IT' ], +'JP' => [ N("Japan"), 'ja_JP' ], +'KR' => [ N("Korea"), 'ko_KR' ], +'LT' => [ N("Lithuania"), 'lt_LT' ], +'LV' => [ N("Latvia"), 'lv_LV' ], +'MK' => [ N("Macedonia"), 'mk_MK' ], +'MT' => [ N("Malta"), 'mt_MT' ], +'MX' => [ N("Mexico"), 'es_MX' ], +'MY' => [ N("Malaysia"), 'ms_MY' ], +'NL' => [ N("Netherlands"), 'nl_NL' ], +'NO' => [ N("Norway"), 'no_NO' ], +'NZ' => [ N("New Zealand"), 'en_NZ' ], +'PL' => [ N("Poland"), 'pl_PL' ], +'PT' => [ N("Portugal"), 'pt_PT' ], +'RO' => [ N("Romania"), 'ro_RO' ], +'RU' => [ N("Russia"), 'ru_RU' ], +'SE' => [ N("Sweden"), 'sv_SE' ], +'SI' => [ N("Slovenia"), 'sl_SI' ], +'SK' => [ N("Slovakia"), 'sk_SK' ], +'TH' => [ N("Thailand"), 'th_TH' ], +'TJ' => [ N("Tajikistan"), 'tg_TJ' ], +'TR' => [ N("Turkey"), 'tr_TR' ], +'TW' => [ N("Taiwan"), 'zh_TW' ], +'UA' => [ N("Ukraina"), 'uk_UA' ], +'US' => [ N("United States"), 'en_US' ], +'UZ' => [ N("Uzbekistan"), 'uz_UZ' ], +'VN' => [ N("Vietnam"), 'vi_VN' ], +'YU' => [ N("Serbia"), 'sp_YU' ], +'ZA' => [ N("South Africa"), 'en_ZA' ], ); -@languages = map { $_->[0] } group_by2(@languages); +sub c2name { exists $countries{$_[0]} && $countries{$_[0]}[0] } +sub c2locale { exists $countries{$_[0]} && $countries{$_[0]}[1] } +sub list_countries { + my (%options) = @_; + my @l = keys %countries; + $options{exclude_non_installed} ? grep { -e "/usr/share/locale/".c2locale($_)."/LC_CTYPE" } @l : @l; +} + +our @locales = qw(af_ZA am_ET ar_EG az_AZ be_BY bg_BG br_FR bs_BA ca_ES cs_CZ cy_GB da_DK de_AT de_BE de_CH de_DE el_GR en_AU en_CA en_GB en_IE en_NZ en_US en_ZA eo_XX es_AR es_ES es_MX et_EE eu_ES fa_IR fi_FI fr_BE fr_CA fr_CH fr_FR ga_IE gl_ES he_IL hi_IN hr_HR hu_HU hy_AM id_ID is_IS it_CH it_IT ja_JP ka_GE kl_GL ko_KR lt_LT lv_LV mi_NZ mk_MK ms_MY mt_MT nl_BE nl_NL nn_NO no_NO pl_PL pt_BR pt_PT ro_RO ru_RU sk_SK sl_SI sp_YU sr_YU sv_SE ta_IN tg_TJ th_TH tr_TR uk_UA uz_UZ vi_VN wa_BE zh_CN zh_TW); + +sub standard_locale { + my ($lang, $country, $utf8) = @_; + retry: + member("${lang}_${country}", @locales) and return "${lang}_${country}".($utf8 ? '.UTF-8' : ''); + length($lang) > 2 and $lang =~ s/^(..).*/$1/, goto retry; +} + +sub getlocale_for_lang { + my ($lang, $country, $utf8) = @_; + standard_locale(@_) || l2locale($lang).($utf8 ? '.UTF-8' : ''); +} + +sub getlocale_for_country { + my ($lang, $country, $utf8) = @_; + standard_locale(@_) || c2locale($country).($utf8 ? '.UTF-8' : ''); +} + +sub getLANGUAGE { + my ($lang, $country, $utf8) = @_; + l2language($lang) || join(':', uniq(getlocale_for_lang(@_), $lang, if_($lang =~ /^(..)_/, $1))); +} my %xim = ( - 'zh_TW.Big5' => { + 'zh_TW' => { ENC => 'big5', XIM => 'xcin', XIM_PROGRAM => 'xcin', XMODIFIERS => '"@im=xcin"', CONSOLE_NOT_LOCALIZED => 'yes', }, - 'zh_TW.Big5@chinput' => { - ENC => 'big5', - XIM => 'Chinput', - XIM_PROGRAM => 'chinput', - XMODIFIERS => '"@im=Chinput"', - CONSOLE_NOT_LOCALIZED => 'yes', - }, 'zh_TW.UTF-8' => { ENC => 'utf8', XIM => 'Chinput', @@ -175,7 +228,7 @@ my %xim = ( XMODIFIERS => '"@im=Chinput"', CONSOLE_NOT_LOCALIZED => 'yes', }, - 'zh_CN.GB2312' => { + 'zh_CN' => { ENC => 'gb', XIM => 'Chinput', XIM_PROGRAM => 'chinput', @@ -189,7 +242,7 @@ my %xim = ( XMODIFIERS => '"@im=Chinput"', CONSOLE_NOT_LOCALIZED => 'yes', }, - 'ko' => { + 'ko_KR' => { ENC => 'kr', XIM => 'Ami', #- NOTE: there are several possible versions of ami, for the different @@ -209,7 +262,7 @@ my %xim = ( XMODIFIERS => '"@im=Ami"', CONSOLE_NOT_LOCALIZED => 'yes', }, - 'ja' => { + 'ja_JP' => { ENC => 'eucj', XIM => 'kinput2', XIM_PROGRAM => 'kinput2', @@ -224,7 +277,7 @@ my %xim = ( #- XFree86 has an internal XIM for Thai that enables syntax checking etc. #- 'Passthroug' is no check at all, 'BasicCheck' accepts bad sequences #- and convert them to right ones, 'Strict' refuses bad sequences - 'th' => { + 'th_TH' => { XIM_PROGRAM => '/bin/true', #- it's an internal module XMODIFIERS => '"@im=BasicCheck"', }, @@ -236,95 +289,52 @@ my %xim = ( #- }, ); -sub std2 { "-*-*-medium-r-normal-*-$_[1]-*-*-*-*-*-$_[0]" } -sub std_ { std2($_[0], 10), std2($_[0], 10) } -sub std { std2($_[0], $_[1] || 10), std2($_[0], 8) } - #- [0]: console font name #- [1]: sfm map for console font (if needed) #- [2]: acm file for console font (none if utf8) #- [3]: iocharset param for mount (utf8 if utf8) #- [4]: codepage parameter for mount (none if utf8) -#- [5]: X11 fontset (for DrakX) my %charsets = ( - "armscii-8" => [ "arm8", undef, "armscii-8", - undef, undef, std_("armscii-8") ], +"armscii-8" => [ "arm8", undef, "armscii-8", undef, undef ], #- chinese needs special console driver for text mode - "Big5" => [ undef, undef, undef, - "big5", "950", "-*-*-*-*-*-*-*-*-*-*-*-*-big5-0" ], - "gb2312" => [ undef, undef, undef, - "gb2312", "936", "-*-*-*-*-*-*-*-*-*-*-*-*-gb2312.1980-0" ], - "C" => [ "lat0-16", undef, "iso15", - "iso8859-1", "850", sub { std("iso8859-1", @_) } ], - "iso-8859-1" => [ "lat1-16", undef, "iso01", - "iso8859-1", "850", sub { std("iso8859-15", @_) } ], - "iso-8859-2" => [ "lat2-sun16", undef, "iso02", - "iso8859-2", "852", sub { std("iso8859-2", @_) } ], - "iso-8859-3" => [ "iso03.f16", undef, "iso03", - "iso8859-3", undef, std_("iso8859-3") ], -#- "iso-8859-4" => [ "lat4u-16", undef, "iso04", -#- "iso8859-4", "775", std_("iso8859-4") ], -#- "iso-8859-5" => [ "UniCyr_8x16", undef, "iso05", -#- "iso8859-5", "855", sub { std("microsoft-cp1251", @_) } ], -#-#- arabic needs special console driver for text mode [acon] -#-#- (and gtk support isn't done yet) - "iso-8859-6" => [ "iso06.f16", undef, "iso06", - "iso8859-6", "864", std_("iso8859-6") ], - "iso-8859-7" => [ "iso07.f16", undef, "iso07", - "iso8859-7", "869", std_("iso8859-7") ], -#-#- hebrew needs special console driver for text mode [acon] -#-#- (and gtk support isn't done yet) - "iso-8859-8" => [ "iso08.f16", undef, "iso08", -#- std_("iso8859-8") ], - "iso8859-8", "862", std_("microsoft-cp1255") ], - "iso-8859-9" => [ "lat5u-16", undef, "iso09", - "iso8859-9", "857", sub { std("iso8859-9", @_) } ], - "iso-8859-13" => [ "tlat7", undef, "iso13", - "iso8859-13", "775", std_("iso8859-13") ], - "iso-8859-14" => [ "iso14.f16", undef, "iso14", - "iso8859-14", "850", std_("iso8859-14") ], - "iso-8859-15" => [ "lat0-16", undef, "iso15", - "iso8859-15", "850", sub { std("iso8859-15", @_) } ], - "iso-8859-9e" => [ "tiso09e", undef, "iso09e", - undef, undef, std2("iso8859-9e",10) ], +"Big5" => [ undef, undef, undef, "big5", "950" ], +"gb2312" => [ undef, undef, undef, "gb2312", "936" ], +"C" => [ "lat0-16", undef, "iso15", "iso8859-1", "850" ], +"iso-8859-1" => [ "lat1-16", undef, "iso01", "iso8859-1", "850" ], +"iso-8859-2" => [ "lat2-sun16", undef, "iso02", "iso8859-2", "852" ], +"iso-8859-3" => [ "iso03.f16", undef, "iso03", "iso8859-3", undef ], +#-"iso-8859-4"=> [ "lat4u-16", undef, "iso04", "iso8859-4", "775" ], +#-"iso-8859-5"=> [ "UniCyr_8x16", undef, "iso05", "iso8859-5", "855" ], +#- arabic needs special console driver for text mode [acon] (and gtk support isn't done yet) +"iso-8859-6" => [ "iso06.f16", undef, "iso06", "iso8859-6", "864" ], +"iso-8859-7" => [ "iso07.f16", undef, "iso07", "iso8859-7", "869" ], +#- hebrew needs special console driver for text mode [acon] (and gtk support isn't done yet) +"iso-8859-8" => [ "iso08.f16", undef, "iso08", "iso8859-8", "862" ], +"iso-8859-9" => [ "lat5u-16", undef, "iso09", "iso8859-9", "857" ], +"iso-8859-13" => [ "tlat7", undef, "iso13", "iso8859-13", "775" ], +"iso-8859-14" => [ "iso14.f16", undef, "iso14", "iso8859-14", "850" ], +"iso-8859-15" => [ "lat0-16", undef, "iso15", "iso8859-15", "850" ], +"iso-8859-9e" => [ "tiso09e", undef, "iso09e", undef, undef ], #- japanese needs special console driver for text mode [kon2] - "jisx0208" => [ undef, undef, "trivial.trans", - "euc-jp", "932", "-*-*-*-*-*-*-*-*-*-*-*-*-jisx*.*-0" ], - "koi8-r" => [ "UniCyr_8x16", undef, "koi8-r", - "koi8-r", "866", sub { std("microsoft-cp1251", @_) } ], - "koi8-u" => [ "UniCyr_8x16", undef, "koi8-u", - "koi8-u", "866", sub { std("microsoft-cp1251", @_) } ], - "georgian-ps" => [ "t_geors", undef, undef, - "utf8", undef, "-*-*-*-*-*-*-*-*-*-*-*-*-georgian-academy" ], - "koi8-k" => [ "koi8-k", undef, undef, - "utf8", undef, std("koi8-k") ], - "cp1251" => [ "UniCyr_8x16", undef, "cp1251", - "cp1251", "866", sub { std("microsoft-cp1251", @_) } ], -#- Yiddish needs special console driver for text mode [acon] -#- (and gtk support isn't done yet) -#- "cp1255" => [ "iso08.f16", "iso08", "trivial.trans", -#- "cp1255", "862", std_("microsoft-cp1255") ], -#- Urdu needs special console driver for text mode [acon] -#- (and gtk support isn't done yet) -#- "cp1256" => [ undef, undef, "trivial.trans", -#- undef, "864", std_("microsoft-cp1255") ], +"jisx0208" => [ undef, undef, "trivial.trans", "euc-jp", "932" ], +"koi8-r" => [ "UniCyr_8x16", undef, "koi8-r", "koi8-r", "866" ], +"koi8-u" => [ "UniCyr_8x16", undef, "koi8-u", "koi8-u", "866" ], +"georgian-ps" => [ "t_geors", undef, undef, "utf8", undef ], +"koi8-k" => [ "koi8-k", undef, undef, "utf8", undef ], +"cp1251" => [ "UniCyr_8x16", undef, "cp1251", "cp1251", "866" ], +#- Yiddish needs special console driver for text mode [acon] (and gtk support isn't done yet) +#-"cp1255" => [ "iso08.f16", "iso08", "trivial.trans", "cp1255", "862" ], +#- Urdu needs special console driver for text mode [acon] (and gtk support isn't done yet) +#-"cp1256" => [ undef, undef, "trivial.trans", undef, "864" ], #- korean needs special console driver for text mode - "ksc5601" => [ undef, undef, undef, - "euc-kr", "949", "-*-*-*-*-*-*-*-*-*-*-*-*-ksc5601.1987-*" ], +"ksc5601" => [ undef, undef, undef, "euc-kr", "949" ], #- I have no console font for Thai... - "tis620" => [ undef, undef, "trivial.trans", - "tis-620", "874", std2("tis620.2533-1",12) ], -#- "tcvn" => [ "tcvn8x16", undef, "tcvn", -#- undef, undef, std2("tcvn-5712", 13), std2("tcvn-5712", 10) ], - "tcvn" => [ "tcvn8x16", undef, "tcvn", - undef, undef, std2("tcvn-5712", 13), std2("tcvn-5712", 10) ], +"tis620" => [ undef, undef, "trivial.trans", "tis-620", "874" ], +"tcvn" => [ "tcvn8x16", undef, "tcvn", undef, undef ], #- Tamil uses pseudo iso-8859-1 fonts - "tscii" => [ "tamil", undef, "tscii-0", - undef, undef, "-tamil-tscakaram-medium-r-normal--12-120-75-75-p-92-tscii-0" ], - "utf_am" => [ "Agafari-16", undef, undef, - "utf8", undef, "-*-*-*-*-*-*-*-*-*-*-*-*-iso10646-1" ], - "unicode" => [ undef, undef, undef, - "utf8", undef, "-*-*-*-*-*-*-*-*-*-*-*-*-iso10646-1" ], +"tscii" => [ "tamil", undef, "tscii-0", undef, undef ], +"utf_am" => [ "Agafari-16", undef, undef, "utf8", undef ], +"unicode" => [ undef, undef, undef, "utf8", undef ], ); my %bigfonts = ( @@ -348,101 +358,30 @@ my %charset2kde_charset = ( tscii => 'iso8859-1', ); -#- for special cases not handled magically -my %lang2country = ( - ar => 'eg', - be => 'by', - bs => 'bh', - cs => 'cz', - da => 'dk', - el => 'gr', - et => 'ee', - ko => 'kr', - mi => 'nz', - ms => 'my', - nn => 'no', - sl => 'si', - sp => 'sr', - sv => 'se', - ta => 'in', -); - - my @during_install__lang_having_their_LC_CTYPE = qw(ja ko ta); -#-###################################################################################### -#- Functions -#-###################################################################################### + +#- ------------------- sub list { my (%options) = @_; - my @l = @languages; - if ($options{exclude_non_necessary_utf8}) { - my %LANGs_non_utf8 = map { lang2LANG($_) => 1 } grep { !/UTF-8/ } @languages; - @l = grep { !/UTF-8/ || !$LANGs_non_utf8{lang2LANG($_)} } @l; - } + my @l = list_langs(); if ($options{exclude_non_installed_langs}) { - @l = grep { -e "/usr/share/locale/" . lang2LANG($_) . "/LC_CTYPE" } @l; + @l = grep { -e "/usr/share/locale/$_/LC_CTYPE" } @l; } @l; } -sub lang2text { exists $languages{$_[0]} && $languages{$_[0]}[0] } -sub lang2charset { exists $languages{$_[0]} && $languages{$_[0]}[1] } -sub lang2LANG { exists $languages{$_[0]} && $languages{$_[0]}[2] } -sub lang2LANGUAGE { exists $languages{$_[0]} && $languages{$_[0]}[3] } -sub lang2UTF8 { exists $languages{$_[0]} && $languages{$_[0]}[4] } -sub getxim { $xim{$_[0]} } - -sub lang2console_font { - my ($lang) = @_; - my $c = $charsets{lang2charset($lang) || return} or return; + +sub l2console_font { + my ($locale) = @_; + my $c = $charsets{l2charset($locale->{lang}) || return} or return; my ($name, $sfm, $acm) = @$c; - undef $acm if lang2UTF8($lang); + undef $acm if $locale->{utf8}; ($name, $sfm, $acm); } -sub lang2country { - my ($lang, $prefix) = @_; - - my $dir = "$prefix/usr/share/locale/l10n"; - my @countries = grep { -d "$dir/$_" } all($dir); - my %countries; @countries{@countries} = (); - - my $valid_country = sub { - my ($country) = @_; - #- fast & dirty solution to ensure bad entries do not happen - exists $countries{$country} && $country; - }; - - my $country; - if ($country ||= $lang2country{$lang}) { - return $valid_country->($country) ? $country : 'C'; - } - $country ||= $valid_country->(lc($1)) if $lang =~ /([A-Z]+)/; - $country ||= $valid_country->(lc($1)) if lang2LANGUAGE($lang) =~ /([A-Z]+)/; - $country ||= $valid_country->(substr($lang, 0, 2)); - $country ||= find { $valid_country->($_) } map { substr($_, 0, 2) } split(':', lang2LANGUAGE($lang)); - $country || 'C'; -} - - -sub country2lang { - my ($country, $default) = @_; - - my $uc_country = uc $country; - my %country2lang = reverse %lang2country; - - my ($lang1, $lang2); - $lang1 ||= $country2lang{$country}; - $lang1 ||= find { /^$country/ } list(); - $lang1 ||= find { /_$uc_country/ } list(); - $lang2 ||= find { int grep { /^$country/ } split(':', lang2LANGUAGE($_)) } list(); - $lang2 ||= find { int grep { /_$uc_country/ } split(':', lang2LANGUAGE($_)) } list(); - ($lang1 =~ /UTF-8/ && $lang2 !~ /UTF-8/ ? $lang2 || $lang1 : $lang1 || $lang2) || $default || 'en_US'; -} - -sub lang2kde_lang { - my ($lang, $default) = @_; +sub get_kde_lang { + my ($locale, $default) = @_; #- get it using #- echo C $(rpm -qp --qf "%{name}\n" /RPMS/kde-i18n-* | sed 's/kde-i18n-//') @@ -458,28 +397,11 @@ sub lang2kde_lang { }; my $r; - $r ||= $valid_lang->(lang2LANG($lang)); - $r ||= find { $valid_lang->($_) } split(':', lang2LANGUAGE($lang)); + $r ||= $valid_lang->($locale->{lang}); + $r ||= find { $valid_lang->($_) } split(':', getlocale_for_lang($locale->{lang}, $locale->{country})); $r || $default || 'C'; } -sub kde_lang2lang { - my ($klang, $default) = @_; - (find { /^$klang/ } list()) || $default || 'en_US'; -} - -sub kde_lang_country2lang { - my ($klang, $country, $default) = @_; - my $uc_country = uc $country; - #- country is used to precise the lang - my @choices = grep { /^$klang/ } list(); - my @sorted = - @choices == 2 && length $choices[0] !~ /[._]/ && $choices[1] =~ /UTF-8/ ? @choices : - map { $_->[0] } sort { $b->[1] <=> $a->[1] } map { [ $_ => /_$uc_country/ ] } @choices; - - $sorted[0] || $default || 'en_US'; -} - sub charset2kde_charset { my ($charset, $default) = @_; my $iocharset = ($charsets{$charset} || [])->[3]; @@ -561,122 +483,106 @@ sub charset2pango_font { $charset2pango_font{exists $charset2pango_font{$charset} ? $charset : 'default'}; } -sub lang2pango_font { +sub l2pango_font { my ($lang) = @_; - my $charset = lang2charset($lang) or log::l("no charset found for lang $lang!"), return; + my $charset = l2charset($lang) or log::l("no charset found for lang $lang!"), return; my $font = charset2pango_font($charset); - log::l("charset : $charset ; font : $font"); + log::l("charset: $charset ; font: $font"); return $font; } -sub set { +sub set { my ($lang, $translate_for_console) = @_; - if ($lang && !exists $languages{$lang}) { - #- try to find the best lang - my $lang2 = find { /^\Q$lang/ } list(); #- $lang is not precise enough, choose the first complete - my $lang3 = find { $lang =~ /^\Q$_/ } list(); #- $lang is too precise, choose the first substring matching - log::l("lang::set: fixing $lang with ", $lang2 || $lang3); - $lang = $lang2 || $lang3; - } - - if ($lang && exists $languages{$lang}) { - my ($dir, $LANG) = ("$ENV{SHARE_PATH}/locale", lang2LANG($lang)); - if (! -e "$dir/$LANG" && common::usingRamdisk()) { - @ENV{qw(LANG LC_ALL LANGUAGE LINGUAS)} = (); - - my @LCs = qw(LC_ADDRESS LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME); - - my $charset = during_install__lang2charset($lang) || $LANG; - - #- there are 3 main charsets containing everything for all locales, except LC_CTYPE - #- by default, there is UTF-8. - #- when asked for GB2312 or BIG5, removing the other main charsets - my $main_charset = member($charset, 'GB2312', 'BIG5') ? $charset : 'UTF-8'; - - #- removing everything - #- except in main charset: only removing LC_CTYPE if it is there - eval { rm_rf($_ eq $main_charset ? "$dir/$_/LC_CTYPE" : "$dir/$_") } foreach all($dir); - - if (! -e "$dir/$main_charset") { - #- getting the main charset - mkdir "$dir/$main_charset"; - mkdir "$dir/$main_charset/LC_MESSAGES"; - install_any::getAndSaveFile("$dir/$main_charset/$_") foreach @LCs, 'LC_MESSAGES/SYS_LC_MESSAGES'; - } - mkdir "$dir/$LANG"; - - #- linking to the main charset - symlink "../$main_charset/$_", "$dir/$LANG/$_" foreach @LCs, 'LC_MESSAGES'; - - #- getting LC_CTYPE (putting it directly in $LANG) - install_any::getAndSaveFile("Mandrake/mdkinst$dir/$charset/LC_CTYPE", "$dir/$LANG/LC_CTYPE"); - } - -#- set all LC_* variables to a unique locale ("C"), and only redefine -#- LC_CTYPE (for X11 choosing the fontset) and LANGUAGE (for the po files) - $ENV{$_} = 'C' foreach qw(LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION); - -#- use lang2LANG() to define LC_CTYPE, so DrakX will use a same encoding -#- for all variations of a same language, eg both 'ru_RU.KOI8-R' and -#- 'ru_RU.UTF-8' will be handled the same (as 'ru') by DrakX. -#- that way DrakX only needs a reduced set of locale and fonts support. -#- of course on the installed system they will be different. - $ENV{LC_CTYPE} = lang2LANG($lang); - $ENV{LC_MESSAGES} = lang2LANG($lang); - $ENV{LANG} = lang2LANG($lang); - - if ($translate_for_console && $lang =~ /^(ko|ja|zh|th)/) { - log::l("not translating in console"); - $ENV{LANGUAGE} = 'C'; - } else { - $ENV{LANGUAGE} = lang2LANGUAGE($lang); + exists $langs{$lang} or log::l("lang::set: trying to set to $lang but I don't know it!"), return; + + my $dir = "$ENV{SHARE_PATH}/locale"; + if (!-e "$dir/$lang" && common::usingRamdisk()) { + @ENV{qw(LANG LC_ALL LANGUAGE LINGUAS)} = (); + + my @LCs = qw(LC_ADDRESS LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME); + + my $charset = during_install__l2charset($lang) || $lang; + + #- there are 3 main charsets containing everything for all locales, except LC_CTYPE + #- by default, there is UTF-8. + #- when asked for GB2312 or BIG5, removing the other main charsets + my $main_charset = member($charset, 'GB2312', 'BIG5') ? $charset : 'UTF-8'; + + #- removing everything + #- except in main charset: only removing LC_CTYPE if it is there + eval { rm_rf($_ eq $main_charset ? "$dir/$_/LC_CTYPE" : "$dir/$_") } foreach all($dir); + + if (!-e "$dir/$main_charset") { + #- getting the main charset + mkdir "$dir/$main_charset"; + mkdir "$dir/$main_charset/LC_MESSAGES"; + install_any::getAndSaveFile("$dir/$main_charset/$_") foreach @LCs, 'LC_MESSAGES/SYS_LC_MESSAGES'; } - load_mo(); + mkdir "$dir/$lang"; + + #- linking to the main charset + symlink "../$main_charset/$_", "$dir/$lang/$_" foreach @LCs, 'LC_MESSAGES'; + + #- getting LC_CTYPE (putting it directly in $lang) + install_any::getAndSaveFile("Mandrake/mdkinst$dir/$charset/LC_CTYPE", "$dir/$lang/LC_CTYPE"); + } + + #- set all LC_* variables to a unique locale ("C"), and only redefine + #- LC_CTYPE (for X11 choosing the fontset) and LANGUAGE (for the po files) + $ENV{$_} = 'C' foreach qw(LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION); + + $ENV{LC_CTYPE} = $lang; + $ENV{LC_MESSAGES} = $lang; + $ENV{LANG} = $lang; + + if ($translate_for_console && $lang =~ /^(ko|ja|zh|th)/) { + log::l("not translating in console"); + $ENV{LANGUAGE} = 'C'; } else { - #- stick with the default (English) */ - delete $ENV{LANG}; - delete $ENV{LC_ALL}; - delete $ENV{LANGUAGE}; - delete $ENV{LINGUAS}; + $ENV{LANGUAGE} = getLANGUAGE($lang); } + load_mo(); $lang; } sub langs { my ($l) = @_; - $l->{all} ? list() : grep { $l->{$_} } keys %$l; + $l->{all} ? list_langs() : grep { $l->{$_} } keys %$l; } sub langsLANGUAGE { - my ($l) = @_; - uniq(map { split ':', lang2LANGUAGE($_) } langs($l)); + my ($l, $c) = @_; + uniq(map { split ':', getLANGUAGE($_, $c) } langs($l)); } sub pack_langs { my ($l) = @_; - my $s = $l->{all} ? 'all' : join ':', uniq(map { lang2LANGUAGE($_) } langs($l)); + my $s = $l->{all} ? 'all' : join ':', uniq(map { getLANGUAGE($_) } langs($l)); $ENV{RPM_INSTALL_LANG} = $s; $s; } -sub unpack_langs { - my ($s) = @_; - my @l = uniq(map { split ':', lang2LANGUAGE($_) } split(':', $s)); - my @l2 = intersection(\@l, [ keys %languages ]); - +{ map { $_ => 1 } @l2 }; -} - sub read { my ($prefix, $user_only) = @_; my ($f1, $f2) = ("$prefix$ENV{HOME}/.i18n", "$prefix/etc/sysconfig/i18n"); my %h = getVarsFromSh($user_only && -e $f1 ? $f1 : $f2); - my $lang = $h{LC_MESSAGES} || 'en_US'; - $lang = bestMatchSentence($lang, list()) if !exists $languages{$lang}; - my $langs = $user_only ? () : - cat_("$prefix/etc/rpm/macros") =~ /%_install_langs (.*)/ ? unpack_langs($1) : { $lang => 1 }; - $lang, $langs; + my $locale; + my $locale_lang = $h{LC_MESSAGES} || 'en_US'; + my $locale_country = $h{LC_MONETARY} || 'en_US'; + if (member($locale_lang, list_langs())) { + #- special lang's such as en_US pt_BR + $locale->{lang} = $locale_lang; + } else { + ($locale->{lang}) = $locale_lang =~ /^(..)/; + } + ($locale->{country}) = $locale_country =~ /^.._(..)/; + $locale->{utf8} = $locale_lang =~ /UTF-8/; + #- safe fallbacks + $locale->{lang} ||= 'en_US'; + $locale->{country} ||= 'US'; + $locale; } sub write_langs { @@ -687,51 +593,55 @@ sub write_langs { } sub write { - my ($prefix, $lang, $user_only, $dont_touch_kde_files) = @_; + my ($prefix, $locale, $user_only, $dont_touch_kde_files) = @_; + + $locale && $locale->{lang} or return; - $lang or return; + $locale->{utf8} ||= l2charset($locale->{lang}) =~ /utf|unicode/ + || any { l2charset($_) ne l2charset($locale->{lang}) } langs($locale->{langs}); + my $locale_lang = getlocale_for_lang($locale->{lang}, $locale->{country}, $locale->{utf8}); + my $locale_country = getlocale_for_country($locale->{lang}, $locale->{country}, $locale->{utf8}); my $h = { XKB_IN_USE => '', - (map { $_ => $lang } qw(LC_COLLATE LC_CTYPE LC_MESSAGES LC_NUMERIC LC_MONETARY LC_TIME)), + (map { $_ => $locale_lang } qw(LANG LC_COLLATE LC_CTYPE LC_MESSAGES LC_TIME)), + LANGUAGE => getLANGUAGE($locale->{lang}, $locale->{country}, $locale->{utf8}), + (map { $_ => $locale_country } qw(LC_NUMERIC LC_MONETARY LC_ADDRESS LC_MEASUREMENT LC_MONETARY LC_NAME LC_PAPER LC_IDENTIFICATION LC_TELEPHONE)) }; - if ($lang && exists $languages{$lang}) { -##- note: KDE is unable to use the keyboard if LC_* and LANG values differ... -#- add2hash $h, { LANG => lang2LANG($lang), LANGUAGE => lang2LANGUAGE($lang) }; - add2hash $h, { LANG => $lang, LANGUAGE => lang2LANGUAGE($lang) }; - - my ($name, $sfm, $acm) = lang2console_font($lang); - if ($name && !$user_only) { - my $p = "$prefix/usr/lib/kbd"; - if ($name) { - eval { - cp_af("$p/consolefonts/$name.psf.gz", "$prefix/etc/sysconfig/console/consolefonts"); - add2hash $h, { SYSFONT => $name }; - }; - $@ and log::l("missing console font $name"); - } - if ($sfm) { - eval { - cp_af(glob_("$p/consoletrans/$sfm*"), "$prefix/etc/sysconfig/console/consoletrans"); - add2hash $h, { UNIMAP => $sfm }; - }; - $@ and log::l("missing console unimap file $sfm"); - } - if ($acm) { - eval { - cp_af(glob_("$p/consoletrans/$acm*"), "$prefix/etc/sysconfig/console/consoletrans"); - add2hash $h, { SYSFONTACM => $acm }; - }; - $@ and log::l("missing console acm file $acm"); - } - + log::l("lang::write: lang:$locale->{lang} country:$locale->{country} locale|lang:$locale_lang locale|country:$locale_country language:$h->{LANGUAGE}"); + + my ($name, $sfm, $acm) = l2console_font($locale); + if ($name && !$user_only) { + my $p = "$prefix/usr/lib/kbd"; + if ($name) { + eval { + cp_af("$p/consolefonts/$name.psf.gz", "$prefix/etc/sysconfig/console/consolefonts"); + add2hash $h, { SYSFONT => $name }; + }; + $@ and log::l("missing console font $name"); } - add2hash $h, $xim{$lang}; + if ($sfm) { + eval { + cp_af(glob_("$p/consoletrans/$sfm*"), "$prefix/etc/sysconfig/console/consoletrans"); + add2hash $h, { UNIMAP => $sfm }; + }; + $@ and log::l("missing console unimap file $sfm"); + } + if ($acm) { + eval { + cp_af(glob_("$p/consoletrans/$acm*"), "$prefix/etc/sysconfig/console/consoletrans"); + add2hash $h, { SYSFONTACM => $acm }; + }; + $@ and log::l("missing console acm file $acm"); + } + } + add2hash $h, $xim{$locale_lang}; + setVarsInSh($prefix . ($user_only ? "$ENV{HOME}/.i18n" : '/etc/sysconfig/i18n'), $h); eval { - my $charset = lang2charset($lang); + my $charset = l2charset($locale->{lang}); my $confdir = $prefix . ($user_only ? "$ENV{HOME}/.kde" : '/usr') . '/share/config'; my ($prev_kde_charset) = cat_("$confdir/kdeglobals") =~ /^Charset=(.*)/mi; @@ -739,8 +649,8 @@ sub write { update_gnomekderc("$confdir/kdeglobals", Locale => ( Charset => charset2kde_charset($charset), - Country => lang2country($lang, $prefix), - Language => lang2kde_lang($lang), + Country => lc($locale->{country}), + Language => get_kde_lang($locale), )); if ($prev_kde_charset ne charset2kde_charset($charset)) { @@ -810,8 +720,8 @@ sub console_font_files { } sub load_console_font { - my ($lang) = @_; - my ($name, $sfm, $acm) = lang2console_font($lang); + my ($locale) = @_; + my ($name, $sfm, $acm) = l2console_font($locale); require run_program; run_program::run(if_($ENV{LD_LOADER}, $ENV{LD_LOADER}), @@ -821,35 +731,17 @@ sub load_console_font { #- in console mode install, ensure we'll get translations in the right codeset #- (charset of locales reported by the glibc are UTF-8 during install) if ($acm) { - c::bind_textdomain_codeset('libDrakX', lang2charset($lang)); + c::bind_textdomain_codeset('libDrakX', l2charset($locale->{lang})); $::need_utf8_i18n = 0; } } -sub get_x_fontset { - my ($lang, $size) = @_; - - my $charset = lang2charset($lang) or return; - my $c = $charsets{$charset} or return; - if (my $f = $bigfonts{$charset}) { - my $dir = "/usr/X11R6/lib/X11/fonts"; - if (! -e "$dir/$f" && $::isInstall && common::usingRamdisk()) { - unlink "$dir/$_" foreach values %bigfonts; - install_any::remove_bigseldom_used(); - install_any::getAndSaveFile("$dir/$f"); - } - } - my ($big, $small) = @$c[5..6]; - ($big, $small) = $big->($size) if ref $big; - ($big, $small); -} - sub fs_options { - my ($lang) = @_; - if (lang2UTF8($lang)) { + my ($locale) = @_; + if ($locale->{utf8}) { ('utf8', undef); } else { - my $c = $charsets{lang2charset($lang) || return} or return; + my $c = $charsets{l2charset($locale->{lang}) || return} or return; my ($iocharset, $codepage) = @$c[3..4]; $iocharset, $codepage; } @@ -864,11 +756,11 @@ sub charset { $l =~ /.*\.(\S+)/ and return $1; } -sub during_install__lang2charset { +sub during_install__l2charset { my ($lang) = @_; - return if member(lang2LANG($lang), @during_install__lang_having_their_LC_CTYPE); + return if member($lang, @during_install__lang_having_their_LC_CTYPE); - my ($c) = lang2charset($lang) or die "bad lang $lang\n"; + my ($c) = l2charset($lang) or die "bad lang $lang\n"; $c = 'UTF-8' if member($c, 'tis620', 'C'); $c = 'UTF-8' if $c =~ /koi8-/; $c = 'UTF-8' if $c =~ /iso-8859/; @@ -877,6 +769,7 @@ sub during_install__lang2charset { uc($c); } + sub check { $^W = 0; my $ok = 1; @@ -888,12 +781,12 @@ sub check { $ok = 0; }; - my @wanted_charsets = uniq map { lang2charset($_) } list(); + my @wanted_charsets = uniq map { l2charset($_) } list_langs(); $err->("invalid charset $_ ($_ does not exist in \%charsets)") foreach difference2(\@wanted_charsets, [ keys %charsets ]); $err->("invalid charset $_ in \%charset2kde_font ($_ does not exist in \%charsets)") foreach difference2([ keys %charset2kde_font ], [ 'default', keys %charsets ]); - $warn->("unused charset $_ (given in \%charsets, but not used in \%languages)") foreach difference2([ keys %charsets ], \@wanted_charsets); + $warn->("unused charset $_ (given in \%charsets, but not used in \%langs)") foreach difference2([ keys %charsets ], \@wanted_charsets); - $warn->("unused entry $_ in \%xim") foreach difference2([ keys %xim ], [ list() ]); + $warn->("unused entry $_ in \%xim") foreach grep { !/UTF-8/ } difference2([ keys %xim ], [ map { l2locale($_) } list_langs() ]); #- consolefonts are checked during build via console_font_files() @@ -901,15 +794,22 @@ sub check { $warn->("no kde font for charset " . join(" ", @l)); } - if (my @l = grep { lang2country($_) eq 'C' } list()) { - $warn->("no country for langs " . join(" ", @l)); - } - if (my @l = grep { lang2kde_lang($_, 'err') eq 'err' } list()) { + if (my @l = grep { get_kde_lang({ lang => $_, country => 'US' }, 'err') eq 'err' } list_langs()) { $warn->("no KDE lang for langs " . join(" ", @l)); } if (my @l = grep { charset2kde_charset($_, 'err') eq 'err' } keys %charsets) { $warn->("no KDE charset for charsets " . join(" ", @l)); } + + $err->("default locale $_->[1] of lang $_->[0] isn't listed in \@locales") + foreach grep { !member($_->[1], @locales) } map { [ $_, l2locale($_) ] } list_langs(); + + $err->("default locale $_->[1] of country $_->[0] isn't listed in \@locales") + foreach grep { !member($_->[1], @locales) } map { [ $_, c2locale($_) ] } list_countries(); + + $warn->("no country corresponding to default locale $_->[1] of lang $_->[0]") + foreach grep { $_->[1] =~ /^.._(..)/ && !exists $countries{$1} } map { [ $_, l2locale($_) ] } list_langs(); + exit($ok ? 0 : 1); } diff --git a/perl-install/pixmaps/langs/lang-af.png b/perl-install/pixmaps/langs/lang-af.png Binary files differnew file mode 100644 index 000000000..9db00aee9 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-af.png diff --git a/perl-install/pixmaps/langs/lang-am.png b/perl-install/pixmaps/langs/lang-am.png Binary files differnew file mode 100644 index 000000000..7058c97c8 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-am.png diff --git a/perl-install/pixmaps/langs/lang-ar.png b/perl-install/pixmaps/langs/lang-ar.png Binary files differnew file mode 100644 index 000000000..9dd1208be --- /dev/null +++ b/perl-install/pixmaps/langs/lang-ar.png diff --git a/perl-install/pixmaps/langs/lang-az.png b/perl-install/pixmaps/langs/lang-az.png Binary files differnew file mode 100644 index 000000000..c471a111a --- /dev/null +++ b/perl-install/pixmaps/langs/lang-az.png diff --git a/perl-install/pixmaps/langs/lang-be.png b/perl-install/pixmaps/langs/lang-be.png Binary files differnew file mode 100644 index 000000000..f08fd6628 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-be.png diff --git a/perl-install/pixmaps/langs/lang-bg.png b/perl-install/pixmaps/langs/lang-bg.png Binary files differnew file mode 100644 index 000000000..bb8fe57c6 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-bg.png diff --git a/perl-install/pixmaps/langs/lang-br.png b/perl-install/pixmaps/langs/lang-br.png Binary files differnew file mode 100644 index 000000000..a8041f390 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-br.png diff --git a/perl-install/pixmaps/langs/lang-bs.png b/perl-install/pixmaps/langs/lang-bs.png Binary files differnew file mode 100644 index 000000000..78cae5f50 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-bs.png diff --git a/perl-install/pixmaps/langs/lang-ca.png b/perl-install/pixmaps/langs/lang-ca.png Binary files differnew file mode 100644 index 000000000..a007d7408 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-ca.png diff --git a/perl-install/pixmaps/langs/lang-cs.png b/perl-install/pixmaps/langs/lang-cs.png Binary files differnew file mode 100644 index 000000000..5353a5979 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-cs.png diff --git a/perl-install/pixmaps/langs/lang-cy.png b/perl-install/pixmaps/langs/lang-cy.png Binary files differnew file mode 100644 index 000000000..463c7239f --- /dev/null +++ b/perl-install/pixmaps/langs/lang-cy.png diff --git a/perl-install/pixmaps/langs/lang-da.png b/perl-install/pixmaps/langs/lang-da.png Binary files differnew file mode 100644 index 000000000..682d77f24 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-da.png diff --git a/perl-install/pixmaps/langs/lang-de.png b/perl-install/pixmaps/langs/lang-de.png Binary files differnew file mode 100644 index 000000000..2268d3c75 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-de.png diff --git a/perl-install/pixmaps/langs/lang-el.png b/perl-install/pixmaps/langs/lang-el.png Binary files differnew file mode 100644 index 000000000..00a6f393f --- /dev/null +++ b/perl-install/pixmaps/langs/lang-el.png diff --git a/perl-install/pixmaps/langs/lang-en_GB.png b/perl-install/pixmaps/langs/lang-en_GB.png Binary files differnew file mode 100644 index 000000000..405afb798 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-en_GB.png diff --git a/perl-install/pixmaps/langs/lang-en_US.png b/perl-install/pixmaps/langs/lang-en_US.png Binary files differnew file mode 100644 index 000000000..bc1e1e5f1 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-en_US.png diff --git a/perl-install/pixmaps/langs/lang-eo.png b/perl-install/pixmaps/langs/lang-eo.png Binary files differnew file mode 100644 index 000000000..92427a024 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-eo.png diff --git a/perl-install/pixmaps/langs/lang-es.png b/perl-install/pixmaps/langs/lang-es.png Binary files differnew file mode 100644 index 000000000..bdc6f12b1 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-es.png diff --git a/perl-install/pixmaps/langs/lang-et.png b/perl-install/pixmaps/langs/lang-et.png Binary files differnew file mode 100644 index 000000000..39f56ab49 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-et.png diff --git a/perl-install/pixmaps/langs/lang-eu.png b/perl-install/pixmaps/langs/lang-eu.png Binary files differnew file mode 100644 index 000000000..2a9441330 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-eu.png diff --git a/perl-install/pixmaps/langs/lang-fa.png b/perl-install/pixmaps/langs/lang-fa.png Binary files differnew file mode 100644 index 000000000..1d69edadb --- /dev/null +++ b/perl-install/pixmaps/langs/lang-fa.png diff --git a/perl-install/pixmaps/langs/lang-fi.png b/perl-install/pixmaps/langs/lang-fi.png Binary files differnew file mode 100644 index 000000000..749c356a5 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-fi.png diff --git a/perl-install/pixmaps/langs/lang-fo.png b/perl-install/pixmaps/langs/lang-fo.png Binary files differnew file mode 100644 index 000000000..0e3865a2d --- /dev/null +++ b/perl-install/pixmaps/langs/lang-fo.png diff --git a/perl-install/pixmaps/langs/lang-fr.png b/perl-install/pixmaps/langs/lang-fr.png Binary files differnew file mode 100644 index 000000000..60b9ec4b1 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-fr.png diff --git a/perl-install/pixmaps/langs/lang-ga.png b/perl-install/pixmaps/langs/lang-ga.png Binary files differnew file mode 100644 index 000000000..dec7b44f9 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-ga.png diff --git a/perl-install/pixmaps/langs/lang-gd.png b/perl-install/pixmaps/langs/lang-gd.png Binary files differnew file mode 100644 index 000000000..51eb7226e --- /dev/null +++ b/perl-install/pixmaps/langs/lang-gd.png diff --git a/perl-install/pixmaps/langs/lang-gl.png b/perl-install/pixmaps/langs/lang-gl.png Binary files differnew file mode 100644 index 000000000..ebeb4c3f6 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-gl.png diff --git a/perl-install/pixmaps/langs/lang-gv.png b/perl-install/pixmaps/langs/lang-gv.png Binary files differnew file mode 100644 index 000000000..073beb503 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-gv.png diff --git a/perl-install/pixmaps/langs/lang-he.png b/perl-install/pixmaps/langs/lang-he.png Binary files differnew file mode 100644 index 000000000..7f3ff2725 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-he.png diff --git a/perl-install/pixmaps/langs/lang-hr.png b/perl-install/pixmaps/langs/lang-hr.png Binary files differnew file mode 100644 index 000000000..77e40aa47 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-hr.png diff --git a/perl-install/pixmaps/langs/lang-hu.png b/perl-install/pixmaps/langs/lang-hu.png Binary files differnew file mode 100644 index 000000000..ad8b03e67 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-hu.png diff --git a/perl-install/pixmaps/langs/lang-hy.png b/perl-install/pixmaps/langs/lang-hy.png Binary files differnew file mode 100644 index 000000000..e149de3b5 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-hy.png diff --git a/perl-install/pixmaps/langs/lang-ia.png b/perl-install/pixmaps/langs/lang-ia.png Binary files differnew file mode 100644 index 000000000..b815a9b9d --- /dev/null +++ b/perl-install/pixmaps/langs/lang-ia.png diff --git a/perl-install/pixmaps/langs/lang-id.png b/perl-install/pixmaps/langs/lang-id.png Binary files differnew file mode 100644 index 000000000..ee316f775 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-id.png diff --git a/perl-install/pixmaps/langs/lang-is.png b/perl-install/pixmaps/langs/lang-is.png Binary files differnew file mode 100644 index 000000000..4e3eda691 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-is.png diff --git a/perl-install/pixmaps/langs/lang-it.png b/perl-install/pixmaps/langs/lang-it.png Binary files differnew file mode 100644 index 000000000..5ea98d3de --- /dev/null +++ b/perl-install/pixmaps/langs/lang-it.png diff --git a/perl-install/pixmaps/langs/lang-iu.png b/perl-install/pixmaps/langs/lang-iu.png Binary files differnew file mode 100644 index 000000000..a5dbb3f36 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-iu.png diff --git a/perl-install/pixmaps/langs/lang-ja.png b/perl-install/pixmaps/langs/lang-ja.png Binary files differnew file mode 100644 index 000000000..014e59d23 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-ja.png diff --git a/perl-install/pixmaps/langs/lang-ka.png b/perl-install/pixmaps/langs/lang-ka.png Binary files differnew file mode 100644 index 000000000..fca927d51 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-ka.png diff --git a/perl-install/pixmaps/langs/lang-ko.png b/perl-install/pixmaps/langs/lang-ko.png Binary files differnew file mode 100644 index 000000000..c2816d2c4 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-ko.png diff --git a/perl-install/pixmaps/langs/lang-kw.png b/perl-install/pixmaps/langs/lang-kw.png Binary files differnew file mode 100644 index 000000000..3deecbc8d --- /dev/null +++ b/perl-install/pixmaps/langs/lang-kw.png diff --git a/perl-install/pixmaps/langs/lang-lt.png b/perl-install/pixmaps/langs/lang-lt.png Binary files differnew file mode 100644 index 000000000..59a747168 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-lt.png diff --git a/perl-install/pixmaps/langs/lang-lv.png b/perl-install/pixmaps/langs/lang-lv.png Binary files differnew file mode 100644 index 000000000..1d5f9a87c --- /dev/null +++ b/perl-install/pixmaps/langs/lang-lv.png diff --git a/perl-install/pixmaps/langs/lang-mi.png b/perl-install/pixmaps/langs/lang-mi.png Binary files differnew file mode 100644 index 000000000..3c45485cc --- /dev/null +++ b/perl-install/pixmaps/langs/lang-mi.png diff --git a/perl-install/pixmaps/langs/lang-mk.png b/perl-install/pixmaps/langs/lang-mk.png Binary files differnew file mode 100644 index 000000000..fb996a90d --- /dev/null +++ b/perl-install/pixmaps/langs/lang-mk.png diff --git a/perl-install/pixmaps/langs/lang-ms.png b/perl-install/pixmaps/langs/lang-ms.png Binary files differnew file mode 100644 index 000000000..ad23dfd28 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-ms.png diff --git a/perl-install/pixmaps/langs/lang-mt.png b/perl-install/pixmaps/langs/lang-mt.png Binary files differnew file mode 100644 index 000000000..0c08457d7 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-mt.png diff --git a/perl-install/pixmaps/langs/lang-nb.png b/perl-install/pixmaps/langs/lang-nb.png Binary files differnew file mode 100644 index 000000000..75b748cd9 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-nb.png diff --git a/perl-install/pixmaps/langs/lang-nl.png b/perl-install/pixmaps/langs/lang-nl.png Binary files differnew file mode 100644 index 000000000..00c37870a --- /dev/null +++ b/perl-install/pixmaps/langs/lang-nl.png diff --git a/perl-install/pixmaps/langs/lang-nn.png b/perl-install/pixmaps/langs/lang-nn.png Binary files differnew file mode 100644 index 000000000..8163a6efc --- /dev/null +++ b/perl-install/pixmaps/langs/lang-nn.png diff --git a/perl-install/pixmaps/langs/lang-oc.png b/perl-install/pixmaps/langs/lang-oc.png Binary files differnew file mode 100644 index 000000000..f98177f37 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-oc.png diff --git a/perl-install/pixmaps/langs/lang-pl.png b/perl-install/pixmaps/langs/lang-pl.png Binary files differnew file mode 100644 index 000000000..866acb80c --- /dev/null +++ b/perl-install/pixmaps/langs/lang-pl.png diff --git a/perl-install/pixmaps/langs/lang-pt.png b/perl-install/pixmaps/langs/lang-pt.png Binary files differnew file mode 100644 index 000000000..356315ea4 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-pt.png diff --git a/perl-install/pixmaps/langs/lang-pt_BR.png b/perl-install/pixmaps/langs/lang-pt_BR.png Binary files differnew file mode 100644 index 000000000..51d657be6 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-pt_BR.png diff --git a/perl-install/pixmaps/langs/lang-ro.png b/perl-install/pixmaps/langs/lang-ro.png Binary files differnew file mode 100644 index 000000000..4940abfc3 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-ro.png diff --git a/perl-install/pixmaps/langs/lang-ru.png b/perl-install/pixmaps/langs/lang-ru.png Binary files differnew file mode 100644 index 000000000..28317c4d0 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-ru.png diff --git a/perl-install/pixmaps/langs/lang-sk.png b/perl-install/pixmaps/langs/lang-sk.png Binary files differnew file mode 100644 index 000000000..4dfa57555 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-sk.png diff --git a/perl-install/pixmaps/langs/lang-sl.png b/perl-install/pixmaps/langs/lang-sl.png Binary files differnew file mode 100644 index 000000000..1a21606e7 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-sl.png diff --git a/perl-install/pixmaps/langs/lang-sp.png b/perl-install/pixmaps/langs/lang-sp.png Binary files differnew file mode 100644 index 000000000..a4b1b8748 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-sp.png diff --git a/perl-install/pixmaps/langs/lang-sq.png b/perl-install/pixmaps/langs/lang-sq.png Binary files differnew file mode 100644 index 000000000..f086ecdb5 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-sq.png diff --git a/perl-install/pixmaps/langs/lang-sr.png b/perl-install/pixmaps/langs/lang-sr.png Binary files differnew file mode 100644 index 000000000..63e344713 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-sr.png diff --git a/perl-install/pixmaps/langs/lang-sv.png b/perl-install/pixmaps/langs/lang-sv.png Binary files differnew file mode 100644 index 000000000..dacb8e83b --- /dev/null +++ b/perl-install/pixmaps/langs/lang-sv.png diff --git a/perl-install/pixmaps/langs/lang-ta.png b/perl-install/pixmaps/langs/lang-ta.png Binary files differnew file mode 100644 index 000000000..84b02b624 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-ta.png diff --git a/perl-install/pixmaps/langs/lang-tg.png b/perl-install/pixmaps/langs/lang-tg.png Binary files differnew file mode 100644 index 000000000..42ec339a0 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-tg.png diff --git a/perl-install/pixmaps/langs/lang-th.png b/perl-install/pixmaps/langs/lang-th.png Binary files differnew file mode 100644 index 000000000..babc76782 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-th.png diff --git a/perl-install/pixmaps/langs/lang-tr.png b/perl-install/pixmaps/langs/lang-tr.png Binary files differnew file mode 100644 index 000000000..42d4630c4 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-tr.png diff --git a/perl-install/pixmaps/langs/lang-tt.png b/perl-install/pixmaps/langs/lang-tt.png Binary files differnew file mode 100644 index 000000000..220acc859 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-tt.png diff --git a/perl-install/pixmaps/langs/lang-uk.png b/perl-install/pixmaps/langs/lang-uk.png Binary files differnew file mode 100644 index 000000000..d4be71704 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-uk.png diff --git a/perl-install/pixmaps/langs/lang-ur.png b/perl-install/pixmaps/langs/lang-ur.png Binary files differnew file mode 100644 index 000000000..5e6af00b5 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-ur.png diff --git a/perl-install/pixmaps/langs/lang-uz.png b/perl-install/pixmaps/langs/lang-uz.png Binary files differnew file mode 100644 index 000000000..5aba91b41 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-uz.png diff --git a/perl-install/pixmaps/langs/lang-vi.png b/perl-install/pixmaps/langs/lang-vi.png Binary files differnew file mode 100644 index 000000000..2f8fc9d7b --- /dev/null +++ b/perl-install/pixmaps/langs/lang-vi.png diff --git a/perl-install/pixmaps/langs/lang-wa.png b/perl-install/pixmaps/langs/lang-wa.png Binary files differnew file mode 100644 index 000000000..26b134176 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-wa.png diff --git a/perl-install/pixmaps/langs/lang-yi.png b/perl-install/pixmaps/langs/lang-yi.png Binary files differnew file mode 100644 index 000000000..27d99e6b6 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-yi.png diff --git a/perl-install/pixmaps/langs/lang-zh_CN.png b/perl-install/pixmaps/langs/lang-zh_CN.png Binary files differnew file mode 100644 index 000000000..21b93104b --- /dev/null +++ b/perl-install/pixmaps/langs/lang-zh_CN.png diff --git a/perl-install/pixmaps/langs/lang-zh_TW.png b/perl-install/pixmaps/langs/lang-zh_TW.png Binary files differnew file mode 100644 index 000000000..6f1b85500 --- /dev/null +++ b/perl-install/pixmaps/langs/lang-zh_TW.png diff --git a/perl-install/standalone/drakhelp b/perl-install/standalone/drakhelp index a6da9f497..a3a0a9653 100644 --- a/perl-install/standalone/drakhelp +++ b/perl-install/standalone/drakhelp @@ -15,11 +15,11 @@ die "Usage: drakhelp <help_path>" if @ARGV != 1; my $in = interactive->vnew; -my $lang = lang::lang2LANG(lang::read('',$>)) || 'en'; -if (!member($lang, qw(de en es fr it ru))) { $lang = 'en' }; -my $path_to_help = "/usr/share/doc/mandrake/" . $lang . "/"; +my $locale = lang::read('', $>); +if (!member($locale->{lang}, qw(de en es fr it ru))) { $locale->{lang} = 'en' }; +my $path_to_help = "/usr/share/doc/mandrake/" . $locale->{lang} . "/"; --d $path_to_help or $in->do_pkgs->install('mandrake_doc-drakxtools-' . $lang); +-d $path_to_help or $in->do_pkgs->install('mandrake_doc-drakxtools-' . $locale->{lang}); if ((my $wm = any::running_window_manager()) eq 'kwin') { system("mdklaunchhelp " . $path_to_help . $ARGV[0] . "&"); diff --git a/perl-install/standalone/drakxtv b/perl-install/standalone/drakxtv index d373b6e05..515af17a9 100755 --- a/perl-install/standalone/drakxtv +++ b/perl-install/standalone/drakxtv @@ -71,33 +71,32 @@ You can install it by typing \"urpmi xawtv\" as root, in a console."))); ); # Info: HRC means "Harmonically Related Carrier" - # default to pal since most people use that - $norm = "PAL"; my %countries = ( - "ar" => [ "argentina" ], - "au" => [ "australia" ], - "(br|fr)" => ["france", "SECAM"], - "ca" => [ "canada-cable" ], - "(ga|ie)" => [ "ireland" ], - "it" => [ "italy" ], - "jp" => [ "japan-bcast", "NTSC-JP" ], - "nz" => [ "newzealand" ], - "(at|be|ch|de|eu|gb|se)" => [ "europe-west" ], - "us" => [ "us-bcast", "NTSC" ], - "za" => [ "southafrica" ], - "(zh|TW|Big5|CN.GB2312|CN)" => [ "china-bcast" ] + "AR" => [ "argentina" ], + "AU" => [ "australia" ], + "FR" => [ "france", "SECAM"], + "CA" => [ "canada-cable" ], + "IE" => [ "ireland" ], + "IT" => [ "italy" ], + "JP" => [ "japan-bcast", "NTSC-JP" ], + "NZ" => [ "newzealand" ], + "AT|BE|CH|DE|ES|GB|SE" => [ "europe-west" ], + "US" => [ "us-bcast", "NTSC" ], + "ZA" => [ "southafrica" ], + "CN|TW" => [ "china-bcast" ] ); - ($_) = lang::read('', $>); - foreach my $i (keys %countries) { - if (/($i|$i.UTF-8)$/i) { - my $tbl = $countries{$i}; - $ftable_id = $tbl->[0]; - $norm = $tbl->[1] if $tbl->[1]; - } + my $tbl; + my $locale = lang::read('', $>); + $locale->{country} =~ /$_/ and $tbl = $countries{$_} foreach keys %countries; + if ($tbl) { + $ftable_id = $tbl->[0]; + $norm = $tbl->[1] if $tbl->[1]; } - log::l("[drakxtv] guess lang=>$_, norm=>$norm, area=>$ftable_id"); + # default to pal since most people use that + $norm ||= "PAL"; + log::l("[drakxtv] guess country=>$locale->{country}, norm=>$norm, area=>$ftable_id"); if ($in->ask_from("TVdrake", N("Please,\ntype in your tv norm and country"), [ diff --git a/perl-install/standalone/localedrake b/perl-install/standalone/localedrake index 13b18027b..66bcc05bf 100644 --- a/perl-install/standalone/localedrake +++ b/perl-install/standalone/localedrake @@ -14,28 +14,33 @@ my ($klang, $country, $apply); foreach (@ARGV) { $apply = /--apply/; $klang = $1 if /--kde_lang=(.*)/; - $country = $1 if /--kde_country=(.*)/; + $kcountry = uc($1) if /--kde_country=(.*)/; } if (defined $klang) { $klang or exit; - my $lang = lang::kde_lang_country2lang($klang, $country); - lang::write('', $lang, $>, 'dont_touch_kde_files') if $apply; + my $lang = member($klang, lang::list_langs()) ? $klang : 'en_US'; + my $country = member($kcountry, lang::list_countries()) ? $kcountry : 'US'; + my $locale = lang::read('', $>); + $klang and $locale->{lang} = $lang; + $kcountry and $locale->{country} = $country; + lang::write('', $locale, $>, 'dont_touch_kde_files') if $apply; #- help KDE defaulting to the right charset - print lang::charset2kde_charset(lang::lang2charset($lang)), "\n"; + print lang::charset2kde_charset(lang::l2charset($lang)), "\n"; } else { - my ($lang) = lang::read('', $>); - + my $locale = lang::read('', $>); my $in = 'interactive'->vnew; - if ($lang = any::selectLanguage($in, $lang)) { - lang::write('', $lang, $>); - if ($>) { - if (my $wm = any::running_window_manager()) { - $in->ask_okcancel('', N("The change is done, but to be effective you must logout"), 1) - && any::ask_window_manager_to_logout($wm); - } + select_language: + $locale->{lang} = any::selectLanguage($in, $locale->{lang}) or goto the_end; + any::selectCountry($in, $locale) or goto select_language; + lang::write('', $locale, $>); + if ($>) { + if (my $wm = any::running_window_manager()) { + $in->ask_okcancel('', N("The change is done, but to be effective you must logout"), 1) + and any::ask_window_manager_to_logout($wm); } } +the_end: $in->exit(0); } diff --git a/perl-install/timezone.pm b/perl-install/timezone.pm index e82d6cca5..7fb5303d3 100644 --- a/perl-install/timezone.pm +++ b/perl-install/timezone.pm @@ -9,6 +9,7 @@ use log; sub getTimeZones { my ($prefix) = @_; + $::testing and $prefix = ''; open(my $F, "cd $prefix/usr/share/zoneinfo && find [A-Z]* -type f |"); my @l = chomp_(<$F>); close $F or die "cannot list the available zoneinfos"; @@ -55,85 +56,75 @@ sub write { }); } -my %l2t = ( -'Afrikaans (South Africa)' => 'Africa/Johannesburg', -'Arabic' => 'Africa/Cairo', -'Armenian (Armenia)' => 'Asia/Yerevan', -'Azeri (Azerbaijan)' => 'Asia/Baku', -'Belarussian (Belarus)' => 'Europe/Minsk', -'Bosnian (Bosnia)' => 'Europe/Sarajevo', -'Brezhoneg (Brittany)' => 'Europe/Paris', -'Bulgarian (Bulgaria)' => 'Europe/Sofia', -'Catalan' => 'Europe/Madrid', -'Chinese Traditional (Taiwan)' => 'Asia/Taipei', -'Chinese Simplified (China)' => 'Asia/Beijing', -'Croatian (Bosnia)' => 'Europe/Sarajevo', -'Croatian (Croatia)' => 'Europe/Zagreb', -'Cymraeg (Welsh)' => 'Europe/London', -'Czech' => 'Europe/Prague', -'Danish (Denmark)' => 'Europe/Copenhagen', -'Dutch (Netherlands)' => 'Europe/Amsterdam', -'English (United States)' => 'America/New_York', -'English (United Kingdom)' => 'Europe/London', -'Esperanto' => 'Europe/Warsaw', -'Estonian (Estonia)' => 'Europe/Tallinn', -'Euskara (Basque)' => 'Europe/Madrid', -'Finnish (Finland)' => 'Europe/Helsinki', -'French (France)' => 'Europe/Paris', -'French (Belgium)' => 'Europe/Brussels', -'French (Canada)' => 'Canada/Atlantic', # or Newfoundland ? or Eastern ? -'Gaeilge (Ireland)' => 'Europe/Dublin', -'Galego' => 'Europe/Madrid', -'Georgian (Georgia)' => 'Asia/Yerevan', -'German (Austria)' => 'Europe/Vienna', -'German (Germany)' => 'Europe/Berlin', -'Greek (Greece)' => 'Europe/Athens', -'Greenlandic' => 'Arctic/Longyearbyen', -'Hebrew (Israel)' => 'Asia/Tel_Aviv', -'Hungarian (Hungary)' => 'Europe/Budapest', -'Icelandic (Iceland)' => 'Atlantic/Reykjavik', -'Indonesian (Indonesia)' => 'Asia/Jakarta', -'Iranian (Iran)' => 'Asia/Tehran', -'Italian (Italy)' => 'Europe/Rome', -#-'Italian (San Marino)' => 'Europe/San_Marino', -#-'Italian (Vatican)' => 'Europe/Vatican', -#-'Italian (Switzerland)' => 'Europe/Zurich', -'Japanese (Japon)' => 'Asia/Tokyo', -'Korean (Korea)' => 'Asia/Seoul', -'Latvian (Latvia)' => 'Europe/Riga', -'Lithuanian (Lithuania)' => 'Europe/Vilnius', -'Macedonian (Macedonia)' => 'Europe/Skopje', -'Maori (New Zealand)' => 'Australia/Sydney', -'Norwegian (Bokmaal)' => 'Europe/Oslo', -'Norwegian (Nynorsk)' => 'Europe/Oslo', -'Polish (Poland)' => 'Europe/Warsaw', -'Portuguese (Brazil)' => 'Brazil/East', # most people live on the east coast -'Portuguese (Portugal)' => 'Europe/Lisbon', -'Romanian (Rumania)' => 'Europe/Bucharest', -'Russian (Russia)' => 'Europe/Moscow', -'Serbian (Serbia)' => 'Europe/Belgrade', -'Slovak (Slovakia)' => 'Europe/Bratislava', -'Slovenian (Slovenia)' => 'Europe/Ljubljana', -'Spanish (Argentina)' => 'America/Buenos_Aires', -'Spanish (Mexico)' => 'America/Mexico_City', -'Spanish (Spain)' => 'Europe/Madrid', -'Swedish (Sweden)' => 'Europe/Stockholm', -'Tajik (Tajikistan)' => 'Asia/Dushanbe', -'Tamil (Sri Lanka)' => 'Asia/Colombo', -'Tatar' => 'Europe/Minsk', -'Thai (Thailand)' => 'Asia/Bangkok', -'Turkish (Turkey)' => 'Europe/Istanbul', -'Ukrainian (Ukraine)' => 'Europe/Kiev', -'Uzbek (Uzbekistan)' => 'Asia/Tashkent', -'Vietnamese (Vietnam)' => 'Asia/Saigon', -'Walon (Belgium)' => 'Europe/Brussels', +#- best guesses for a given country +my %c2t = ( +'AM' => 'Asia/Yerevan', +'AR' => 'America/Buenos_Aires', +'AT' => 'Europe/Vienna', +'AU' => 'Australia/Sydney', +'BA' => 'Europe/Sarajevo', +'BE' => 'Europe/Brussels', +'BG' => 'Europe/Sofia', +'BR' => 'Brazil/East', #- most people live on the east coast +'BY' => 'Europe/Minsk', +'CA' => 'Canada/Eastern', +'CH' => 'Europe/Zurich', +'CN' => 'Asia/Beijing', +'CZ' => 'Europe/Prague', +'DE' => 'Europe/Berlin', +'DK' => 'Europe/Copenhagen', +'EE' => 'Europe/Tallinn', +'ES' => 'Europe/Madrid', +'FI' => 'Europe/Helsinki', +'FR' => 'Europe/Paris', +'GB' => 'Europe/London', +'GE' => 'Asia/Yerevan', +'GL' => 'Arctic/Longyearbyen', +'GR' => 'Europe/Athens', +'HR' => 'Europe/Zagreb', +'HU' => 'Europe/Budapest', +'ID' => 'Asia/Jakarta', +'IE' => 'Europe/Dublin', +'IL' => 'Asia/Tel_Aviv', +'IN' => 'Asia/Calcutta', +'IR' => 'Asia/Tehran', +'IS' => 'Atlantic/Reykjavik', +'IT' => 'Europe/Rome', +'JP' => 'Asia/Tokyo', +'KR' => 'Asia/Seoul', +'LT' => 'Europe/Vilnius', +'LV' => 'Europe/Riga', +'MK' => 'Europe/Skopje', +'MT' => 'Europe/Malta', +'MX' => 'America/Mexico_City', +'MY' => 'Asia/Kuala_Lumpur', +'NL' => 'Europe/Amsterdam', +'NO' => 'Europe/Oslo', +'NZ' => 'Pacific/Auckland', +'PL' => 'Europe/Warsaw', +'PT' => 'Europe/Lisbon', +'RO' => 'Europe/Bucharest', +'RU' => 'Europe/Moscow', +'SE' => 'Europe/Stockholm', +'SI' => 'Europe/Ljubljana', +'SK' => 'Europe/Bratislava', +'TH' => 'Asia/Bangkok', +'TJ' => 'Asia/Dushanbe', +'TR' => 'Europe/Istanbul', +'TW' => 'Asia/Taipei', +'UA' => 'Europe/Kiev', +'US' => 'America/New_York', +'UZ' => 'Asia/Tashkent', +'VN' => 'Asia/Saigon', +'YU' => 'Europe/Belgrade', +'ZA' => 'Africa/Johannesburg', ); sub fuzzyChoice { - my ($b, $count) = bestMatchSentence($_[0], keys %l2t); + my ($b, $count) = bestMatchSentence($_[0], keys %c2t); $count ? $b : ''; } -sub bestTimezone { $l2t{fuzzyChoice($_[0])} || 'GMT' } +sub bestTimezone { $c2t{fuzzyChoice($_[0])} || 'GMT' } sub ntp_servers { q(Australia (ntp.adelaide.edu.au) |