pdf: create a new document for PDF version test, fix spelling
[LibreOffice.git] / bin / lo-xlate-lang
blob9b939012e99a22652a8fab7a6afccbbcd4a6b145
1 #!/usr/bin/env perl
3 use strict;
5 my $progname=$0; $progname = $& if $progname =~ m,[^/]+$,;
7 my %PREFIX; # used to search for prefix numbers
8 my %ISOCODE; # used to search for iso codes
9 my %LANGUAGE; # used to search for language names
11 #=======================================================================
12 # initialisation code - stuff the DATA into the CODES hash
13 #=======================================================================
14 sub init {
16 my $prefix;
17 my $code;
18 my $name;
21 while (<DATA>)
23 next unless /\S/;
24 chop;
25 ($prefix, $code, $name ) = split(/:/, $_, 3);
26 $PREFIX{$prefix} = $prefix;
27 $PREFIX{$code} = $prefix;
28 $PREFIX{$name} = $prefix;
30 $ISOCODE{$prefix} = $code;
31 $ISOCODE{$code} = $code;
32 $ISOCODE{$name} = $code;
34 $LANGUAGE{$prefix} = $name;
35 $LANGUAGE{$code} = $name;
36 $LANGUAGE{$name} = $name;
41 #=======================================================================
42 # usage - error message
43 #=======================================================================
44 sub usage {
45 my $errmsg = shift;
46 my $errcode = shift;
47 print STDERR "$progname: $errmsg\n" if $errmsg;
48 print STDERR "$progname: Converts between prefix codes, iso codes and langnames\n";
49 print STDERR " Usage: $progname (-i|-l|-p|-h) <code>|all\n";
50 print STDERR " -i <code>: convert prefix to iso code (ex: 03 -> pt)\n";
51 print STDERR " -l <code>: convert iso code to language name (ex: pt -> portuguese)\n";
52 print STDERR " -p <code>: convert iso code to prefix (ex: pt -> 03)\n";
53 print STDERR " the code can either be an iso code, a prefix or even a language name\n";
54 print STDERR " The special code \"all\" asks for all possible values.\n\n";
55 print STDERR " -h : print this help\n";
56 exit $errcode;
59 #=======================================================================
60 # main -
61 #=======================================================================
62 init();
64 my ($LanguageCode, $LanguageMap);
66 while ($ARGV[0] =~ /^-/) {
67 $_ = shift;
68 if (m/^-i/) {
69 $LanguageMap = \%ISOCODE;
71 elsif (m/^-l/) {
72 $LanguageMap = \%LANGUAGE;
74 elsif (m/^-p/) {
75 $LanguageMap = \%PREFIX;
77 elsif (m/^-h/) {
78 usage("",0);
80 else {
81 usage ("unknown option $_",1);
85 usage ("no operation specified on command line",1)
86 if (!$LanguageMap);
88 usage ("no language code specified on command line",1)
89 if (!($LanguageCode = shift));
91 if ($LanguageCode =~ (m/^all$/)) {
92 # Asked for all codes
93 my $old="";
94 foreach my $key (sort values %$LanguageMap) {
95 if ($key ne $old) {
96 print "$key ";
97 $old=$key;
100 print "\n";
101 exit 0;
104 usage ("no mapping found for $LanguageCode\n",1)
105 if (!($LanguageMap->{$LanguageCode}));
107 print $LanguageMap->{$LanguageCode}, "\n";
111 # keep third column names here with openoffice-dir/share/*/<long lang name>/
113 __DATA__
114 :be:belarusian
115 :bg:bulgarian
116 :bn:bengali
117 :bs:bosnian
118 :en-GB:english_british
119 :gu:gujarati
120 :hr:croatian
121 :km:khmer
122 :kmr-Latn:Kurmanji
123 :pa-IN:punjabi
124 :rw:kinarwanda
125 :xh:xhosa
126 :lt:lithuanian
127 :ne:nepali
128 :vi:vietnamese
129 :nso:northern_sotho
130 :ss:swazi
131 :sr:serbian
132 :ve:venda
133 :ts:tsonga
134 :st:southern_sotho
135 :tn:tswana
136 :br:breton
137 :ga:gaelic
138 :gd:scottish_gaelic
139 :th:thai
140 :hi:hindi
141 :bs-BA:bosnian
142 :en-ZA:english_southafrican
143 :mk:macedonian
144 :as:assamese
145 :ml:malayalam
146 :mr:marathi
147 :or:odia
148 :ur:urdu
149 :fa:farsi
150 :lv:latvian
151 :nr:ndebele
152 :ne:nepalese
153 :sh:serbian
154 :te:telugu
155 :ta:tamil
156 :tg:tajik
157 :ka:georgian
158 :eo:esperanto
159 :uk:ukrainian
160 :kk:kazakh
161 :dz:dzongkha
162 :kn:kannada
163 :gl:galician
164 :uz:uzbek
165 :oc:occitan
166 :ro:romanian
167 :eu:basque
168 :mn:mongolian
169 :om:oromo
170 :bo:tibetan
171 :ast:asturian
172 :is:icelandic
173 :ug:uighur
174 :si:sinhala
175 :id:indonesian
176 :my:burmese
177 :am:amharic
178 :gug:guarani
179 :szl:upper_silesian
180 :hy:armenian
181 01:en-US:english_american
182 03:pt:portuguese
183 07:ru:russian
184 26:ns:northernsotho
185 27:af:afrikaans
186 28:zu:zulu
187 30:el:greek
188 31:nl:dutch
189 33:fr:french
190 34:es:spanish
191 35:fi:finnish
192 36:hu:hungarian
193 37:ca:catalan
194 39:it:italian
195 42:cs:czech
196 43:sk:slovak
197 45:da:danish
198 46:sv:swedish
199 47:nb:norwegian_bokmal
200 48:pl:polish
201 49:de:german
202 50:sl:slovenian
203 53:cy:welsh
204 55:pt-BR:portuguese_brazilian
205 77:et:estonian
206 79:nn:norwegian_nynorsk
207 81:ja:japanese
208 82:ko:korean
209 86:zh-CN:chinese_simplified
210 88:zh-TW:chinese_traditional
211 90:tr:turkish
212 91:hi:hindi
213 96:ar:arabic
214 97:he:hebrew