Re: Copious warnings from Sys::Syslog
[p5sagit/p5-mst-13.2.git] / lib / Locale / Language.pm
CommitLineData
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
7package Locale::Language;
8use strict;
9require 5.002;
10
47a334e9 11require Exporter;
12
13#-----------------------------------------------------------------------
14# Public Global Variables
15#-----------------------------------------------------------------------
16use 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#-----------------------------------------------------------------------
25my %CODES = ();
26my %LANGUAGES = ();
27
28
29#=======================================================================
6b14ceb7 30#
31# code2language ( CODE )
32#
47a334e9 33#=======================================================================
34sub 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 60sub 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 86sub all_language_codes
87{
88 return keys %CODES;
89}
90
6b14ceb7 91
92#=======================================================================
93#
94# all_language_names()
95#
96#=======================================================================
47a334e9 97sub 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
1211;
122
123__DATA__
124aa:Afar
125ab:Abkhazian
126ae:Avestan
127af:Afrikaans
128am:Amharic
129ar:Arabic
130as:Assamese
131ay:Aymara
132az:Azerbaijani
133
134ba:Bashkir
135be:Belarusian
136bg:Bulgarian
137bh:Bihari
138bi:Bislama
139bn:Bengali
140bo:Tibetan
141br:Breton
142bs:Bosnian
143
144ca:Catalan
145ce:Chechen
146ch:Chamorro
147co:Corsican
148cs:Czech
149cu:Church Slavic
150cv:Chuvash
151cy:Welsh
152
153da:Danish
154de:German
155dz:Dzongkha
156
157el:Greek
158en:English
159eo:Esperanto
160es:Spanish
161et:Estonian
162eu:Basque
163
164fa:Persian
165fi:Finnish
166fj:Fijian
167fo:Faeroese
168fr:French
169fy:Frisian
170
171ga:Irish
172gd:Gaelic (Scots)
173gl:Gallegan
174gn:Guarani
175gu:Gujarati
176gv:Manx
177
178ha:Hausa
179he:Hebrew
180hi:Hindi
181ho:Hiri Motu
182hr:Croatian
183hu:Hungarian
184hy:Armenian
185hz:Herero
186
187ia:Interlingua
188id:Indonesian
189ie:Interlingue
190ik:Inupiaq
191is:Icelandic
192it:Italian
193iu:Inuktitut
194
195ja:Japanese
196jw:Javanese
197
198ka:Georgian
199ki:Kikuyu
200kj:Kuanyama
201kk:Kazakh
202kl:Kalaallisut
203km:Khmer
204kn:Kannada
205ko:Korean
206ks:Kashmiri
207ku:Kurdish
208kv:Komi
209kw:Cornish
210ky:Kirghiz
211
212la:Latin
213lb:Letzeburgesch
214ln:Lingala
215lo:Lao
216lt:Lithuanian
217lv:Latvian
218
219mg:Malagasy
220mh:Marshall
221mi:Maori
222mk:Macedonian
223ml:Malayalam
224mn:Mongolian
225mo:Moldavian
226mr:Marathi
227ms:Malay
228mt:Maltese
229my:Burmese
230
231na:Nauru
232nb:Norwegian Bokmål
233nd:Ndebele, North
234ne:Nepali
235ng:Ndonga
236nl:Dutch
237nn:Norwegian Nynorsk
238no:Norwegian
239nr:Ndebele, South
240nv:Navajo
241ny:Chichewa; Nyanja
242
243oc:Occitan (post 1500)
244om:Oromo
245or:Oriya
246os:Ossetian; Ossetic
247
248pa:Panjabi
249pi:Pali
250pl:Polish
251ps:Pushto
252pt:Portuguese
253
254qu:Quechua
255
256rm:Rhaeto-Romance
257rn:Rundi
258ro:Romanian
259ru:Russian
260rw:Kinyarwanda
261
262sa:Sanskrit
263sc:Sardinian
264sd:Sindhi
265se:Sami
266sg:Sango
267si:Sinhalese
268sk:Slovak
269sl:Slovenian
270sm:Samoan
271sn:Shona
272so:Somali
273sq:Albanian
274sr:Serbian
275ss:Swati
276st:Sotho
277su:Sundanese
278sv:Swedish
279sw:Swahili
280
281ta:Tamil
282te:Telugu
283tg:Tajik
284th:Thai
285ti:Tigrinya
286tk:Turkmen
287tl:Tagalog
288tn:Tswana
289to:Tonga
290tr:Turkish
291ts:Tsonga
292tt:Tatar
293tw:Twi
294
295ug:Uighur
296uk:Ukrainian
297ur:Urdu
298uz:Uzbek
299
300vi:Vietnamese
301vo:Volapük
302
303wo:Wolof
304
305xh:Xhosa
306
307yi:Yiddish
308yo:Yoruba
309
310za:Zhuang
311zh:Chinese
312zu:Zulu