Commit | Line | Data |
6b14ceb7 |
1 | # |
2 | # Locale::Language - ISO two letter codes for language identification (ISO 639) |
3 | # |
4 | # $Id: Language.pm,v 2.1 2002/02/06 04:07:10 neilb Exp $ |
5 | # |
47a334e9 |
6 | |
7 | package Locale::Language; |
8 | use strict; |
9 | require 5.002; |
10 | |
47a334e9 |
11 | require Exporter; |
12 | |
13 | #----------------------------------------------------------------------- |
14 | # Public Global Variables |
15 | #----------------------------------------------------------------------- |
16 | use vars qw($VERSION @ISA @EXPORT); |
6b14ceb7 |
17 | $VERSION = sprintf("%d.%02d", q$Revision: 2.1 $ =~ /(\d+)\.(\d+)/); |
47a334e9 |
18 | @ISA = qw(Exporter); |
19 | @EXPORT = qw(&code2language &language2code |
20 | &all_language_codes &all_language_names ); |
21 | |
22 | #----------------------------------------------------------------------- |
23 | # Private Global Variables |
24 | #----------------------------------------------------------------------- |
25 | my %CODES = (); |
26 | my %LANGUAGES = (); |
27 | |
28 | |
29 | #======================================================================= |
6b14ceb7 |
30 | # |
31 | # code2language ( CODE ) |
32 | # |
47a334e9 |
33 | #======================================================================= |
34 | sub code2language |
35 | { |
36 | my $code = shift; |
37 | |
38 | |
39 | return undef unless defined $code; |
40 | $code = lc($code); |
41 | if (exists $CODES{$code}) |
42 | { |
43 | return $CODES{$code}; |
44 | } |
45 | else |
46 | { |
47 | #--------------------------------------------------------------- |
48 | # no such language code! |
49 | #--------------------------------------------------------------- |
50 | return undef; |
51 | } |
52 | } |
53 | |
6b14ceb7 |
54 | |
55 | #======================================================================= |
56 | # |
57 | # language2code ( LANGUAGE ) |
58 | # |
59 | #======================================================================= |
47a334e9 |
60 | sub language2code |
61 | { |
62 | my $lang = shift; |
63 | |
64 | |
65 | return undef unless defined $lang; |
66 | $lang = lc($lang); |
67 | if (exists $LANGUAGES{$lang}) |
68 | { |
69 | return $LANGUAGES{$lang}; |
70 | } |
71 | else |
72 | { |
73 | #--------------------------------------------------------------- |
74 | # no such language! |
75 | #--------------------------------------------------------------- |
76 | return undef; |
77 | } |
78 | } |
79 | |
47a334e9 |
80 | |
81 | #======================================================================= |
6b14ceb7 |
82 | # |
83 | # all_language_codes() |
84 | # |
85 | #======================================================================= |
47a334e9 |
86 | sub all_language_codes |
87 | { |
88 | return keys %CODES; |
89 | } |
90 | |
6b14ceb7 |
91 | |
92 | #======================================================================= |
93 | # |
94 | # all_language_names() |
95 | # |
96 | #======================================================================= |
47a334e9 |
97 | sub all_language_names |
98 | { |
99 | return values %CODES; |
100 | } |
101 | |
47a334e9 |
102 | |
103 | #======================================================================= |
104 | # initialisation code - stuff the DATA into the CODES hash |
105 | #======================================================================= |
106 | { |
107 | my $code; |
108 | my $language; |
109 | |
110 | |
111 | while (<DATA>) |
112 | { |
6b6e008c |
113 | next unless /\S/; |
47a334e9 |
114 | chop; |
115 | ($code, $language) = split(/:/, $_, 2); |
116 | $CODES{$code} = $language; |
117 | $LANGUAGES{"\L$language"} = $code; |
118 | } |
119 | } |
120 | |
121 | 1; |
122 | |
123 | __DATA__ |
124 | aa:Afar |
125 | ab:Abkhazian |
126 | ae:Avestan |
127 | af:Afrikaans |
128 | am:Amharic |
129 | ar:Arabic |
130 | as:Assamese |
131 | ay:Aymara |
132 | az:Azerbaijani |
133 | |
134 | ba:Bashkir |
135 | be:Belarusian |
136 | bg:Bulgarian |
137 | bh:Bihari |
138 | bi:Bislama |
139 | bn:Bengali |
140 | bo:Tibetan |
141 | br:Breton |
142 | bs:Bosnian |
143 | |
144 | ca:Catalan |
145 | ce:Chechen |
146 | ch:Chamorro |
147 | co:Corsican |
148 | cs:Czech |
149 | cu:Church Slavic |
150 | cv:Chuvash |
151 | cy:Welsh |
152 | |
153 | da:Danish |
154 | de:German |
155 | dz:Dzongkha |
156 | |
157 | el:Greek |
158 | en:English |
159 | eo:Esperanto |
160 | es:Spanish |
161 | et:Estonian |
162 | eu:Basque |
163 | |
164 | fa:Persian |
165 | fi:Finnish |
166 | fj:Fijian |
167 | fo:Faeroese |
168 | fr:French |
169 | fy:Frisian |
170 | |
171 | ga:Irish |
172 | gd:Gaelic (Scots) |
173 | gl:Gallegan |
174 | gn:Guarani |
175 | gu:Gujarati |
176 | gv:Manx |
177 | |
178 | ha:Hausa |
179 | he:Hebrew |
180 | hi:Hindi |
181 | ho:Hiri Motu |
182 | hr:Croatian |
183 | hu:Hungarian |
184 | hy:Armenian |
185 | hz:Herero |
186 | |
187 | ia:Interlingua |
188 | id:Indonesian |
189 | ie:Interlingue |
190 | ik:Inupiaq |
191 | is:Icelandic |
192 | it:Italian |
193 | iu:Inuktitut |
194 | |
195 | ja:Japanese |
196 | jw:Javanese |
197 | |
198 | ka:Georgian |
199 | ki:Kikuyu |
200 | kj:Kuanyama |
201 | kk:Kazakh |
202 | kl:Kalaallisut |
203 | km:Khmer |
204 | kn:Kannada |
205 | ko:Korean |
206 | ks:Kashmiri |
207 | ku:Kurdish |
208 | kv:Komi |
209 | kw:Cornish |
210 | ky:Kirghiz |
211 | |
212 | la:Latin |
213 | lb:Letzeburgesch |
214 | ln:Lingala |
215 | lo:Lao |
216 | lt:Lithuanian |
217 | lv:Latvian |
218 | |
219 | mg:Malagasy |
220 | mh:Marshall |
221 | mi:Maori |
222 | mk:Macedonian |
223 | ml:Malayalam |
224 | mn:Mongolian |
225 | mo:Moldavian |
226 | mr:Marathi |
227 | ms:Malay |
228 | mt:Maltese |
229 | my:Burmese |
230 | |
231 | na:Nauru |
232 | nb:Norwegian Bokmål |
233 | nd:Ndebele, North |
234 | ne:Nepali |
235 | ng:Ndonga |
236 | nl:Dutch |
237 | nn:Norwegian Nynorsk |
238 | no:Norwegian |
239 | nr:Ndebele, South |
240 | nv:Navajo |
241 | ny:Chichewa; Nyanja |
242 | |
243 | oc:Occitan (post 1500) |
244 | om:Oromo |
245 | or:Oriya |
246 | os:Ossetian; Ossetic |
247 | |
248 | pa:Panjabi |
249 | pi:Pali |
250 | pl:Polish |
251 | ps:Pushto |
252 | pt:Portuguese |
253 | |
254 | qu:Quechua |
255 | |
256 | rm:Rhaeto-Romance |
257 | rn:Rundi |
258 | ro:Romanian |
259 | ru:Russian |
260 | rw:Kinyarwanda |
261 | |
262 | sa:Sanskrit |
263 | sc:Sardinian |
264 | sd:Sindhi |
265 | se:Sami |
266 | sg:Sango |
267 | si:Sinhalese |
268 | sk:Slovak |
269 | sl:Slovenian |
270 | sm:Samoan |
271 | sn:Shona |
272 | so:Somali |
273 | sq:Albanian |
274 | sr:Serbian |
275 | ss:Swati |
276 | st:Sotho |
277 | su:Sundanese |
278 | sv:Swedish |
279 | sw:Swahili |
280 | |
281 | ta:Tamil |
282 | te:Telugu |
283 | tg:Tajik |
284 | th:Thai |
285 | ti:Tigrinya |
286 | tk:Turkmen |
287 | tl:Tagalog |
288 | tn:Tswana |
289 | to:Tonga |
290 | tr:Turkish |
291 | ts:Tsonga |
292 | tt:Tatar |
293 | tw:Twi |
294 | |
295 | ug:Uighur |
296 | uk:Ukrainian |
297 | ur:Urdu |
298 | uz:Uzbek |
299 | |
300 | vi:Vietnamese |
301 | vo:Volapük |
302 | |
303 | wo:Wolof |
304 | |
305 | xh:Xhosa |
306 | |
307 | yi:Yiddish |
308 | yo:Yoruba |
309 | |
310 | za:Zhuang |
311 | zh:Chinese |
312 | zu:Zulu |