From 2dbbcd2144d8c53d7223a0dd709b80f90a6dde25 Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Wed, 5 Mar 2003 17:53:47 +0000 Subject: fix behaviour when only one lang is available (clicking on "cancel" on the country selection didn't cancel it) --- perl-install/standalone/localedrake | 54 ++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 16 deletions(-) (limited to 'perl-install/standalone') diff --git a/perl-install/standalone/localedrake b/perl-install/standalone/localedrake index 66bcc05bf..4f5a433e3 100644 --- a/perl-install/standalone/localedrake +++ b/perl-install/standalone/localedrake @@ -9,15 +9,16 @@ use common; use lang; use any; -my ($klang, $country, $apply); +my ($klang, $kcountry, $apply); foreach (@ARGV) { $apply = /--apply/; $klang = $1 if /--kde_lang=(.*)/; $kcountry = uc($1) if /--kde_country=(.*)/; } + if (defined $klang) { - $klang or exit; + $klang or exit(-1); my $lang = member($klang, lang::list_langs()) ? $klang : 'en_US'; my $country = member($kcountry, lang::list_countries()) ? $kcountry : 'US'; my $locale = lang::read('', $>); @@ -27,21 +28,42 @@ if (defined $klang) { #- help KDE defaulting to the right charset print lang::charset2kde_charset(lang::l2charset($lang)), "\n"; -} else { - my $locale = lang::read('', $>); - my $in = 'interactive'->vnew; - 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); - } + exit(0); +} + +my $locale = lang::read('', $>); +my $in = 'interactive'->vnew; +my $one_lang_only; + +sub select_language { + $locale->{lang} = any::selectLanguage($in, $locale->{lang}); +} +sub select_country { + any::selectCountry($in, $locale); +} + +eval { + language: + select_language() or goto the_end; + select_country() or goto language; +}; +if ($@) { + if ($@ =~ /^one lang only/) { + select_country() or goto the_end; + } else { + die; } -the_end: - $in->exit(0); } +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); + -- cgit v1.2.1