xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/Locale/Language.pm (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#
2*0Sstevel@tonic-gate# Locale::Language - ISO two letter codes for language identification (ISO 639)
3*0Sstevel@tonic-gate#
4*0Sstevel@tonic-gate# $Id: Language.pm,v 2.2 2002/07/10 16:33:27 neilb Exp $
5*0Sstevel@tonic-gate#
6*0Sstevel@tonic-gate
7*0Sstevel@tonic-gatepackage Locale::Language;
8*0Sstevel@tonic-gateuse strict;
9*0Sstevel@tonic-gaterequire 5.002;
10*0Sstevel@tonic-gate
11*0Sstevel@tonic-gaterequire Exporter;
12*0Sstevel@tonic-gate
13*0Sstevel@tonic-gate#-----------------------------------------------------------------------
14*0Sstevel@tonic-gate#	Public Global Variables
15*0Sstevel@tonic-gate#-----------------------------------------------------------------------
16*0Sstevel@tonic-gateuse vars qw($VERSION @ISA @EXPORT);
17*0Sstevel@tonic-gate$VERSION      = sprintf("%d.%02d", q$Revision: 2.21 $ =~ /(\d+)\.(\d+)/);
18*0Sstevel@tonic-gate@ISA          = qw(Exporter);
19*0Sstevel@tonic-gate@EXPORT       = qw(&code2language &language2code
20*0Sstevel@tonic-gate                   &all_language_codes &all_language_names );
21*0Sstevel@tonic-gate
22*0Sstevel@tonic-gate#-----------------------------------------------------------------------
23*0Sstevel@tonic-gate#	Private Global Variables
24*0Sstevel@tonic-gate#-----------------------------------------------------------------------
25*0Sstevel@tonic-gatemy %CODES     = ();
26*0Sstevel@tonic-gatemy %LANGUAGES = ();
27*0Sstevel@tonic-gate
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gate#=======================================================================
30*0Sstevel@tonic-gate#
31*0Sstevel@tonic-gate# code2language ( CODE )
32*0Sstevel@tonic-gate#
33*0Sstevel@tonic-gate#=======================================================================
34*0Sstevel@tonic-gatesub code2language
35*0Sstevel@tonic-gate{
36*0Sstevel@tonic-gate    my $code = shift;
37*0Sstevel@tonic-gate
38*0Sstevel@tonic-gate
39*0Sstevel@tonic-gate    return undef unless defined $code;
40*0Sstevel@tonic-gate    $code = lc($code);
41*0Sstevel@tonic-gate    if (exists $CODES{$code})
42*0Sstevel@tonic-gate    {
43*0Sstevel@tonic-gate        return $CODES{$code};
44*0Sstevel@tonic-gate    }
45*0Sstevel@tonic-gate    else
46*0Sstevel@tonic-gate    {
47*0Sstevel@tonic-gate        #---------------------------------------------------------------
48*0Sstevel@tonic-gate        # no such language code!
49*0Sstevel@tonic-gate        #---------------------------------------------------------------
50*0Sstevel@tonic-gate        return undef;
51*0Sstevel@tonic-gate    }
52*0Sstevel@tonic-gate}
53*0Sstevel@tonic-gate
54*0Sstevel@tonic-gate
55*0Sstevel@tonic-gate#=======================================================================
56*0Sstevel@tonic-gate#
57*0Sstevel@tonic-gate# language2code ( LANGUAGE )
58*0Sstevel@tonic-gate#
59*0Sstevel@tonic-gate#=======================================================================
60*0Sstevel@tonic-gatesub language2code
61*0Sstevel@tonic-gate{
62*0Sstevel@tonic-gate    my $lang = shift;
63*0Sstevel@tonic-gate
64*0Sstevel@tonic-gate
65*0Sstevel@tonic-gate    return undef unless defined $lang;
66*0Sstevel@tonic-gate    $lang = lc($lang);
67*0Sstevel@tonic-gate    if (exists $LANGUAGES{$lang})
68*0Sstevel@tonic-gate    {
69*0Sstevel@tonic-gate        return $LANGUAGES{$lang};
70*0Sstevel@tonic-gate    }
71*0Sstevel@tonic-gate    else
72*0Sstevel@tonic-gate    {
73*0Sstevel@tonic-gate        #---------------------------------------------------------------
74*0Sstevel@tonic-gate        # no such language!
75*0Sstevel@tonic-gate        #---------------------------------------------------------------
76*0Sstevel@tonic-gate        return undef;
77*0Sstevel@tonic-gate    }
78*0Sstevel@tonic-gate}
79*0Sstevel@tonic-gate
80*0Sstevel@tonic-gate
81*0Sstevel@tonic-gate#=======================================================================
82*0Sstevel@tonic-gate#
83*0Sstevel@tonic-gate# all_language_codes()
84*0Sstevel@tonic-gate#
85*0Sstevel@tonic-gate#=======================================================================
86*0Sstevel@tonic-gatesub all_language_codes
87*0Sstevel@tonic-gate{
88*0Sstevel@tonic-gate    return keys %CODES;
89*0Sstevel@tonic-gate}
90*0Sstevel@tonic-gate
91*0Sstevel@tonic-gate
92*0Sstevel@tonic-gate#=======================================================================
93*0Sstevel@tonic-gate#
94*0Sstevel@tonic-gate# all_language_names()
95*0Sstevel@tonic-gate#
96*0Sstevel@tonic-gate#=======================================================================
97*0Sstevel@tonic-gatesub all_language_names
98*0Sstevel@tonic-gate{
99*0Sstevel@tonic-gate    return values %CODES;
100*0Sstevel@tonic-gate}
101*0Sstevel@tonic-gate
102*0Sstevel@tonic-gate
103*0Sstevel@tonic-gate#=======================================================================
104*0Sstevel@tonic-gate# initialisation code - stuff the DATA into the CODES hash
105*0Sstevel@tonic-gate#=======================================================================
106*0Sstevel@tonic-gate{
107*0Sstevel@tonic-gate    my $code;
108*0Sstevel@tonic-gate    my $language;
109*0Sstevel@tonic-gate
110*0Sstevel@tonic-gate    local $_;
111*0Sstevel@tonic-gate
112*0Sstevel@tonic-gate    while (<DATA>)
113*0Sstevel@tonic-gate    {
114*0Sstevel@tonic-gate        next unless /\S/;
115*0Sstevel@tonic-gate        chop;
116*0Sstevel@tonic-gate        ($code, $language) = split(/:/, $_, 2);
117*0Sstevel@tonic-gate        $CODES{$code} = $language;
118*0Sstevel@tonic-gate        $LANGUAGES{"\L$language"} = $code;
119*0Sstevel@tonic-gate    }
120*0Sstevel@tonic-gate
121*0Sstevel@tonic-gate    close(DATA);
122*0Sstevel@tonic-gate}
123*0Sstevel@tonic-gate
124*0Sstevel@tonic-gate1;
125*0Sstevel@tonic-gate
126*0Sstevel@tonic-gate__DATA__
127*0Sstevel@tonic-gateaa:Afar
128*0Sstevel@tonic-gateab:Abkhazian
129*0Sstevel@tonic-gateae:Avestan
130*0Sstevel@tonic-gateaf:Afrikaans
131*0Sstevel@tonic-gateam:Amharic
132*0Sstevel@tonic-gatear:Arabic
133*0Sstevel@tonic-gateas:Assamese
134*0Sstevel@tonic-gateay:Aymara
135*0Sstevel@tonic-gateaz:Azerbaijani
136*0Sstevel@tonic-gate
137*0Sstevel@tonic-gateba:Bashkir
138*0Sstevel@tonic-gatebe:Belarusian
139*0Sstevel@tonic-gatebg:Bulgarian
140*0Sstevel@tonic-gatebh:Bihari
141*0Sstevel@tonic-gatebi:Bislama
142*0Sstevel@tonic-gatebn:Bengali
143*0Sstevel@tonic-gatebo:Tibetan
144*0Sstevel@tonic-gatebr:Breton
145*0Sstevel@tonic-gatebs:Bosnian
146*0Sstevel@tonic-gate
147*0Sstevel@tonic-gateca:Catalan
148*0Sstevel@tonic-gatece:Chechen
149*0Sstevel@tonic-gatech:Chamorro
150*0Sstevel@tonic-gateco:Corsican
151*0Sstevel@tonic-gatecs:Czech
152*0Sstevel@tonic-gatecu:Church Slavic
153*0Sstevel@tonic-gatecv:Chuvash
154*0Sstevel@tonic-gatecy:Welsh
155*0Sstevel@tonic-gate
156*0Sstevel@tonic-gateda:Danish
157*0Sstevel@tonic-gatede:German
158*0Sstevel@tonic-gatedz:Dzongkha
159*0Sstevel@tonic-gate
160*0Sstevel@tonic-gateel:Greek
161*0Sstevel@tonic-gateen:English
162*0Sstevel@tonic-gateeo:Esperanto
163*0Sstevel@tonic-gatees:Spanish
164*0Sstevel@tonic-gateet:Estonian
165*0Sstevel@tonic-gateeu:Basque
166*0Sstevel@tonic-gate
167*0Sstevel@tonic-gatefa:Persian
168*0Sstevel@tonic-gatefi:Finnish
169*0Sstevel@tonic-gatefj:Fijian
170*0Sstevel@tonic-gatefo:Faeroese
171*0Sstevel@tonic-gatefr:French
172*0Sstevel@tonic-gatefy:Frisian
173*0Sstevel@tonic-gate
174*0Sstevel@tonic-gatega:Irish
175*0Sstevel@tonic-gategd:Gaelic (Scots)
176*0Sstevel@tonic-gategl:Gallegan
177*0Sstevel@tonic-gategn:Guarani
178*0Sstevel@tonic-gategu:Gujarati
179*0Sstevel@tonic-gategv:Manx
180*0Sstevel@tonic-gate
181*0Sstevel@tonic-gateha:Hausa
182*0Sstevel@tonic-gatehe:Hebrew
183*0Sstevel@tonic-gatehi:Hindi
184*0Sstevel@tonic-gateho:Hiri Motu
185*0Sstevel@tonic-gatehr:Croatian
186*0Sstevel@tonic-gatehu:Hungarian
187*0Sstevel@tonic-gatehy:Armenian
188*0Sstevel@tonic-gatehz:Herero
189*0Sstevel@tonic-gate
190*0Sstevel@tonic-gateia:Interlingua
191*0Sstevel@tonic-gateid:Indonesian
192*0Sstevel@tonic-gateie:Interlingue
193*0Sstevel@tonic-gateik:Inupiaq
194*0Sstevel@tonic-gateis:Icelandic
195*0Sstevel@tonic-gateit:Italian
196*0Sstevel@tonic-gateiu:Inuktitut
197*0Sstevel@tonic-gate
198*0Sstevel@tonic-gateja:Japanese
199*0Sstevel@tonic-gatejw:Javanese
200*0Sstevel@tonic-gate
201*0Sstevel@tonic-gateka:Georgian
202*0Sstevel@tonic-gateki:Kikuyu
203*0Sstevel@tonic-gatekj:Kuanyama
204*0Sstevel@tonic-gatekk:Kazakh
205*0Sstevel@tonic-gatekl:Kalaallisut
206*0Sstevel@tonic-gatekm:Khmer
207*0Sstevel@tonic-gatekn:Kannada
208*0Sstevel@tonic-gateko:Korean
209*0Sstevel@tonic-gateks:Kashmiri
210*0Sstevel@tonic-gateku:Kurdish
211*0Sstevel@tonic-gatekv:Komi
212*0Sstevel@tonic-gatekw:Cornish
213*0Sstevel@tonic-gateky:Kirghiz
214*0Sstevel@tonic-gate
215*0Sstevel@tonic-gatela:Latin
216*0Sstevel@tonic-gatelb:Letzeburgesch
217*0Sstevel@tonic-gateln:Lingala
218*0Sstevel@tonic-gatelo:Lao
219*0Sstevel@tonic-gatelt:Lithuanian
220*0Sstevel@tonic-gatelv:Latvian
221*0Sstevel@tonic-gate
222*0Sstevel@tonic-gatemg:Malagasy
223*0Sstevel@tonic-gatemh:Marshall
224*0Sstevel@tonic-gatemi:Maori
225*0Sstevel@tonic-gatemk:Macedonian
226*0Sstevel@tonic-gateml:Malayalam
227*0Sstevel@tonic-gatemn:Mongolian
228*0Sstevel@tonic-gatemo:Moldavian
229*0Sstevel@tonic-gatemr:Marathi
230*0Sstevel@tonic-gatems:Malay
231*0Sstevel@tonic-gatemt:Maltese
232*0Sstevel@tonic-gatemy:Burmese
233*0Sstevel@tonic-gate
234*0Sstevel@tonic-gatena:Nauru
235*0Sstevel@tonic-gatenb:Norwegian Bokmal
236*0Sstevel@tonic-gatend:Ndebele, North
237*0Sstevel@tonic-gatene:Nepali
238*0Sstevel@tonic-gateng:Ndonga
239*0Sstevel@tonic-gatenl:Dutch
240*0Sstevel@tonic-gatenn:Norwegian Nynorsk
241*0Sstevel@tonic-gateno:Norwegian
242*0Sstevel@tonic-gatenr:Ndebele, South
243*0Sstevel@tonic-gatenv:Navajo
244*0Sstevel@tonic-gateny:Chichewa; Nyanja
245*0Sstevel@tonic-gate
246*0Sstevel@tonic-gateoc:Occitan (post 1500)
247*0Sstevel@tonic-gateom:Oromo
248*0Sstevel@tonic-gateor:Oriya
249*0Sstevel@tonic-gateos:Ossetian; Ossetic
250*0Sstevel@tonic-gate
251*0Sstevel@tonic-gatepa:Panjabi
252*0Sstevel@tonic-gatepi:Pali
253*0Sstevel@tonic-gatepl:Polish
254*0Sstevel@tonic-gateps:Pushto
255*0Sstevel@tonic-gatept:Portuguese
256*0Sstevel@tonic-gate
257*0Sstevel@tonic-gatequ:Quechua
258*0Sstevel@tonic-gate
259*0Sstevel@tonic-gaterm:Rhaeto-Romance
260*0Sstevel@tonic-gatern:Rundi
261*0Sstevel@tonic-gatero:Romanian
262*0Sstevel@tonic-gateru:Russian
263*0Sstevel@tonic-gaterw:Kinyarwanda
264*0Sstevel@tonic-gate
265*0Sstevel@tonic-gatesa:Sanskrit
266*0Sstevel@tonic-gatesc:Sardinian
267*0Sstevel@tonic-gatesd:Sindhi
268*0Sstevel@tonic-gatese:Sami
269*0Sstevel@tonic-gatesg:Sango
270*0Sstevel@tonic-gatesi:Sinhalese
271*0Sstevel@tonic-gatesk:Slovak
272*0Sstevel@tonic-gatesl:Slovenian
273*0Sstevel@tonic-gatesm:Samoan
274*0Sstevel@tonic-gatesn:Shona
275*0Sstevel@tonic-gateso:Somali
276*0Sstevel@tonic-gatesq:Albanian
277*0Sstevel@tonic-gatesr:Serbian
278*0Sstevel@tonic-gatess:Swati
279*0Sstevel@tonic-gatest:Sotho
280*0Sstevel@tonic-gatesu:Sundanese
281*0Sstevel@tonic-gatesv:Swedish
282*0Sstevel@tonic-gatesw:Swahili
283*0Sstevel@tonic-gate
284*0Sstevel@tonic-gateta:Tamil
285*0Sstevel@tonic-gatete:Telugu
286*0Sstevel@tonic-gatetg:Tajik
287*0Sstevel@tonic-gateth:Thai
288*0Sstevel@tonic-gateti:Tigrinya
289*0Sstevel@tonic-gatetk:Turkmen
290*0Sstevel@tonic-gatetl:Tagalog
291*0Sstevel@tonic-gatetn:Tswana
292*0Sstevel@tonic-gateto:Tonga
293*0Sstevel@tonic-gatetr:Turkish
294*0Sstevel@tonic-gatets:Tsonga
295*0Sstevel@tonic-gatett:Tatar
296*0Sstevel@tonic-gatetw:Twi
297*0Sstevel@tonic-gate
298*0Sstevel@tonic-gateug:Uighur
299*0Sstevel@tonic-gateuk:Ukrainian
300*0Sstevel@tonic-gateur:Urdu
301*0Sstevel@tonic-gateuz:Uzbek
302*0Sstevel@tonic-gate
303*0Sstevel@tonic-gatevi:Vietnamese
304*0Sstevel@tonic-gatevo:Volapuk
305*0Sstevel@tonic-gate
306*0Sstevel@tonic-gatewo:Wolof
307*0Sstevel@tonic-gate
308*0Sstevel@tonic-gatexh:Xhosa
309*0Sstevel@tonic-gate
310*0Sstevel@tonic-gateyi:Yiddish
311*0Sstevel@tonic-gateyo:Yoruba
312*0Sstevel@tonic-gate
313*0Sstevel@tonic-gateza:Zhuang
314*0Sstevel@tonic-gatezh:Chinese
315*0Sstevel@tonic-gatezu:Zulu
316