source: gsdl/trunk/perllib/lang.pm@ 15894

Last change on this file since 15894 was 15894, checked in by mdewsnip, 13 years ago

Added "use strict" to the files missing it.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 5.6 KB
Line 
1###########################################################################
2#
3# lang.pm --
4# A component of the Greenstone digital library software
5# from the New Zealand Digital Library Project at the
6# University of Waikato, New Zealand.
7#
8# Copyright (C) 1999 New Zealand Digital Library Project
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23#
24###########################################################################
25
26# this module translates language descriptions to and from
27# the ISO 639 standard
28
29package lang;
30
31use strict;
32
33@lang::trans = (["ab", "Abkhazian"], ["om", "Afan Oromo"],
34 ["om", "Oromo"], ["aa", "Afar"],
35 ["af", "Afrikaans"], ["sq", "Albanian"],
36 ["am", "Amharic"], ["ar", "Arabic"],
37 ["hy", "Armenian"], ["as", "Assamese"],
38 ["ay", "Aymara"], ["az", "Azerbaijani"],
39
40 ["ba", "Bashkir"], ["eu", "Basque"],
41 ["bn", "Bengali"], ["bn", "Bangla"],
42 ["dz", "Bhutani"], ["bh", "Bihari"],
43 ["bi", "Bislama"], ["br", "Breton"],
44 ["bg", "Bulgarian"], ["my", "Burmese"],
45 ["be", "Byelorussian"],
46
47 ["km", "Cambodian"], ["ca", "Catalan"],
48 ["zh", "Chinese"], ["co", "Corsican"],
49 ["hr", "Croatian"], ["cs", "Czech"],
50
51 ["da", "Danish"], ["nl", "Dutch"],
52
53 ["en", "English"], ["eo", "Esperanto"],
54 ["et", "Estonian"], ["fo", "Faroese"],
55 ["fj", "Fijian"], ["fi", "Finnish"],
56 ["fr", "French"], ["fy", "Frisian"],
57
58 ["gl", "Galician"], ["ka", "Georgian"],
59 ["de", "German"], ["el", "Greek"],
60 ["kl", "Greenlandic"], ["gn", "Guarani"],
61 ["gu", "Gujarati"],
62
63 ["ha", "Hausa"], ["iw", "Hebrew"],
64 ["hi", "Hindi"], ["hu", "Hungarian"],
65
66 ["is", "Icelandic"], ["in", "Indonesian"],
67 ["ia", "Interlingua"], ["ie", "Interlingue"],
68 ["ik", "Inupiak"], ["ga", "Irish"],
69 ["it", "Italian"],
70
71 ["ja", "Japanese"], ["jv", "Javanese"],
72
73 ["kn", "Kannada"], ["ks", "Kashmiri"],
74 ["kk", "Kazakh"], ["rw", "Kinyarwanda"],
75 ["ky", "Kirghiz"], ["rn", "Kirundi"],
76 ["ko", "Korean"], ["ku", "Kurdish"],
77
78 ["lo", "Laothian"], ["la", "Latin"],
79 ["lv", "Latvian"], ["lv", "Lettish"],
80 ["ln", "Lingala"], ["lt", "Lithuanian"],
81
82 ["mk", "Macedonian"], ["mg", "Malagasy"],
83 ["ms", "Malay"], ["ml", "Malayalam"],
84 ["mt", "Maltese"], ["mi", "Maori"],
85 ["mr", "Marathi"], ["mo", "Moldavian"],
86 ["mn", "Mongolian"],
87
88 ["na", "Nauru"], ["ne", "Nepali"],
89 ["no", "Norwegian"],
90
91 ["oc", "Occitan"], ["or", "Oriya"],
92
93 ["ps", "Pashto"], ["ps", "Pushto"],
94 ["fa", "Persian"], ["pl", "Polish"],
95 ["pt", "Portuguese"], ["pa", "Punjabi"],
96
97 ["qu", "Quechua"],
98
99 ["rm", "Rhaeto-Romance"], ["ro", "Romanian"],
100 ["ru", "Russian"],
101
102 ["sm", "Samoan"], ["sg", "Sangho"],
103 ["sa", "Sanskrit"], ["gd", "Scots Gaelic"],
104 ["sr", "Serbian"], ["sh", "Serbo-Croatian"],
105 ["st", "Sesotho"], ["tn", "Setswana"],
106 ["sn", "Shona"], ["sd", "Sindhi"],
107 ["si", "Singhalese"], ["ss", "Siswati"],
108 ["sk", "Slovak"], ["sl", "Slovenian"],
109 ["so", "Somali"], ["es", "Spanish"],
110 ["su", "Sundanese"], ["sw", "Swahili"],
111 ["sv", "Swedish"],
112
113 ["tl", "Tagalog"], ["tg", "Tajik"],
114 ["ta", "Tamil"], ["tt", "Tatar"],
115 ["te", "Telugu"], ["th", "Thai"],
116 ["bo", "Tibetan"], ["ti", "Tigrinya"],
117 ["to", "Tonga"], ["ts", "Tsonga"],
118 ["tr", "Turkish"], ["tk", "Turkmen"],
119 ["tw", "Twi"],
120
121 ["uk", "Ukrainian"], ["ur", "Urdu"],
122 ["uz", "Uzbek"],
123
124 ["vi", "Vietnamese"], ["vo", "Volapuk"],
125
126 ["cy", "Welsh"], ["wo", "Wolof"],
127
128 ["xh", "Xhosa"],
129
130 ["ji", "Yiddish"], ["yo", "Yoruba"],
131
132 ["zu", "Zulu"]);
133
134
135sub one_english_to_iso639 {
136 my ($english) = @_;
137 my $iso639 = "";
138
139 foreach my $lang (@lang::trans) {
140 my $code = $lang->[0];
141 my $enname = $lang->[1];
142 if ($english =~ /^\s*($code|$enname)\s*$/i) {
143 # found the language
144 $iso639 = $code;
145 last;
146
147 }
148 }
149
150 return $iso639;
151}
152
153
154sub english_to_iso639 {
155 my ($englishlist) = @_;
156 my ($english);
157
158 my @englishlist = split (",", $englishlist);
159 my @iso639list = ();
160
161 foreach my $english (@englishlist) {
162 push (@iso639list, &one_english_to_iso639($english));
163 }
164
165 return join (",", @iso639list);
166}
167
168
169sub one_iso639_to_english {
170 my ($iso639) = @_;
171 my $english = "";
172
173 foreach my $lang (@lang::trans) {
174 my $code = $lang->[0];
175 my $enname = $lang->[1];
176 if ($iso639 =~ /\s*($code|$enname)\s*$/i) {
177 # found the language
178 $english = $enname;
179 last;
180
181 }
182 }
183
184 return $english;
185}
186
187
188sub iso639_to_english {
189 my ($iso639list) = @_;
190 my ($iso639);
191
192 my @iso639list = split (",", $iso639list);
193 my @englishlist = ();
194
195 foreach $iso639 (@iso639list) {
196 push (@englishlist, &one_iso639_to_english($iso639));
197 }
198
199 return join (",", @englishlist);
200}
201
202
2031;
Note: See TracBrowser for help on using the repository browser.