summaryrefslogtreecommitdiffstats
path: root/scripts/genlocalelist
blob: ae3d01e4caec0c517dde0e2b7073f1067436baca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/perl

# This table is used to eliminate things like French (France)
$defaultTerritory{"Albanian"} = "Albania";
$defaultTerritory{"Belarusian"} = "Belarus";
$defaultTerritory{"Bulgarian"} = "Bulgaria";
$defaultTerritory{"Croatian"} = "Croatia";
$defaultTerritory{"Czech"} = "Czech Republic";
$defaultTerritory{"Danish"} = "Denmark";
$defaultTerritory{"Estonian"} = "Estonia";
$defaultTerritory{"Finnish"} = "Finland";
$defaultTerritory{"French"} = "France";
$defaultTerritory{"German"} = "Germany";
$defaultTerritory{"Greek"} = "Greece";
$defaultTerritory{"Hungarian"} = "Hungary";
$defaultTerritory{"Icelandic"} = "Iceland";
$defaultTerritory{"Indonesian"} = "Indonesia";
$defaultTerritory{"Italian"} = "Italy";
$defaultTerritory{"Irish"} = "Ireland";
$defaultTerritory{"Japanese"} = "Japan";
$defaultTerritory{"Lithuanian"} = "Lithuania";
$defaultTerritory{"Macedonian"} = "Macedonia";
$defaultTerritory{"Norwegian"} = "Norway";
$defaultTerritory{"Polish"} = "Poland";
$defaultTerritory{"Portuguese"} = "Portugal";
$defaultTerritory{"Romanian"} = "Romania";
$defaultTerritory{"Russian"} = "Russia";
$defaultTerritory{"Slovak"} = "Slovak";
$defaultTerritory{"Slovenian"} = "Slovenian";
$defaultTerritory{"Ukrainian"} = "Ukraine";
$defaultTerritory{"Vietnamese"} = "Vietnam";
$defaultTerritory{"Spanish"} = "Spain";
$defaultTerritory{"Swedish"} = "Sweden";
$defaultTerritory{"Turkish"} = "Turkey";
$defaultTerritory{"Thai"} = "Thailand";

$charMap{"EUC-JP"} =  "iso01";
$charMap{"ISO-8859-1"} =  "iso01";
$charMap{"ISO-8859-2"} =  "iso02";
$charMap{"ISO-8859-3"} =  "iso03";
$charMap{"ISO-8859-5"} =  "iso05";
$charMap{"ISO-8859-6"} =  "iso06";
$charMap{"ISO-8859-7"} =  "iso07";
$charMap{"ISO-8859-8"} =  "iso08";
$charMap{"ISO-8859-9"} =  "iso09";
$charMap{"ISO-8859-15"} =  "iso15";

$charFont{"EUC-JP"} =  "default8x16";
$charFont{"ISO-8859-1"} =  "default8x16";
$charFont{"ISO-8859-2"} =  "lat2-sun16";
#$charFont{"ISO-8859-3"} =  "iso03";		mk_MK -- no font available
$charFont{"ISO-8859-5"} =  "cyr-sun16";
$charFont{"ISO-8859-6"} =  "LatArCyrHeb-16";
$charFont{"ISO-8859-7"} =  "gr.f16";
$charFont{"ISO-8859-8"} =  "LatArCyrHeb-16";
$charFont{"ISO-8859-9"} =  "lat5-sun16";
$charFont{"ISO-8859-15"} =  "lat0-sun16";


open(FILE, "locale -a|");

while (<FILE>) {
#for (['he_IL', 'en_US']) {
    chop;

    # limit to items of the form xx_.*
    /^[a-zA-Z][a-zA-Z]_/ || next;

    $lang=$_;

    open(INFO, "LANG=$lang locale -c language -c territory -k charmap|");
    <INFO>;
    $name = <INFO>;
    <INFO>;
    $territory = <INFO>;
    <INFO>;
    $charmap = <INFO>;
    close(INFO);

    chop $name;
    $name =~ s/^[^"]+"//;
    $name =~ s/"$//;
    chop $territory;
    $territory =~ s/^[^"]+"//;
    $territory =~ s/"$//;
    chop $charmap;
    $charmap =~ s/^[^"]+"//;
    $charmap =~ s/"$//;

    # Some languages name's are the same as their ISO id's!
    ($name eq substr($lang, 0, 2)) && next;

    if ($defaultTerritory{$name} eq "$territory") {
	$fullName = $name;
    } else {
	$fullName = "$name ($territory)";
    }

    $langList{$lang} = $fullName;
    $charmapList{$lang} = $charmap;
}

close(FILE);

for $key (keys %langList) {
    $langName = $langList{$key};
    if ($nameList{$langName}) {
	# we have a conflict. longest wins
	if (length($key) > length($nameList{$langName})) {
	    $nameList{$langName} = $key;
	} else {
	}
    } else {
	$nameList{$langName} = $key;
    }
}

@names = sort(keys %nameList);

for $name (@names) {
    $short = $nameList{$name};
    $map = $charmapList{$short};
    if ($charMap{$map} and $charFont{$map}) {
	print "$short $charMap{$map} $charFont{$map} $name\n";
    }
}