summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-02-18 19:44:51 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-02-18 19:44:51 +0000
commitb8687c171484a2efe5a3449bce38d891e9ca9d85 (patch)
tree984dc2ec44aa742c3db95bb3b01993099c7c626c /perl-install
parent0b424c7192ae4fd49396e1a5aee8735ba99941b9 (diff)
downloaddrakx-backup-do-not-use-b8687c171484a2efe5a3449bce38d891e9ca9d85.tar
drakx-backup-do-not-use-b8687c171484a2efe5a3449bce38d891e9ca9d85.tar.gz
drakx-backup-do-not-use-b8687c171484a2efe5a3449bce38d891e9ca9d85.tar.bz2
drakx-backup-do-not-use-b8687c171484a2efe5a3449bce38d891e9ca9d85.tar.xz
drakx-backup-do-not-use-b8687c171484a2efe5a3449bce38d891e9ca9d85.zip
- handle --kde_lang with optionally --kde_country
- handle --apply
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/lang.pm18
-rw-r--r--perl-install/standalone/localedrake12
2 files changed, 27 insertions, 3 deletions
diff --git a/perl-install/lang.pm b/perl-install/lang.pm
index a6be76621..f24db210f 100644
--- a/perl-install/lang.pm
+++ b/perl-install/lang.pm
@@ -497,6 +497,24 @@ sub lang2kde_lang {
$r ||= first(grep { $valid_lang->($_) } split(':', lang2LANGUAGE($lang)));
$r || $default || 'C';
}
+
+sub kde_lang2lang {
+ my ($klang, $default) = @_;
+ first(grep { /^$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];
diff --git a/perl-install/standalone/localedrake b/perl-install/standalone/localedrake
index ea40a99d0..b71f4cff7 100644
--- a/perl-install/standalone/localedrake
+++ b/perl-install/standalone/localedrake
@@ -8,10 +8,16 @@ use interactive;
use lang;
use any;
+my ($klang, $country, $apply);
-if ($ARGV[0] =~ /--kde_country=(.*)/) {
- my $lang = lang::country2lang($1);
- lang::write('', $lang, $>);
+foreach (@ARGV) {
+ $apply = /--apply/;
+ $klang = $1 if /--kde_lang=(.*)/;
+ $country = $1 if /--kde_country=(.*)/;
+}
+if ($klang) {
+ my $lang = lang::kde_lang_country2lang($klang, $country);
+ lang::write('', $lang, $>) if $apply;
#- help KDE defaulting to the right charset
print lang::charset2kde_charset(lang::lang2charset($lang)), "\n";