You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gfxboot-theme-calculate/scrape-localechooser

67 lines
1.4 KiB

#! /usr/bin/perl -w
use strict;
if (@ARGV != 1) {
print STDERR "Usage: $0 localechooser-source-tree\n";
exit 1;
}
my $localechooser = $ARGV[0];
# Some special cases that are handled strangely either here or in
# localechooser.
my %langcode_overrides = (
'nb_NO' => 'nb',
'nn_NO' => 'nn',
'pt' => 'pt_PT',
'se_NO' => 'se',
);
# The real localised names for these languages use characters not present in
# our font, or not rendered correctly for some other reason.
my @langname_notranslate = (
'am',
'ar',
'bn',
'dz',
'gu',
'he',
'hi',
'km',
'ml',
'mr',
'ne',
'pa',
'ta',
'th',
);
my %langname_notranslate = map { $_ => 1 } @langname_notranslate;
my %langnames;
my %locales;
open LIST, '<:utf8', "$localechooser/languagelist"
or die "$0: can't open $localechooser/languagelist: $!";
while (<LIST>) {
chomp;
next if /^#/ or not /\S/;
my @bits = split /;/;
my $lang = $bits[0];
next if $lang eq 'C';
$lang = $langcode_overrides{$lang} if exists $langcode_overrides{$lang};
if (exists $langname_notranslate{$lang}) {
$langnames{$lang} = $bits[1];
} else {
$langnames{$lang} = $bits[2];
}
($locales{$lang} = "$bits[6]") =~ s/[.@].*//;
}
close LIST;
binmode STDOUT, ':utf8';
print "/lang.defaultnames [\n";
for my $lang (sort keys %langnames) {
print qq{ [ "$lang" "$locales{$lang}" "$langnames{$lang}" ]\n};
}
print "] def\n";