summarylogtreecommitdiffstats
path: root/ff-downloader.pl
diff options
context:
space:
mode:
authorSimon Brulhart2017-08-20 17:42:53 +0200
committerSimon Brulhart2017-08-20 18:12:45 +0200
commitae90fbe3db7783b6f6ff69ddf2c006632a092b71 (patch)
tree24b98be7c79d1fd49ae7840fb1458471f85015e9 /ff-downloader.pl
parente29f7994992f60ab1127e5b2ebaa2e24e4cf5011 (diff)
downloadaur-ae90fbe3db7783b6f6ff69ddf2c006632a092b71.tar.gz
Use language codes instead of numbers for language selection
Diffstat (limited to 'ff-downloader.pl')
-rw-r--r--ff-downloader.pl34
1 files changed, 17 insertions, 17 deletions
diff --git a/ff-downloader.pl b/ff-downloader.pl
index 22769cfa3040..ae88b31d0322 100644
--- a/ff-downloader.pl
+++ b/ff-downloader.pl
@@ -95,7 +95,7 @@ $LANG = read_config();
if (!$LANG)
{
- my @ff_i18n = (
+ my @ff_langs = (
{ language => 'Acholi', code => 'ach' },
{ language => 'Afrikaans (South Africa)', code => 'af' },
{ language => 'Netherlands Antilles', code => 'an' },
@@ -193,28 +193,28 @@ if (!$LANG)
{ language => 'Chinese (Traditional)', code => 'zh-TW' },
);
- my @i18n = sort { $a->{language} cmp $b->{language} } @ff_i18n;
- my $size = scalar @i18n;
- print "\n";
+ my @langs = sort { $a->{language} cmp $b->{language} } @ff_langs;
+ my %langs_hash = map { $_->{code} => $_->{language} } @langs;
- for (my $i = 0; $i < $size; $i++ )
- {
- say '[', $i + 1, "] $i18n[$i]{language}";
+ say '';
+ say 'CODE LANGUAGE';
+ say '----------------';
+ for my $lang (@langs) {
+ printf "%-7s %s\n", $lang->{code}, $lang->{language};
}
- print "\n:: please select your language (type corresponding number)\n> ";
+ print "\n:: Please select your language (type language code)\n> ";
my $choice;
- while ( $choice = <STDIN> )
+ while ( $choice = <STDIN> )
{
- no warnings;
- chomp $choice;
- $choice =~ s/^\s+//;
- $choice =~ s/\s+$//;
- last if $choice ~~ [ 1 .. $size ];
- print ":: WRONG SELECTION!\n:: please select your language (type corresponding number)\n> ";
+ chomp $choice;
+ $choice =~ s/^\s+//;
+ $choice =~ s/\s+$//;
+ last if exists($langs_hash{$choice});
+ print ":: WRONG SELECTION!\n:: Please select your language (type language code)\n> ";
}
- $LANG = $i18n[$choice - 1]{code};
- say ":: \"$i18n[$choice - 1]{language}\" selected\n::";
+ $LANG = $choice;
+ say qq{:: "$langs_hash{$choice}" selected\n::};
my ($user_conf_dir,) = xdg_config_dirs;
say qq{:: HINT: put "ff=$LANG" (without quotes) in $user_conf_dir/ff-downloader.conf to avoid being asked about your language each time you build the package\n::};
}