59177427 |
1 | <?php |
1fd97780 |
2 | |
35586184 |
3 | /** |
4 | * i18n.php |
5 | * |
15e6162e |
6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * This file contains variuos functions that are needed to do |
10 | * internationalization of SquirrelMail. |
11 | * |
12 | * Internally the output character set is used. Other characters are |
13 | * encoded using Unicode entities according to HTML 4.0. |
14 | * |
15 | * $Id$ |
16 | */ |
17 | |
a2a7852b |
18 | /* Decodes a string to the internal encoding from the given charset */ |
19 | function charset_decode ($charset, $string) { |
6fbd125b |
20 | global $languages, $squirrelmail_language; |
a2a7852b |
21 | |
3714db45 |
22 | if (isset($languages[$squirrelmail_language]['XTRA_CODE']) && |
23 | function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) { |
6fbd125b |
24 | $string = $languages[$squirrelmail_language]['XTRA_CODE']('decode', $string); |
25 | } |
b05c8961 |
26 | |
a2a7852b |
27 | /* All HTML special characters are 7 bit and can be replaced first */ |
28 | $string = htmlspecialchars ($string); |
29 | |
30 | $charset = strtolower($charset); |
31 | |
a2a7852b |
32 | if (ereg('iso-8859-([[:digit:]]+)', $charset, $res)) { |
33 | if ($res[1] == '1') { |
34 | $ret = charset_decode_iso_8859_1 ($string); |
35 | } else if ($res[1] == '2') { |
36 | $ret = charset_decode_iso_8859_2 ($string); |
9be313d5 |
37 | } else if ($res[1] == '4') { |
38 | $ret = charset_decode_iso_8859_4 ($string); |
a2a7852b |
39 | } else if ($res[1] == '7') { |
40 | $ret = charset_decode_iso_8859_7 ($string); |
9be313d5 |
41 | } else if ($res[1] == '13') { |
42 | $ret = charset_decode_iso_8859_13 ($string); |
a2a7852b |
43 | } else if ($res[1] == '15') { |
44 | $ret = charset_decode_iso_8859_15 ($string); |
45 | } else { |
46 | $ret = charset_decode_iso_8859_default ($string); |
47 | } |
48 | } else if ($charset == 'ns_4551-1') { |
49 | $ret = charset_decode_ns_4551_1 ($string); |
50 | } else if ($charset == 'koi8-r') { |
51 | $ret = charset_decode_koi8r ($string); |
52 | } else if ($charset == 'windows-1251') { |
53 | $ret = charset_decode_koi8r ($string); |
54 | } else { |
55 | $ret = $string; |
56 | } |
57 | return( $ret ); |
58 | } |
59 | |
60 | /* |
61 | iso-8859-1 is the same as Latin 1 and is normally used |
62 | in western europe. |
63 | */ |
64 | function charset_decode_iso_8859_1 ($string) { |
65 | global $default_charset; |
13e0c649 |
66 | |
a2a7852b |
67 | if (strtolower($default_charset) <> 'iso-8859-1') { |
68 | /* Only do the slow convert if there are 8-bit characters */ |
69 | if (ereg("[\200-\377]", $string)) { |
066c374f |
70 | $string = str_replace("\201", '', $string); |
71 | $string = str_replace("\202", '‚', $string); |
72 | $string = str_replace("\203", 'ƒ', $string); |
73 | $string = str_replace("\204", '„', $string); |
74 | $string = str_replace("\205", '…', $string); |
75 | $string = str_replace("\206", '†', $string); |
76 | $string = str_replace("\207", '‡', $string); |
77 | $string = str_replace("\210", 'ˆ', $string); |
78 | $string = str_replace("\211", '‰', $string); |
79 | $string = str_replace("\212", 'Š', $string); |
80 | $string = str_replace("\213", '‹', $string); |
81 | $string = str_replace("\214", 'Œ', $string); |
82 | $string = str_replace("\215", '', $string); |
83 | $string = str_replace("\216", 'Ž', $string); |
84 | $string = str_replace("\217", '', $string); |
85 | $string = str_replace("\220", '', $string); |
86 | $string = str_replace("\221", '‘', $string); |
87 | $string = str_replace("\222", '’', $string); |
88 | $string = str_replace("\223", '“', $string); |
89 | $string = str_replace("\224", '”', $string); |
90 | $string = str_replace("\225", '•', $string); |
91 | $string = str_replace("\226", '–', $string); |
92 | $string = str_replace("\227", '—', $string); |
93 | $string = str_replace("\230", '˜', $string); |
94 | $string = str_replace("\231", '™', $string); |
95 | $string = str_replace("\232", 'š', $string); |
96 | $string = str_replace("\233", '›', $string); |
97 | $string = str_replace("\234", 'œ', $string); |
98 | $string = str_replace("\235", '', $string); |
99 | $string = str_replace("\236", 'ž', $string); |
100 | $string = str_replace("\237", 'Ÿ', $string); |
101 | $string = str_replace("\240", ' ', $string); |
102 | $string = str_replace("\241", '¡', $string); |
103 | $string = str_replace("\242", '¢', $string); |
104 | $string = str_replace("\243", '£', $string); |
105 | $string = str_replace("\244", '¤', $string); |
106 | $string = str_replace("\245", '¥', $string); |
107 | $string = str_replace("\246", '¦', $string); |
108 | $string = str_replace("\247", '§', $string); |
109 | $string = str_replace("\250", '¨', $string); |
110 | $string = str_replace("\251", '©', $string); |
111 | $string = str_replace("\252", 'ª', $string); |
112 | $string = str_replace("\253", '«', $string); |
113 | $string = str_replace("\254", '¬', $string); |
114 | $string = str_replace("\255", '­', $string); |
115 | $string = str_replace("\256", '®', $string); |
116 | $string = str_replace("\257", '¯', $string); |
117 | $string = str_replace("\260", '°', $string); |
118 | $string = str_replace("\261", '±', $string); |
119 | $string = str_replace("\262", '²', $string); |
120 | $string = str_replace("\263", '³', $string); |
121 | $string = str_replace("\264", '´', $string); |
122 | $string = str_replace("\265", 'µ', $string); |
123 | $string = str_replace("\266", '¶', $string); |
124 | $string = str_replace("\267", '·', $string); |
125 | $string = str_replace("\270", '¸', $string); |
126 | $string = str_replace("\271", '¹', $string); |
127 | $string = str_replace("\272", 'º', $string); |
128 | $string = str_replace("\273", '»', $string); |
129 | $string = str_replace("\274", '¼', $string); |
130 | $string = str_replace("\275", '½', $string); |
131 | $string = str_replace("\276", '¾', $string); |
132 | $string = str_replace("\277", '¿', $string); |
133 | $string = str_replace("\300", 'À', $string); |
134 | $string = str_replace("\301", 'Á', $string); |
135 | $string = str_replace("\302", 'Â', $string); |
136 | $string = str_replace("\303", 'Ã', $string); |
137 | $string = str_replace("\304", 'Ä', $string); |
138 | $string = str_replace("\305", 'Å', $string); |
139 | $string = str_replace("\306", 'Æ', $string); |
140 | $string = str_replace("\307", 'Ç', $string); |
141 | $string = str_replace("\310", 'È', $string); |
142 | $string = str_replace("\311", 'É', $string); |
143 | $string = str_replace("\312", 'Ê', $string); |
144 | $string = str_replace("\313", 'Ë', $string); |
145 | $string = str_replace("\314", 'Ì', $string); |
146 | $string = str_replace("\315", 'Í', $string); |
147 | $string = str_replace("\316", 'Î', $string); |
148 | $string = str_replace("\317", 'Ï', $string); |
149 | $string = str_replace("\320", 'Ð', $string); |
150 | $string = str_replace("\321", 'Ñ', $string); |
151 | $string = str_replace("\322", 'Ò', $string); |
152 | $string = str_replace("\323", 'Ó', $string); |
153 | $string = str_replace("\324", 'Ô', $string); |
154 | $string = str_replace("\325", 'Õ', $string); |
155 | $string = str_replace("\326", 'Ö', $string); |
156 | $string = str_replace("\327", '×', $string); |
157 | $string = str_replace("\330", 'Ø', $string); |
158 | $string = str_replace("\331", 'Ù', $string); |
159 | $string = str_replace("\332", 'Ú', $string); |
160 | $string = str_replace("\333", 'Û', $string); |
161 | $string = str_replace("\334", 'Ü', $string); |
162 | $string = str_replace("\335", 'Ý', $string); |
163 | $string = str_replace("\336", 'Þ', $string); |
164 | $string = str_replace("\337", 'ß', $string); |
165 | $string = str_replace("\340", 'à', $string); |
166 | $string = str_replace("\341", 'á', $string); |
167 | $string = str_replace("\342", 'â', $string); |
168 | $string = str_replace("\343", 'ã', $string); |
169 | $string = str_replace("\344", 'ä', $string); |
170 | $string = str_replace("\345", 'å', $string); |
171 | $string = str_replace("\346", 'æ', $string); |
172 | $string = str_replace("\347", 'ç', $string); |
173 | $string = str_replace("\350", 'è', $string); |
174 | $string = str_replace("\351", 'é', $string); |
175 | $string = str_replace("\352", 'ê', $string); |
176 | $string = str_replace("\353", 'ë', $string); |
177 | $string = str_replace("\354", 'ì', $string); |
178 | $string = str_replace("\355", 'í', $string); |
179 | $string = str_replace("\356", 'î', $string); |
180 | $string = str_replace("\357", 'ï', $string); |
181 | $string = str_replace("\360", 'ð', $string); |
182 | $string = str_replace("\361", 'ñ', $string); |
183 | $string = str_replace("\362", 'ò', $string); |
184 | $string = str_replace("\363", 'ó', $string); |
185 | $string = str_replace("\364", 'ô', $string); |
186 | $string = str_replace("\365", 'õ', $string); |
187 | $string = str_replace("\366", 'ö', $string); |
188 | $string = str_replace("\367", '÷', $string); |
189 | $string = str_replace("\370", 'ø', $string); |
190 | $string = str_replace("\371", 'ù', $string); |
191 | $string = str_replace("\372", 'ú', $string); |
192 | $string = str_replace("\373", 'û', $string); |
193 | $string = str_replace("\374", 'ü', $string); |
194 | $string = str_replace("\375", 'ý', $string); |
195 | $string = str_replace("\376", 'þ', $string); |
196 | $string = str_replace("\377", 'ÿ', $string); |
a2a7852b |
197 | } |
198 | } |
199 | |
200 | return ($string); |
201 | } |
202 | |
203 | /* iso-8859-2 is used for some eastern European languages */ |
204 | function charset_decode_iso_8859_2 ($string) { |
205 | global $default_charset; |
206 | |
207 | if (strtolower($default_charset) == 'iso-8859-2') |
208 | return $string; |
209 | |
210 | /* Only do the slow convert if there are 8-bit characters */ |
211 | if (! ereg("[\200-\377]", $string)) |
212 | return $string; |
213 | |
214 | /* NO-BREAK SPACE */ |
215 | $string = str_replace("\240", ' ', $string); |
216 | /* LATIN CAPITAL LETTER A WITH OGONEK */ |
217 | $string = str_replace("\241", 'Ą', $string); |
218 | /* BREVE */ |
219 | $string = str_replace("\242", '˘', $string); |
220 | // LATIN CAPITAL LETTER L WITH STROKE |
221 | $string = str_replace("\243", 'Ł', $string); |
222 | // CURRENCY SIGN |
223 | $string = str_replace("\244", '¤', $string); |
224 | // LATIN CAPITAL LETTER L WITH CARON |
225 | $string = str_replace("\245", 'Ľ', $string); |
226 | // LATIN CAPITAL LETTER S WITH ACUTE |
227 | $string = str_replace("\246", 'Ś', $string); |
228 | // SECTION SIGN |
229 | $string = str_replace("\247", '§', $string); |
230 | // DIAERESIS |
231 | $string = str_replace("\250", '¨', $string); |
232 | // LATIN CAPITAL LETTER S WITH CARON |
233 | $string = str_replace("\251", 'Š', $string); |
234 | // LATIN CAPITAL LETTER S WITH CEDILLA |
235 | $string = str_replace("\252", 'Ş', $string); |
236 | // LATIN CAPITAL LETTER T WITH CARON |
237 | $string = str_replace("\253", 'Ť', $string); |
238 | // LATIN CAPITAL LETTER Z WITH ACUTE |
239 | $string = str_replace("\254", 'Ź', $string); |
240 | // SOFT HYPHEN |
241 | $string = str_replace("\255", '­', $string); |
242 | // LATIN CAPITAL LETTER Z WITH CARON |
243 | $string = str_replace("\256", 'Ž', $string); |
244 | // LATIN CAPITAL LETTER Z WITH DOT ABOVE |
245 | $string = str_replace("\257", 'Ż', $string); |
246 | // DEGREE SIGN |
247 | $string = str_replace("\260", '°', $string); |
248 | // LATIN SMALL LETTER A WITH OGONEK |
249 | $string = str_replace("\261", 'ą', $string); |
250 | // OGONEK |
251 | $string = str_replace("\262", '˛', $string); |
252 | // LATIN SMALL LETTER L WITH STROKE |
253 | $string = str_replace("\263", 'ł', $string); |
254 | // ACUTE ACCENT |
255 | $string = str_replace("\264", '´', $string); |
256 | // LATIN SMALL LETTER L WITH CARON |
257 | $string = str_replace("\265", 'ľ', $string); |
258 | // LATIN SMALL LETTER S WITH ACUTE |
259 | $string = str_replace("\266", 'ś', $string); |
260 | // CARON |
261 | $string = str_replace("\267", 'ˇ', $string); |
262 | // CEDILLA |
263 | $string = str_replace("\270", '¸', $string); |
264 | // LATIN SMALL LETTER S WITH CARON |
265 | $string = str_replace("\271", 'š', $string); |
266 | // LATIN SMALL LETTER S WITH CEDILLA |
267 | $string = str_replace("\272", 'ş', $string); |
268 | // LATIN SMALL LETTER T WITH CARON |
269 | $string = str_replace("\273", 'ť', $string); |
270 | // LATIN SMALL LETTER Z WITH ACUTE |
271 | $string = str_replace("\274", 'ź', $string); |
272 | // DOUBLE ACUTE ACCENT |
273 | $string = str_replace("\275", '˝', $string); |
274 | // LATIN SMALL LETTER Z WITH CARON |
275 | $string = str_replace("\276", 'ž', $string); |
276 | // LATIN SMALL LETTER Z WITH DOT ABOVE |
277 | $string = str_replace("\277", 'ż', $string); |
278 | // LATIN CAPITAL LETTER R WITH ACUTE |
279 | $string = str_replace("\300", 'Ŕ', $string); |
280 | // LATIN CAPITAL LETTER A WITH ACUTE |
281 | $string = str_replace("\301", 'Á', $string); |
282 | // LATIN CAPITAL LETTER A WITH CIRCUMFLEX |
283 | $string = str_replace("\302", 'Â', $string); |
284 | // LATIN CAPITAL LETTER A WITH BREVE |
285 | $string = str_replace("\303", 'Ă', $string); |
286 | // LATIN CAPITAL LETTER A WITH DIAERESIS |
287 | $string = str_replace("\304", 'Ä', $string); |
288 | // LATIN CAPITAL LETTER L WITH ACUTE |
289 | $string = str_replace("\305", 'Ĺ', $string); |
290 | // LATIN CAPITAL LETTER C WITH ACUTE |
291 | $string = str_replace("\306", 'Ć', $string); |
292 | // LATIN CAPITAL LETTER C WITH CEDILLA |
293 | $string = str_replace("\307", 'Ç', $string); |
294 | // LATIN CAPITAL LETTER C WITH CARON |
295 | $string = str_replace("\310", 'Č', $string); |
296 | // LATIN CAPITAL LETTER E WITH ACUTE |
297 | $string = str_replace("\311", 'É', $string); |
298 | // LATIN CAPITAL LETTER E WITH OGONEK |
299 | $string = str_replace("\312", 'Ę', $string); |
300 | // LATIN CAPITAL LETTER E WITH DIAERESIS |
301 | $string = str_replace("\313", 'Ë', $string); |
302 | // LATIN CAPITAL LETTER E WITH CARON |
303 | $string = str_replace("\314", 'Ě', $string); |
304 | // LATIN CAPITAL LETTER I WITH ACUTE |
305 | $string = str_replace("\315", 'Í', $string); |
306 | // LATIN CAPITAL LETTER I WITH CIRCUMFLEX |
307 | $string = str_replace("\316", 'Î', $string); |
308 | // LATIN CAPITAL LETTER D WITH CARON |
309 | $string = str_replace("\317", 'Ď', $string); |
310 | // LATIN CAPITAL LETTER D WITH STROKE |
311 | $string = str_replace("\320", 'Đ', $string); |
312 | // LATIN CAPITAL LETTER N WITH ACUTE |
313 | $string = str_replace("\321", 'Ń', $string); |
314 | // LATIN CAPITAL LETTER N WITH CARON |
315 | $string = str_replace("\322", 'Ň', $string); |
316 | // LATIN CAPITAL LETTER O WITH ACUTE |
317 | $string = str_replace("\323", 'Ó', $string); |
318 | // LATIN CAPITAL LETTER O WITH CIRCUMFLEX |
319 | $string = str_replace("\324", 'Ô', $string); |
320 | // LATIN CAPITAL LETTER O WITH DOUBLE ACUTE |
321 | $string = str_replace("\325", 'Ő', $string); |
322 | // LATIN CAPITAL LETTER O WITH DIAERESIS |
323 | $string = str_replace("\326", 'Ö', $string); |
324 | // MULTIPLICATION SIGN |
325 | $string = str_replace("\327", '×', $string); |
326 | // LATIN CAPITAL LETTER R WITH CARON |
327 | $string = str_replace("\330", 'Ř', $string); |
328 | // LATIN CAPITAL LETTER U WITH RING ABOVE |
329 | $string = str_replace("\331", 'Ů', $string); |
330 | // LATIN CAPITAL LETTER U WITH ACUTE |
331 | $string = str_replace("\332", 'Ú', $string); |
332 | // LATIN CAPITAL LETTER U WITH DOUBLE ACUTE |
333 | $string = str_replace("\333", 'Ű', $string); |
334 | // LATIN CAPITAL LETTER U WITH DIAERESIS |
335 | $string = str_replace("\334", 'Ü', $string); |
336 | // LATIN CAPITAL LETTER Y WITH ACUTE |
337 | $string = str_replace("\335", 'Ý', $string); |
338 | // LATIN CAPITAL LETTER T WITH CEDILLA |
339 | $string = str_replace("\336", 'Ţ', $string); |
340 | // LATIN SMALL LETTER SHARP S |
341 | $string = str_replace("\337", 'ß', $string); |
342 | // LATIN SMALL LETTER R WITH ACUTE |
343 | $string = str_replace("\340", 'ŕ', $string); |
344 | // LATIN SMALL LETTER A WITH ACUTE |
345 | $string = str_replace("\341", 'á', $string); |
346 | // LATIN SMALL LETTER A WITH CIRCUMFLEX |
347 | $string = str_replace("\342", 'â', $string); |
348 | // LATIN SMALL LETTER A WITH BREVE |
349 | $string = str_replace("\343", 'ă', $string); |
350 | // LATIN SMALL LETTER A WITH DIAERESIS |
351 | $string = str_replace("\344", 'ä', $string); |
352 | // LATIN SMALL LETTER L WITH ACUTE |
353 | $string = str_replace("\345", 'ĺ', $string); |
354 | // LATIN SMALL LETTER C WITH ACUTE |
355 | $string = str_replace("\346", 'ć', $string); |
356 | // LATIN SMALL LETTER C WITH CEDILLA |
357 | $string = str_replace("\347", 'ç', $string); |
358 | // LATIN SMALL LETTER C WITH CARON |
359 | $string = str_replace("\350", 'č', $string); |
360 | // LATIN SMALL LETTER E WITH ACUTE |
361 | $string = str_replace("\351", 'é', $string); |
362 | // LATIN SMALL LETTER E WITH OGONEK |
363 | $string = str_replace("\352", 'ę', $string); |
364 | // LATIN SMALL LETTER E WITH DIAERESIS |
365 | $string = str_replace("\353", 'ë', $string); |
366 | // LATIN SMALL LETTER E WITH CARON |
367 | $string = str_replace("\354", 'ě', $string); |
368 | // LATIN SMALL LETTER I WITH ACUTE |
369 | $string = str_replace("\355", 'í', $string); |
370 | // LATIN SMALL LETTER I WITH CIRCUMFLEX |
371 | $string = str_replace("\356", 'î', $string); |
372 | // LATIN SMALL LETTER D WITH CARON |
373 | $string = str_replace("\357", 'ď', $string); |
374 | // LATIN SMALL LETTER D WITH STROKE |
375 | $string = str_replace("\360", 'đ', $string); |
376 | // LATIN SMALL LETTER N WITH ACUTE |
377 | $string = str_replace("\361", 'ń', $string); |
378 | // LATIN SMALL LETTER N WITH CARON |
379 | $string = str_replace("\362", 'ň', $string); |
380 | // LATIN SMALL LETTER O WITH ACUTE |
381 | $string = str_replace("\363", 'ó', $string); |
382 | // LATIN SMALL LETTER O WITH CIRCUMFLEX |
383 | $string = str_replace("\364", 'ô', $string); |
384 | // LATIN SMALL LETTER O WITH DOUBLE ACUTE |
385 | $string = str_replace("\365", 'ő', $string); |
386 | // LATIN SMALL LETTER O WITH DIAERESIS |
387 | $string = str_replace("\366", 'ö', $string); |
388 | // DIVISION SIGN |
389 | $string = str_replace("\367", '÷', $string); |
390 | // LATIN SMALL LETTER R WITH CARON |
391 | $string = str_replace("\370", 'ř', $string); |
392 | // LATIN SMALL LETTER U WITH RING ABOVE |
393 | $string = str_replace("\371", 'ů', $string); |
394 | // LATIN SMALL LETTER U WITH ACUTE |
395 | $string = str_replace("\372", 'ú', $string); |
396 | // LATIN SMALL LETTER U WITH DOUBLE ACUTE |
397 | $string = str_replace("\373", 'ű', $string); |
398 | // LATIN SMALL LETTER U WITH DIAERESIS |
399 | $string = str_replace("\374", 'ü', $string); |
400 | // LATIN SMALL LETTER Y WITH ACUTE |
401 | $string = str_replace("\375", 'ý', $string); |
402 | // LATIN SMALL LETTER T WITH CEDILLA |
403 | $string = str_replace("\376", 'ţ', $string); |
404 | // DOT ABOVE |
405 | $string = str_replace("\377", '˙', $string); |
406 | |
407 | return $string; |
408 | } |
409 | |
9be313d5 |
410 | /* |
411 | iso-8859-4 is Baltic codeset used in some email clients |
412 | instead of iso-8859-13 in Lithuania |
413 | only Lithuanian charactes are added. |
414 | */ |
415 | |
416 | function charset_decode_iso_8859_4 ($string) { |
417 | // latin capital a with ogonek |
418 | $string = str_replace ("\241", 'Ą', $string); |
419 | // latin capital c with caron |
420 | $string = str_replace ("\310", 'Č', $string); |
421 | // latin capital e with ogonek |
422 | $string = str_replace ("\312", 'Ę', $string); |
423 | // latin capital e with dot above |
424 | $string = str_replace ("\314", 'Ė', $string); |
425 | // latin capital i with ogonek |
426 | $string = str_replace ("\307", 'Į', $string); |
427 | // latin capital s with caron |
428 | $string = str_replace ("\251", 'Š', $string); |
429 | // latin capital u with ogonek |
430 | $string = str_replace ("\331", 'Ų', $string); |
431 | // latin capital u with macron |
432 | $string = str_replace ("\336", 'Ū', $string); |
433 | // latin capital z with caron |
434 | $string = str_replace ("\256", 'Ž', $string); |
435 | // latin small a with ogonek |
436 | $string = str_replace ("\261", 'ą', $string); |
437 | // latin small c with caron |
438 | $string = str_replace ("\350", 'č', $string); |
439 | // latin small e with ogonek |
440 | $string = str_replace ("\352", 'ę', $string); |
441 | // latin small e with dot above |
442 | $string = str_replace ("\354", 'ė', $string); |
443 | // latin small i with ogonek |
444 | $string = str_replace ("\347", 'į', $string); |
445 | // latin small s with caron |
446 | $string = str_replace ("\271", 'š', $string); |
447 | // latin small u with ogonek |
448 | $string = str_replace ("\371", 'ų', $string); |
449 | // latin small u with macron |
450 | $string = str_replace ("\376", 'ū', $string); |
451 | // latin small z with caron |
452 | $string = str_replace ("\276", 'ž', $string); |
453 | |
454 | return (charset_decode_iso_8859_1($string)); |
455 | } |
456 | |
a2a7852b |
457 | /* iso-8859-7 is Greek. */ |
458 | function charset_decode_iso_8859_7 ($string) { |
459 | global $default_charset; |
460 | |
461 | if (strtolower($default_charset) == 'iso-8859-7') { |
462 | return $string; |
463 | } |
464 | |
465 | /* Only do the slow convert if there are 8-bit characters */ |
466 | if (!ereg("[\200-\377]", $string)) { |
467 | return $string; |
468 | } |
469 | |
470 | /* Some diverse characters in the beginning */ |
471 | $string = str_replace("\240", ' ', $string); |
472 | $string = str_replace("\241", '‘', $string); |
473 | $string = str_replace("\242", '’', $string); |
474 | $string = str_replace("\243", '£', $string); |
475 | $string = str_replace("\246", '¦', $string); |
476 | $string = str_replace("\247", '§', $string); |
477 | $string = str_replace("\250", '¨', $string); |
478 | $string = str_replace("\251", '©', $string); |
479 | $string = str_replace("\253", '«', $string); |
480 | $string = str_replace("\254", '¬', $string); |
481 | $string = str_replace("\255", '­', $string); |
482 | $string = str_replace("\257", '―', $string); |
483 | $string = str_replace("\260", '°', $string); |
484 | $string = str_replace("\261", '±', $string); |
485 | $string = str_replace("\262", '²', $string); |
486 | $string = str_replace("\263", '³', $string); |
487 | |
488 | /* Horizontal bar (parentheki pavla) */ |
489 | $string = str_replace ("\257", '―', $string); |
490 | |
491 | /* |
492 | * ISO-8859-7 characters from 11/04 (0xB4) to 11/06 (0xB6) |
493 | * These are Unicode 900-902 |
494 | */ |
620f6b8b |
495 | $string = preg_replace("/([\264-\266])/",'&#' . (ord(\\1)+720),$string); |
49c17806 |
496 | |
a2a7852b |
497 | /* 11/07 (0xB7) Middle dot is the same in iso-8859-1 */ |
498 | $string = str_replace("\267", '·', $string); |
499 | |
500 | /* |
501 | * ISO-8859-7 characters from 11/08 (0xB8) to 11/10 (0xBA) |
502 | * These are Unicode 900-902 |
503 | */ |
620f6b8b |
504 | $string = preg_replace("/([\270-\272])/",'&#' . (ord(\\1)+720),$string); |
a2a7852b |
505 | |
506 | /* |
507 | * 11/11 (0xBB) Right angle quotation mark is the same as in |
508 | * iso-8859-1 |
509 | */ |
510 | $string = str_replace("\273", '»', $string); |
511 | |
512 | /* And now the rest of the charset */ |
620f6b8b |
513 | $string = preg_replace("/([\274-\376])/",'&#' . (ord(\\1)+720),$string); |
a2a7852b |
514 | |
515 | return $string; |
516 | } |
517 | |
518 | /* |
9be313d5 |
519 | iso-8859-13 codeset used in Lithuania |
520 | only Lithuanian charactes are added. |
521 | */ |
522 | |
523 | function charset_decode_iso_8859_13 ($string) { |
524 | // latin capital a with ogonek |
525 | $string = str_replace ("\300", 'Ą', $string); |
526 | // latin capital c with caron |
527 | $string = str_replace ("\310", 'Č', $string); |
528 | // latin capital e with ogonek |
529 | $string = str_replace ("\306", 'Ę', $string); |
530 | // latin capital e with dot above |
531 | $string = str_replace ("\313", 'Ė', $string); |
532 | // latin capital i with ogonek |
533 | $string = str_replace ("\301", 'Į', $string); |
534 | // latin capital s with caron |
535 | $string = str_replace ("\320", 'Š', $string); |
536 | // latin capital u with ogonek |
537 | $string = str_replace ("\330", 'Ų', $string); |
538 | // latin capital u with macron |
539 | $string = str_replace ("\333", 'Ū', $string); |
540 | // latin capital z with caron |
541 | $string = str_replace ("\336", 'Ž', $string); |
542 | // latin small a with ogonek |
543 | $string = str_replace ("\340", 'ą', $string); |
544 | // latin small c with caron |
545 | $string = str_replace ("\350", 'č', $string); |
546 | // latin small e with ogonek |
547 | $string = str_replace ("\346", 'ę', $string); |
548 | // latin small e with dot above |
549 | $string = str_replace ("\353", 'ė', $string); |
550 | // latin small i with ogonek |
551 | $string = str_replace ("\341", 'į', $string); |
552 | // latin small s with caron |
553 | $string = str_replace ("\360", 'š', $string); |
554 | // latin small u with ogonek |
555 | $string = str_replace ("\370", 'ų', $string); |
556 | // latin small u with macron |
557 | $string = str_replace ("\373", 'ū', $string); |
558 | // latin small z with caron |
559 | $string = str_replace ("\376", 'ž', $string); |
560 | |
561 | return (charset_decode_iso_8859_1($string)); |
562 | } |
563 | |
564 | /* |
a2a7852b |
565 | * iso-8859-15 is Latin 9 and has very much the same use as Latin 1 |
566 | * but has the Euro symbol and some characters needed for French. |
567 | */ |
568 | function charset_decode_iso_8859_15 ($string) { |
569 | // Euro sign |
570 | $string = str_replace ("\244", '€', $string); |
571 | // Latin capital letter S with caron |
84556805 |
572 | $string = str_replace ("\246", 'Š', $string); |
a2a7852b |
573 | // Latin small letter s with caron |
574 | $string = str_replace ("\250", 'š', $string); |
575 | // Latin capital letter Z with caron |
576 | $string = str_replace ("\264", 'Ž', $string); |
577 | // Latin small letter z with caron |
578 | $string = str_replace ("\270", 'ž', $string); |
579 | // Latin capital ligature OE |
580 | $string = str_replace ("\274", 'Œ', $string); |
581 | // Latin small ligature oe |
582 | $string = str_replace ("\275", 'œ', $string); |
583 | // Latin capital letter Y with diaeresis |
584 | $string = str_replace ("\276", 'Ÿ', $string); |
585 | |
586 | return (charset_decode_iso_8859_1($string)); |
587 | } |
588 | |
84556805 |
589 | /* ISO-8859-5 is Cyrillic */ |
a2a7852b |
590 | function charset_decode_iso_8859_5 ($string) { |
591 | // Convert to KOI8-R, then return this decoded. |
592 | $string = convert_cyr_string($string, 'i', 'k'); |
593 | return charset_decode_koi8r($string); |
594 | } |
595 | |
596 | /* Remove all 8 bit characters from all other ISO-8859 character sets */ |
597 | function charset_decode_iso_8859_default ($string) { |
598 | return (strtr($string, "\240\241\242\243\244\245\246\247". |
1fd97780 |
599 | "\250\251\252\253\254\255\256\257". |
600 | "\260\261\262\263\264\265\266\267". |
601 | "\270\271\272\273\274\275\276\277". |
602 | "\300\301\302\303\304\305\306\307". |
603 | "\310\311\312\313\314\315\316\317". |
604 | "\320\321\322\323\324\325\326\327". |
605 | "\330\331\332\333\334\335\336\337". |
606 | "\340\341\342\343\344\345\346\347". |
607 | "\350\351\352\353\354\355\356\357". |
608 | "\360\361\362\363\364\365\366\367". |
a2a7852b |
609 | "\370\371\372\373\374\375\376\377", |
1fd97780 |
610 | "????????????????????????????????????????". |
611 | "????????????????????????????????????????". |
612 | "????????????????????????????????????????". |
613 | "????????")); |
a2a7852b |
614 | |
615 | } |
616 | |
617 | /* |
618 | * This is the same as ISO-646-NO and is used by some |
619 | * Microsoft programs when sending Norwegian characters |
620 | */ |
621 | function charset_decode_ns_4551_1 ($string) { |
622 | /* |
623 | * These characters are: |
624 | * Latin capital letter AE |
625 | * Latin capital letter O with stroke |
626 | * Latin capital letter A with ring above |
627 | * and the same as small letters |
628 | */ |
629 | return strtr ($string, "[\\]{|}", "ÆØÅæøå"); |
630 | } |
631 | |
632 | /* |
633 | * KOI8-R is used to encode Russian mail (Cyrrilic). Defined in RFC |
634 | * 1489. |
635 | */ |
636 | function charset_decode_koi8r ($string) { |
637 | global $default_charset; |
638 | |
639 | if ($default_charset == 'koi8-r') { |
640 | return $string; |
641 | } |
642 | |
643 | /* |
644 | * Convert to Unicode HTML entities. |
645 | * This code is rather ineffective. |
646 | */ |
647 | $string = str_replace("\200", '─', $string); |
648 | $string = str_replace("\201", '│', $string); |
649 | $string = str_replace("\202", '┌', $string); |
650 | $string = str_replace("\203", '┐', $string); |
651 | $string = str_replace("\204", '└', $string); |
652 | $string = str_replace("\205", '┘', $string); |
653 | $string = str_replace("\206", '├', $string); |
654 | $string = str_replace("\207", '┤', $string); |
655 | $string = str_replace("\210", '┬', $string); |
656 | $string = str_replace("\211", '┴', $string); |
657 | $string = str_replace("\212", '┼', $string); |
658 | $string = str_replace("\213", '▀', $string); |
659 | $string = str_replace("\214", '▄', $string); |
660 | $string = str_replace("\215", '█', $string); |
661 | $string = str_replace("\216", '▌', $string); |
662 | $string = str_replace("\217", '▐', $string); |
663 | $string = str_replace("\220", '░', $string); |
664 | $string = str_replace("\221", '▒', $string); |
665 | $string = str_replace("\222", '▓', $string); |
666 | $string = str_replace("\223", '⌠', $string); |
667 | $string = str_replace("\224", '■', $string); |
668 | $string = str_replace("\225", '∙', $string); |
669 | $string = str_replace("\226", '√', $string); |
670 | $string = str_replace("\227", '≈', $string); |
671 | $string = str_replace("\230", '≤', $string); |
672 | $string = str_replace("\231", '≥', $string); |
673 | $string = str_replace("\232", ' ', $string); |
674 | $string = str_replace("\233", '⌡', $string); |
675 | $string = str_replace("\234", '°', $string); |
676 | $string = str_replace("\235", '²', $string); |
677 | $string = str_replace("\236", '·', $string); |
678 | $string = str_replace("\237", '÷', $string); |
679 | $string = str_replace("\240", '═', $string); |
680 | $string = str_replace("\241", '║', $string); |
681 | $string = str_replace("\242", '╒', $string); |
682 | $string = str_replace("\243", 'ё', $string); |
683 | $string = str_replace("\244", '╓', $string); |
684 | $string = str_replace("\245", '╔', $string); |
685 | $string = str_replace("\246", '╕', $string); |
686 | $string = str_replace("\247", '╖', $string); |
687 | $string = str_replace("\250", '╗', $string); |
688 | $string = str_replace("\251", '╘', $string); |
689 | $string = str_replace("\252", '╙', $string); |
690 | $string = str_replace("\253", '╚', $string); |
691 | $string = str_replace("\254", '╛', $string); |
692 | $string = str_replace("\255", '╜', $string); |
693 | $string = str_replace("\256", '╝', $string); |
694 | $string = str_replace("\257", '╞', $string); |
695 | $string = str_replace("\260", '╟', $string); |
696 | $string = str_replace("\261", '╠', $string); |
697 | $string = str_replace("\262", '╡', $string); |
698 | $string = str_replace("\263", 'Ё', $string); |
699 | $string = str_replace("\264", '╢', $string); |
700 | $string = str_replace("\265", '╣', $string); |
701 | $string = str_replace("\266", '╤', $string); |
702 | $string = str_replace("\267", '╥', $string); |
703 | $string = str_replace("\270", '╦', $string); |
704 | $string = str_replace("\271", '╧', $string); |
705 | $string = str_replace("\272", '╨', $string); |
706 | $string = str_replace("\273", '╩', $string); |
707 | $string = str_replace("\274", '╪', $string); |
708 | $string = str_replace("\275", '╫', $string); |
709 | $string = str_replace("\276", '╬', $string); |
710 | $string = str_replace("\277", '©', $string); |
711 | $string = str_replace("\300", 'ю', $string); |
712 | $string = str_replace("\301", 'а', $string); |
713 | $string = str_replace("\302", 'б', $string); |
714 | $string = str_replace("\303", 'ц', $string); |
715 | $string = str_replace("\304", 'д', $string); |
716 | $string = str_replace("\305", 'е', $string); |
717 | $string = str_replace("\306", 'ф', $string); |
718 | $string = str_replace("\307", 'г', $string); |
719 | $string = str_replace("\310", 'х', $string); |
720 | $string = str_replace("\311", 'и', $string); |
721 | $string = str_replace("\312", 'й', $string); |
722 | $string = str_replace("\313", 'к', $string); |
723 | $string = str_replace("\314", 'л', $string); |
724 | $string = str_replace("\315", 'м', $string); |
725 | $string = str_replace("\316", 'н', $string); |
726 | $string = str_replace("\317", 'о', $string); |
727 | $string = str_replace("\320", 'п', $string); |
728 | $string = str_replace("\321", 'я', $string); |
729 | $string = str_replace("\322", 'р', $string); |
730 | $string = str_replace("\323", 'с', $string); |
731 | $string = str_replace("\324", 'т', $string); |
732 | $string = str_replace("\325", 'у', $string); |
733 | $string = str_replace("\326", 'ж', $string); |
734 | $string = str_replace("\327", 'в', $string); |
735 | $string = str_replace("\330", 'ь', $string); |
736 | $string = str_replace("\331", 'ы', $string); |
737 | $string = str_replace("\332", 'з', $string); |
738 | $string = str_replace("\333", 'ш', $string); |
739 | $string = str_replace("\334", 'э', $string); |
740 | $string = str_replace("\335", 'щ', $string); |
741 | $string = str_replace("\336", 'ч', $string); |
742 | $string = str_replace("\337", 'ъ', $string); |
743 | $string = str_replace("\340", 'Ю', $string); |
744 | $string = str_replace("\341", 'А', $string); |
745 | $string = str_replace("\342", 'Б', $string); |
746 | $string = str_replace("\343", 'Ц', $string); |
747 | $string = str_replace("\344", 'Д', $string); |
748 | $string = str_replace("\345", 'Е', $string); |
749 | $string = str_replace("\346", 'Ф', $string); |
750 | $string = str_replace("\347", 'Г', $string); |
751 | $string = str_replace("\350", 'Х', $string); |
752 | $string = str_replace("\351", 'И', $string); |
753 | $string = str_replace("\352", 'Й', $string); |
754 | $string = str_replace("\353", 'К', $string); |
755 | $string = str_replace("\354", 'Л', $string); |
756 | $string = str_replace("\355", 'М', $string); |
757 | $string = str_replace("\356", 'Н', $string); |
758 | $string = str_replace("\357", 'О', $string); |
759 | $string = str_replace("\360", 'П', $string); |
760 | $string = str_replace("\361", 'Я', $string); |
761 | $string = str_replace("\362", 'Р', $string); |
762 | $string = str_replace("\363", 'С', $string); |
763 | $string = str_replace("\364", 'Т', $string); |
764 | $string = str_replace("\365", 'У', $string); |
765 | $string = str_replace("\366", 'Ж', $string); |
766 | $string = str_replace("\367", 'В', $string); |
767 | $string = str_replace("\370", 'Ь', $string); |
768 | $string = str_replace("\371", 'Ы', $string); |
769 | $string = str_replace("\372", 'З', $string); |
770 | $string = str_replace("\373", 'Ш', $string); |
771 | $string = str_replace("\374", 'Э', $string); |
772 | $string = str_replace("\375", 'Щ', $string); |
773 | $string = str_replace("\376", 'Ч', $string); |
774 | $string = str_replace("\377", 'Ъ', $string); |
775 | |
776 | return $string; |
777 | } |
778 | |
6fbd125b |
779 | |
a2a7852b |
780 | /* |
781 | * Set up the language to be output |
782 | * if $do_search is true, then scan the browser information |
783 | * for a possible language that we know |
784 | */ |
785 | function set_up_language($sm_language, $do_search = false) { |
786 | |
787 | static $SetupAlready = 0; |
9eb0fbd4 |
788 | global $use_gettext, $languages, |
a2a7852b |
789 | $squirrelmail_language, $squirrelmail_default_language, |
790 | $sm_notAlias; |
791 | |
792 | if ($SetupAlready) { |
793 | return; |
794 | } |
5c920668 |
795 | $SetupAlready = TRUE; |
a2a7852b |
796 | |
9eb0fbd4 |
797 | if ($do_search && ! $sm_language && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
798 | $sm_language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); |
a2a7852b |
799 | } |
66d7950f |
800 | |
a2a7852b |
801 | if (!$sm_language && isset($squirrelmail_default_language)) { |
802 | $squirrelmail_language = $squirrelmail_default_language; |
66d7950f |
803 | $sm_language = $squirrelmail_default_language; |
a2a7852b |
804 | } |
805 | $sm_notAlias = $sm_language; |
806 | while (isset($languages[$sm_notAlias]['ALIAS'])) { |
807 | $sm_notAlias = $languages[$sm_notAlias]['ALIAS']; |
808 | } |
809 | |
88cb1b4d |
810 | if ( isset($sm_language) && |
5c920668 |
811 | $use_gettext && |
812 | $sm_language != '' && |
813 | isset($languages[$sm_notAlias]['CHARSET']) ) { |
814 | bindtextdomain( 'squirrelmail', '../locale/' ); |
88cb1b4d |
815 | textdomain( 'squirrelmail' ); |
816 | if ( !ini_get('safe_mode') && |
5c920668 |
817 | getenv( 'LC_ALL' ) != $sm_notAlias ) { |
818 | putenv( "LC_ALL=$sm_notAlias" ); |
819 | putenv( "LANG=$sm_notAlias" ); |
820 | putenv( "LANGUAGE=$sm_notAlias" ); |
a2a7852b |
821 | } |
88cb1b4d |
822 | setlocale(LC_ALL, $sm_notAlias); |
5c920668 |
823 | $squirrelmail_language = $sm_notAlias; |
538f1ab7 |
824 | if ($squirrelmail_language == 'ja_JP' && function_exists('mb_detect_encoding') ) { |
b05c8961 |
825 | header ('Content-Type: text/html; charset=EUC-JP'); |
826 | if (!function_exists('mb_internal_encoding')) { |
827 | echo _("You need to have php4 installed with the multibyte string function enabled (using configure option --with-mbstring)."); |
828 | } |
829 | mb_internal_encoding('EUC-JP'); |
830 | mb_http_output('pass'); |
831 | } else { |
5c920668 |
832 | header( 'Content-Type: text/html; charset=' . $languages[$sm_notAlias]['CHARSET'] ); |
a2a7852b |
833 | } |
834 | } |
b05c8961 |
835 | } |
a2a7852b |
836 | |
837 | function set_my_charset(){ |
838 | |
839 | /* |
840 | * There can be a $default_charset setting in the |
841 | * config.php file, but the user may have a different language |
842 | * selected for a user interface. This function checks the |
843 | * language selected by the user and tags the outgoing messages |
844 | * with the appropriate charset corresponding to the language |
845 | * selection. This is "more right" (tm), than just stamping the |
846 | * message blindly with the system-wide $default_charset. |
847 | */ |
848 | global $data_dir, $username, $default_charset, $languages; |
88cb1b4d |
849 | |
a2a7852b |
850 | $my_language = getPref($data_dir, $username, 'language'); |
5c920668 |
851 | if (!$my_language) { |
852 | return; |
853 | } |
a2a7852b |
854 | while (isset($languages[$my_language]['ALIAS'])) { |
f7e8861e |
855 | $my_language = $languages[$my_language]['ALIAS']; |
a2a7852b |
856 | } |
5c920668 |
857 | $my_charset = $languages[$my_language]['CHARSET']; |
a2a7852b |
858 | if ($my_charset) { |
859 | $default_charset = $my_charset; |
860 | } |
861 | } |
862 | |
a2a7852b |
863 | /* ------------------------------ main --------------------------- */ |
864 | |
5c920668 |
865 | global $squirrelmail_language, $languages, $use_gettext; |
866 | |
a2a7852b |
867 | if (! isset($squirrelmail_language)) { |
868 | $squirrelmail_language = ''; |
869 | } |
870 | |
871 | /* This array specifies the available languages. */ |
5c920668 |
872 | |
873 | // The glibc locale is ca_ES. |
874 | |
875 | $languages['ca_ES']['NAME'] = 'Catalan'; |
876 | $languages['ca_ES']['CHARSET'] = 'iso-8859-1'; |
877 | $languages['ca']['ALIAS'] = 'ca_ES'; |
878 | |
a2a7852b |
879 | $languages['cs_CZ']['NAME'] = 'Czech'; |
880 | $languages['cs_CZ']['CHARSET'] = 'iso-8859-2'; |
881 | $languages['cs']['ALIAS'] = 'cs_CZ'; |
a2a7852b |
882 | |
5c920668 |
883 | // Danish locale is da_DK. |
884 | |
885 | $languages['da_DK']['NAME'] = 'Danish'; |
886 | $languages['da_DK']['CHARSET'] = 'iso-8859-1'; |
887 | $languages['da']['ALIAS'] = 'da_DK'; |
888 | |
889 | $languages['de_DE']['NAME'] = 'Deutsch'; |
890 | $languages['de_DE']['CHARSET'] = 'iso-8859-1'; |
891 | $languages['de']['ALIAS'] = 'de_DE'; |
a2a7852b |
892 | |
5c920668 |
893 | // There is no en_EN! There is en_US, en_BR, en_AU, and so forth, |
894 | // but who cares about !US, right? Right? :) |
a2a7852b |
895 | |
5c920668 |
896 | $languages['en_US']['NAME'] = 'English'; |
897 | $languages['en_US']['CHARSET'] = 'iso-8859-1'; |
898 | $languages['en']['ALIAS'] = 'en_US'; |
a2a7852b |
899 | |
5c920668 |
900 | $languages['es_ES']['NAME'] = 'Spanish'; |
901 | $languages['es_ES']['CHARSET'] = 'iso-8859-1'; |
902 | $languages['es']['ALIAS'] = 'es_ES'; |
a2a7852b |
903 | |
5c920668 |
904 | $languages['et_EE']['NAME'] = 'Estonian'; |
905 | $languages['et_EE']['CHARSET'] = 'iso-8859-15'; |
906 | $languages['et']['ALIAS'] = 'et_EE'; |
a2a7852b |
907 | |
5c920668 |
908 | $languages['fi_FI']['NAME'] = 'Finnish'; |
909 | $languages['fi_FI']['CHARSET'] = 'iso-8859-1'; |
910 | $languages['fi']['ALIAS'] = 'fi_FI'; |
a2a7852b |
911 | |
5c920668 |
912 | $languages['fr_FR']['NAME'] = 'French'; |
913 | $languages['fr_FR']['CHARSET'] = 'iso-8859-1'; |
914 | $languages['fr']['ALIAS'] = 'fr_FR'; |
a2a7852b |
915 | |
5c920668 |
916 | $languages['hr_HR']['NAME'] = 'Croatian'; |
917 | $languages['hr_HR']['CHARSET'] = 'iso-8859-2'; |
918 | $languages['hr']['ALIAS'] = 'hr_HR'; |
a2a7852b |
919 | |
5c920668 |
920 | $languages['hu_HU']['NAME'] = 'Hungarian'; |
921 | $languages['hu_HU']['CHARSET'] = 'iso-8859-2'; |
922 | $languages['hu']['ALIAS'] = 'hu_HU'; |
a2a7852b |
923 | |
5c920668 |
924 | $languages['id_ID']['NAME'] = 'Indonesian'; |
925 | $languages['id_ID']['CHARSET'] = 'iso-8859-1'; |
926 | $languages['id']['ALIAS'] = 'id_ID'; |
a2a7852b |
927 | |
5c920668 |
928 | $languages['is_IS']['NAME'] = 'Icelandic'; |
929 | $languages['is_IS']['CHARSET'] = 'iso-8859-1'; |
930 | $languages['is']['ALIAS'] = 'is_IS'; |
a2a7852b |
931 | |
5c920668 |
932 | $languages['it_IT']['NAME'] = 'Italian'; |
933 | $languages['it_IT']['CHARSET'] = 'iso-8859-1'; |
934 | $languages['it']['ALIAS'] = 'it_IT'; |
a2a7852b |
935 | |
b05c8961 |
936 | $languages['ja_JP']['NAME'] = 'Japanese'; |
937 | $languages['ja_JP']['CHARSET'] = 'iso-2022-jp'; |
6fbd125b |
938 | $languages['ja_JP']['XTRA_CODE'] = 'japanese_charset_xtra'; |
b05c8961 |
939 | $languages['ja']['ALIAS'] = 'ja_JP'; |
940 | |
5c920668 |
941 | $languages['ko_KR']['NAME'] = 'Korean'; |
942 | $languages['ko_KR']['CHARSET'] = 'euc-KR'; |
1d33e35e |
943 | $languages['ko_KR']['XTRA_CODE'] = 'korean_charset_xtra'; |
5c920668 |
944 | $languages['ko']['ALIAS'] = 'ko_KR'; |
a2a7852b |
945 | |
5c920668 |
946 | $languages['nl_NL']['NAME'] = 'Dutch'; |
947 | $languages['nl_NL']['CHARSET'] = 'iso-8859-1'; |
948 | $languages['nl']['ALIAS'] = 'nl_NL'; |
a2a7852b |
949 | |
5c920668 |
950 | $languages['no_NO']['NAME'] = 'Norwegian (Bokmål)'; |
951 | $languages['no_NO']['CHARSET'] = 'iso-8859-1'; |
952 | $languages['no']['ALIAS'] = 'no_NO'; |
b8b4ac4a |
953 | $languages['nn_NO']['NAME'] = 'Norwegian (Nynorsk)'; |
954 | $languages['nn_NO']['CHARSET'] = 'iso-8859-1'; |
a2a7852b |
955 | |
5c920668 |
956 | $languages['pl_PL']['NAME'] = 'Polish'; |
957 | $languages['pl_PL']['CHARSET'] = 'iso-8859-2'; |
958 | $languages['pl']['ALIAS'] = 'pl_PL'; |
a2a7852b |
959 | |
5c920668 |
960 | $languages['pt_PT']['NAME'] = 'Portuguese (Portugal)'; |
961 | $languages['pt_PT']['CHARSET'] = 'iso-8859-1'; |
a2a7852b |
962 | $languages['pt_BR']['NAME'] = 'Portuguese (Brazil)'; |
963 | $languages['pt_BR']['CHARSET'] = 'iso-8859-1'; |
5c920668 |
964 | $languages['pt']['ALIAS'] = 'pt_PT'; |
a2a7852b |
965 | |
5c920668 |
966 | $languages['ru_RU']['NAME'] = 'Russian'; |
967 | $languages['ru_RU']['CHARSET'] = 'koi8-r'; |
968 | $languages['ru']['ALIAS'] = 'ru_RU'; |
a2a7852b |
969 | |
dbec0d67 |
970 | $languages['sr_YU']['NAME'] = 'Serbian'; |
971 | $languages['sr_YU']['CHARSET'] = 'iso-8859-2'; |
972 | $languages['sr']['ALIAS'] = 'sr_YU'; |
a2a7852b |
973 | |
5c920668 |
974 | $languages['sv_SE']['NAME'] = 'Swedish'; |
975 | $languages['sv_SE']['CHARSET'] = 'iso-8859-1'; |
976 | $languages['sv']['ALIAS'] = 'sv_SE'; |
a2a7852b |
977 | |
5c920668 |
978 | $languages['tr_TR']['NAME'] = 'Turkish'; |
979 | $languages['tr_TR']['CHARSET'] = 'iso-8859-9'; |
980 | $languages['tr']['ALIAS'] = 'tr_TR'; |
a2a7852b |
981 | |
5c920668 |
982 | $languages['zh_TW']['NAME'] = 'Taiwan'; |
983 | $languages['zh_TW']['CHARSET'] = 'big5'; |
984 | $languages['tw']['ALIAS'] = 'zh_TW'; |
a2a7852b |
985 | |
8ba79a3b |
986 | $languages['zh_TW']['NAME'] = 'Chinese'; |
987 | $languages['zh_TW']['CHARSET'] = 'gb2312'; |
988 | $languages['tw']['ALIAS'] = 'zh_CN'; |
989 | |
a2a7852b |
990 | $languages['sk_SK']['NAME'] = 'Slovak'; |
991 | $languages['sk_SK']['CHARSET'] = 'iso-8859-2'; |
992 | $languages['sk']['ALIAS'] = 'sk_SK'; |
993 | |
5c920668 |
994 | $languages['ro_RO']['NAME'] = 'Romanian'; |
995 | $languages['ro_RO']['CHARSET'] = 'iso-8859-2'; |
996 | $languages['ro']['ALIAS'] = 'ro_RO'; |
a2a7852b |
997 | |
5c920668 |
998 | $languages['th_TH']['NAME'] = 'Thai'; |
999 | $languages['th_TH']['CHARSET'] = 'tis-620'; |
1000 | $languages['th']['ALIAS'] = 'th_TH'; |
a2a7852b |
1001 | |
5c920668 |
1002 | $languages['lt_LT']['NAME'] = 'Lithuanian'; |
1003 | $languages['lt_LT']['CHARSET'] = 'iso-8859-13'; |
1004 | $languages['lt']['ALIAS'] = 'lt_LT'; |
a2a7852b |
1005 | |
5c920668 |
1006 | $languages['sl_SI']['NAME'] = 'Slovenian'; |
1007 | $languages['sl_SI']['CHARSET'] = 'iso-8859-2'; |
1008 | $languages['sl']['ALIAS'] = 'sl_SI'; |
a2a7852b |
1009 | |
5c920668 |
1010 | $languages['bg_BG']['NAME'] = 'Bulgarian'; |
1011 | $languages['bg_BG']['CHARSET'] = 'windows-1251'; |
1012 | $languages['bg']['ALIAS'] = 'bg_BG'; |
a2a7852b |
1013 | |
d3b57948 |
1014 | // Right to left languages |
1015 | |
1016 | $languages['he_HE']['NAME'] = 'Hebrew'; |
1017 | $languages['he_HE']['CHARSET'] = 'windows-1255'; |
1018 | $languages['he_HE']['DIR'] = 'rtl'; |
1019 | $languages['he']['ALIAS'] = 'he_HE'; |
1020 | |
1021 | |
5c920668 |
1022 | /* Detect whether gettext is installed. */ |
a2a7852b |
1023 | $gettext_flags = 0; |
1024 | if (function_exists('_')) { |
1025 | $gettext_flags += 1; |
1026 | } |
1027 | if (function_exists('bindtextdomain')) { |
1028 | $gettext_flags += 2; |
1029 | } |
1030 | if (function_exists('textdomain')) { |
1031 | $gettext_flags += 4; |
1032 | } |
1033 | |
5c920668 |
1034 | /* If gettext is fully loaded, cool */ |
a2a7852b |
1035 | if ($gettext_flags == 7) { |
1036 | $use_gettext = true; |
1037 | } |
5c920668 |
1038 | /* If we can fake gettext, try that */ |
a2a7852b |
1039 | elseif ($gettext_flags == 0) { |
1040 | $use_gettext = true; |
e7ab8c9d |
1041 | include_once(SM_PATH . 'functions/gettext.php'); |
a2a7852b |
1042 | } else { |
5c920668 |
1043 | /* Uh-ho. A weird install */ |
a2a7852b |
1044 | if (! $gettext_flags & 1) { |
1045 | function _($str) { |
1046 | return $str; |
1047 | } |
1048 | } |
1049 | if (! $gettext_flags & 2) { |
1050 | function bindtextdomain() { |
1051 | return; |
1052 | } |
1053 | } |
1054 | if (! $gettext_flags & 4) { |
1055 | function textdomain() { |
1056 | return; |
1057 | } |
1058 | } |
1059 | } |
1060 | |
1d33e35e |
1061 | |
1062 | /* |
1063 | * Japanese charset extra function |
1064 | * |
1065 | */ |
1066 | function japanese_charset_xtra() { |
1067 | $ret = func_get_arg(1); /* default return value */ |
1068 | if (function_exists('mb_detect_encoding')) { |
1069 | switch (func_get_arg(0)) { /* action */ |
1070 | case 'decode': |
1071 | $detect_encoding = mb_detect_encoding($ret); |
1072 | if ($detect_encoding == 'JIS' || |
1073 | $detect_encoding == 'EUC-JP' || |
1074 | $detect_encoding == 'SJIS') { |
1075 | |
1076 | $ret = mb_convert_encoding($ret, 'EUC-JP', 'AUTO'); |
1077 | } |
1078 | break; |
1079 | case 'encode': |
1080 | $detect_encoding = mb_detect_encoding($ret); |
1081 | if ($detect_encoding == 'JIS' || |
1082 | $detect_encoding == 'EUC-JP' || |
1083 | $detect_encoding == 'SJIS') { |
1084 | |
1085 | $ret = mb_convert_encoding($ret, 'JIS', 'AUTO'); |
1086 | } |
1087 | break; |
1088 | case 'strimwidth': |
1089 | $width = func_get_arg(2); |
1090 | $ret = mb_strimwidth($ret, 0, $width, '...'); |
1091 | break; |
1092 | case 'encodeheader': |
8ba05cbe |
1093 | $result = ''; |
1094 | if (strlen($ret) > 0) { |
1095 | $tmpstr = mb_substr($ret, 0, 1); |
1096 | $prevcsize = strlen($tmpstr); |
1097 | for ($i = 1; $i < mb_strlen($ret); $i++) { |
1098 | $tmp = mb_substr($ret, $i, 1); |
1099 | if (strlen($tmp) == $prevcsize) { |
1100 | $tmpstr .= $tmp; |
1101 | } else { |
1102 | if ($prevcsize == 1) { |
1103 | $result .= $tmpstr; |
1104 | } else { |
1105 | $result .= mb_encode_mimeheader($tmpstr); |
1106 | } |
1107 | $tmpstr = $tmp; |
1108 | $prevcsize = strlen($tmp); |
1109 | } |
1110 | } |
1111 | if (strlen($tmpstr)) { |
1112 | if (strlen(mb_substr($tmpstr, 0, 1)) == 1) |
1113 | $result .= $tmpstr; |
1114 | else |
1115 | $result .= mb_encode_mimeheader($tmpstr); |
1116 | } |
1117 | } |
1118 | $ret = $result; |
1119 | //$ret = mb_encode_mimeheader($ret); |
1d33e35e |
1120 | break; |
1121 | case 'decodeheader': |
1122 | $ret = str_replace("\t", "", $ret); |
1123 | if (eregi('=\\?([^?]+)\\?(q|b)\\?([^?]+)\\?=', $ret)) |
1124 | $ret = mb_decode_mimeheader($ret); |
1125 | $ret = mb_convert_encoding($ret, 'EUC-JP', 'AUTO'); |
1126 | break; |
1127 | case 'downloadfilename': |
1128 | $useragent = func_get_arg(2); |
1129 | if (strstr($useragent, 'Windows') !== false || |
1130 | strstr($useragent, 'Mac_') !== false) { |
1131 | $ret = mb_convert_encoding($ret, 'SJIS', 'AUTO'); |
1132 | } else { |
1133 | $ret = mb_convert_encoding($ret, 'EUC-JP', 'AUTO'); |
1134 | } |
1135 | break; |
1136 | } |
1137 | } |
1138 | return $ret; |
1139 | } |
1140 | |
1141 | |
1142 | /* |
1143 | * Korean charset extra function |
1144 | * Hangul(Korean Character) Attached File Name Fix. |
1145 | */ |
1146 | function korean_charset_xtra() { |
1147 | |
1148 | $ret = func_get_arg(1); /* default return value */ |
1149 | if (func_get_arg(0) == 'downloadfilename') { /* action */ |
1150 | $ret = str_replace("\x0D\x0A", '', $ret); /* Hanmail's CR/LF Clear */ |
1151 | for ($i=0;$i<strlen($ret);$i++) { |
1152 | if ($ret[$i] >= "\xA1" && $ret[$i] <= "\xFE") { /* 0xA1 - 0XFE are Valid */ |
1153 | $i++; |
1154 | continue; |
1155 | } else if (($ret[$i] >= 'a' && $ret[$i] <= 'z') || /* From Original ereg_replace in download.php */ |
1156 | ($ret[$i] >= 'A' && $ret[$i] <= 'Z') || |
1157 | ($ret[$i] == '.') || ($ret[$i] == '-')) { |
1158 | continue; |
1159 | } else { |
1160 | $ret[$i] = '_'; |
1161 | } |
1162 | } |
1163 | |
1164 | } |
1165 | |
1166 | return $ret; |
1167 | } |
1168 | |
e7ab8c9d |
1169 | ?> |