updated russian translation
[squirrelmail.git] / functions / i18n.php
CommitLineData
59177427 1<?php
1fd97780 2
3/**
4 ** i18n.php
5 **
6 ** This file contains variuos functions that are needed to do
7 ** internationalization of SquirrelMail.
8 **
c1d54dc7 9 ** Internally the output character set is used. Other characters are
10 ** encoded using Unicode entities according to HTML 4.0.
173ed887 11 **
1fd97780 12 **/
13
14 $i18n_php = true;
15
d30d79f2 16 // This array specifies the available languages.
e8816411 17 $languages["en"]["NAME"] = "English";
cf7be4f2 18 $languages["en"]["CHARSET"] = "iso-8859-1";
3196a4f7 19 $languages["no"]["NAME"] = "Norwegian (Bokm&aring;l)";
e8816411 20 $languages["no"]["CHARSET"] = "iso-8859-1";
3196a4f7 21 $languages["no_NO_ny"]["NAME"] = "Norwegian (Nynorsk)";
22 $languages["no_NO_ny"]["CHARSET"] = "iso-8859-1";
62d9ff4d 23 $languages["de"]["NAME"] = "Deutsch";
e8816411 24 $languages["de"]["CHARSET"] = "iso-8859-1";
25 $languages["ru"]["NAME"] = "Russian KOI8-R";
26 $languages["ru"]["CHARSET"] = "koi8-r";
f3b155fd 27 $languages["pl"]["NAME"] = "Polish";
28 $languages["pl"]["CHARSET"] = "iso-8859-2";
46812a3a 29 $languages["sv"]["NAME"] = "Swedish";
fba22d17 30 $languages["sv"]["CHARSET"] = "iso-8859-1";
43161dcc 31 $languages["nl"]["NAME"] = "Dutch";
32 $languages["nl"]["CHARSET"] = "iso-8859-1";
22ef7536 33 $languages["pt_BR"]["NAME"] = "Portuguese (Brazil)";
70ed9428 34 $languages["pt_BR"]["CHARSET"] = "iso-8859-1";
2a54aa37 35 $languages["fr"]["NAME"] = "French";
36 $languages["fr"]["CHARSET"] = "iso-8859-1";
4c973296 37 $languages["it"]["NAME"] = "Italian";
38 $languages["it"]["CHARSET"] = "iso-8859-1";
a9af0166 39 $languages["cs_CZ"]["NAME"] = "Czech";
40 $languages["cs_CZ"]["CHARSET"] = "iso-8859-2";
76e6ff64 41 $languages["es"]["NAME"] = "Spanish";
42 $languages["es"]["CHARSET"] = "iso-8859-1";
a77ef4c9 43 $languages["ko"]["NAME"] = "Korean";
44 $languages["ko"]["CHARSET"] = "euc-KR";
bafefd39 45 $languages["ca"]["NAME"] = "Catalan";
46 $languages["ca"]["CHARSET"] = "iso-8859-1";
cf7be4f2 47 $languages["sr"]["NAME"] = "Serbian";
48 $languages["sr"]["CHARSET"] = "iso-8859-2";
49 $languages["tw"]["NAME"] = "Taiwan";
50 $languages["tw"]["CHARSET"] = "big5";
51 $languages["da"]["NAME"] = "Danish";
52 $languages["da"]["CHARSET"] = "iso-8859-1";
b80a4da6 53 $languages["fi"]["NAME"] = "Finnish";
54 $languages["fi"]["CHARSET"] = "iso-8859-1";
d30d79f2 55
1fd97780 56 // Decodes a string to the internal encoding from the given charset
57 function charset_decode ($charset, $string) {
e4a256af 58 global $debug_mime;
59
1fd97780 60 // All HTML special characters are 7 bit and can be replaced first
61 $string = htmlspecialchars ($string);
62
44139266 63 $charset = strtolower($charset);
1fd97780 64
e4a256af 65 if ($debug_mime) $string = $charset.":".$string;
66
3309f5b9 67 if (ereg("iso-8859-([[:digit:]]+)", $charset, $res)) {
1fd97780 68 if ($res[1] == "1")
69 return charset_decode_iso_8859_1 ($string);
e9d611cb 70 else if ($res[1] == "2")
a89c13f5 71 return charset_decode_iso_8859_2 ($string);
e9d611cb 72 else if ($res[1] == "7")
173ed887 73 return charset_decode_iso_8859_7 ($string);
1fd97780 74 else if ($res[1] == "15")
75 return charset_decode_iso_8859_15 ($string);
76 else
77 return charset_decode_iso_8859_default ($string);
78 } else if ($charset == "ns_4551-1") {
79 return charset_decode_ns_4551_1 ($string);
17ce8467 80 } else if ($charset == "koi8-r") {
81 return charset_decode_koi8r ($string);
209e2f82 82 } else
8c5a2cb2 83 return "$string";
1fd97780 84 }
85
86 // iso-8859-1 is the same as Latin 1 and is normally used
87 // in western europe.
88 function charset_decode_iso_8859_1 ($string) {
04563822 89 global $default_charset;
1fd97780 90
04563822 91 if (strtolower($default_charset) == "iso-8859-1") {
92 return $string;
93 } else {
94 // Only do the slow convert if there are 8-bit characters
95 if (ereg("[\200-\377]", $string)) {
96 $string = str_replace("\201", "&#129;", $string);
97 $string = str_replace("\202", "&#130;", $string);
98 $string = str_replace("\203", "&#131;", $string);
99 $string = str_replace("\204", "&#132;", $string);
100 $string = str_replace("\205", "&#133;", $string);
101 $string = str_replace("\206", "&#134;", $string);
102 $string = str_replace("\207", "&#135;", $string);
103 $string = str_replace("\210", "&#136;", $string);
104 $string = str_replace("\211", "&#137;", $string);
105 $string = str_replace("\212", "&#138;", $string);
106 $string = str_replace("\213", "&#139;", $string);
107 $string = str_replace("\214", "&#140;", $string);
108 $string = str_replace("\215", "&#141;", $string);
109 $string = str_replace("\216", "&#142;", $string);
110 $string = str_replace("\217", "&#143;", $string);
111 $string = str_replace("\220", "&#144;", $string);
112 $string = str_replace("\221", "&#145;", $string);
113 $string = str_replace("\222", "&#146;", $string);
114 $string = str_replace("\223", "&#147;", $string);
115 $string = str_replace("\224", "&#148;", $string);
116 $string = str_replace("\225", "&#149;", $string);
117 $string = str_replace("\226", "&#150;", $string);
118 $string = str_replace("\227", "&#151;", $string);
119 $string = str_replace("\230", "&#152;", $string);
120 $string = str_replace("\231", "&#153;", $string);
121 $string = str_replace("\232", "&#154;", $string);
122 $string = str_replace("\233", "&#155;", $string);
123 $string = str_replace("\234", "&#156;", $string);
124 $string = str_replace("\235", "&#157;", $string);
125 $string = str_replace("\236", "&#158;", $string);
126 $string = str_replace("\237", "&#159;", $string);
127 $string = str_replace("\240", "&#160;", $string);
128 $string = str_replace("\241", "&#161;", $string);
129 $string = str_replace("\242", "&#162;", $string);
130 $string = str_replace("\243", "&#163;", $string);
131 $string = str_replace("\244", "&#164;", $string);
132 $string = str_replace("\245", "&#165;", $string);
133 $string = str_replace("\246", "&#166;", $string);
134 $string = str_replace("\247", "&#167;", $string);
135 $string = str_replace("\250", "&#168;", $string);
136 $string = str_replace("\251", "&#169;", $string);
137 $string = str_replace("\252", "&#170;", $string);
138 $string = str_replace("\253", "&#171;", $string);
139 $string = str_replace("\254", "&#172;", $string);
140 $string = str_replace("\255", "&#173;", $string);
141 $string = str_replace("\256", "&#174;", $string);
142 $string = str_replace("\257", "&#175;", $string);
143 $string = str_replace("\260", "&#176;", $string);
144 $string = str_replace("\261", "&#177;", $string);
145 $string = str_replace("\262", "&#178;", $string);
146 $string = str_replace("\263", "&#179;", $string);
147 $string = str_replace("\264", "&#180;", $string);
148 $string = str_replace("\265", "&#181;", $string);
149 $string = str_replace("\266", "&#182;", $string);
150 $string = str_replace("\267", "&#183;", $string);
151 $string = str_replace("\270", "&#184;", $string);
152 $string = str_replace("\271", "&#185;", $string);
153 $string = str_replace("\272", "&#186;", $string);
154 $string = str_replace("\273", "&#187;", $string);
155 $string = str_replace("\274", "&#188;", $string);
156 $string = str_replace("\275", "&#189;", $string);
157 $string = str_replace("\276", "&#190;", $string);
158 $string = str_replace("\277", "&#191;", $string);
159 $string = str_replace("\300", "&#192;", $string);
160 $string = str_replace("\301", "&#193;", $string);
161 $string = str_replace("\302", "&#194;", $string);
162 $string = str_replace("\303", "&#195;", $string);
163 $string = str_replace("\304", "&#196;", $string);
164 $string = str_replace("\305", "&#197;", $string);
165 $string = str_replace("\306", "&#198;", $string);
166 $string = str_replace("\307", "&#199;", $string);
167 $string = str_replace("\310", "&#200;", $string);
168 $string = str_replace("\311", "&#201;", $string);
169 $string = str_replace("\312", "&#202;", $string);
170 $string = str_replace("\313", "&#203;", $string);
171 $string = str_replace("\314", "&#204;", $string);
172 $string = str_replace("\315", "&#205;", $string);
173 $string = str_replace("\316", "&#206;", $string);
174 $string = str_replace("\317", "&#207;", $string);
175 $string = str_replace("\320", "&#208;", $string);
176 $string = str_replace("\321", "&#209;", $string);
177 $string = str_replace("\322", "&#210;", $string);
178 $string = str_replace("\323", "&#211;", $string);
179 $string = str_replace("\324", "&#212;", $string);
180 $string = str_replace("\325", "&#213;", $string);
181 $string = str_replace("\326", "&#214;", $string);
182 $string = str_replace("\327", "&#215;", $string);
183 $string = str_replace("\330", "&#216;", $string);
184 $string = str_replace("\331", "&#217;", $string);
185 $string = str_replace("\332", "&#218;", $string);
186 $string = str_replace("\333", "&#219;", $string);
187 $string = str_replace("\334", "&#220;", $string);
188 $string = str_replace("\335", "&#221;", $string);
189 $string = str_replace("\336", "&#222;", $string);
190 $string = str_replace("\337", "&#223;", $string);
191 $string = str_replace("\340", "&#224;", $string);
192 $string = str_replace("\341", "&#225;", $string);
193 $string = str_replace("\342", "&#226;", $string);
194 $string = str_replace("\343", "&#227;", $string);
195 $string = str_replace("\344", "&#228;", $string);
196 $string = str_replace("\345", "&#229;", $string);
197 $string = str_replace("\346", "&#230;", $string);
198 $string = str_replace("\347", "&#231;", $string);
199 $string = str_replace("\350", "&#232;", $string);
200 $string = str_replace("\351", "&#233;", $string);
201 $string = str_replace("\352", "&#234;", $string);
202 $string = str_replace("\353", "&#235;", $string);
203 $string = str_replace("\354", "&#236;", $string);
204 $string = str_replace("\355", "&#237;", $string);
205 $string = str_replace("\356", "&#238;", $string);
206 $string = str_replace("\357", "&#239;", $string);
207 $string = str_replace("\360", "&#240;", $string);
208 $string = str_replace("\361", "&#241;", $string);
209 $string = str_replace("\362", "&#242;", $string);
210 $string = str_replace("\363", "&#243;", $string);
211 $string = str_replace("\364", "&#244;", $string);
212 $string = str_replace("\365", "&#245;", $string);
213 $string = str_replace("\366", "&#246;", $string);
214 $string = str_replace("\367", "&#247;", $string);
215 $string = str_replace("\370", "&#248;", $string);
216 $string = str_replace("\371", "&#249;", $string);
217 $string = str_replace("\372", "&#250;", $string);
218 $string = str_replace("\373", "&#251;", $string);
219 $string = str_replace("\374", "&#252;", $string);
220 $string = str_replace("\375", "&#253;", $string);
221 $string = str_replace("\376", "&#254;", $string);
222 $string = str_replace("\377", "&#255;", $string);
223 }
224 }
1fd97780 225
226 return ($string);
227 }
228
a89c13f5 229 // iso-8859-2 is used for some eastern European languages
230 function charset_decode_iso_8859_2 ($string) {
231 global $default_charset;
232
e9d611cb 233 if (strtolower($default_charset) == "iso-8859-2") {
a89c13f5 234 return $string;
235 } else {
236 // Only do the slow convert if there are 8-bit characters
237 if (ereg("[\200-\377]", $string)) {
238 // NO-BREAK SPACE
66488126 239 $string = str_replace("\240", "&#160;", $string);
a89c13f5 240 // LATIN CAPITAL LETTER A WITH OGONEK
66488126 241 $string = str_replace("\241", "&#260;", $string);
a89c13f5 242 // BREVE
66488126 243 $string = str_replace("\242", "&#728;", $string);
a89c13f5 244 // LATIN CAPITAL LETTER L WITH STROKE
66488126 245 $string = str_replace("\243", "&#321;", $string);
a89c13f5 246 // CURRENCY SIGN
66488126 247 $string = str_replace("\244", "&#164;", $string);
a89c13f5 248 // LATIN CAPITAL LETTER L WITH CARON
66488126 249 $string = str_replace("\245", "&#317;", $string);
a89c13f5 250 // LATIN CAPITAL LETTER S WITH ACUTE
66488126 251 $string = str_replace("\246", "&#346;", $string);
a89c13f5 252 // SECTION SIGN
66488126 253 $string = str_replace("\247", "&#167;", $string);
a89c13f5 254 // DIAERESIS
66488126 255 $string = str_replace("\250", "&#168;", $string);
a89c13f5 256 // LATIN CAPITAL LETTER S WITH CARON
66488126 257 $string = str_replace("\251", "&#352;", $string);
a89c13f5 258 // LATIN CAPITAL LETTER S WITH CEDILLA
66488126 259 $string = str_replace("\252", "&#350;", $string);
a89c13f5 260 // LATIN CAPITAL LETTER T WITH CARON
66488126 261 $string = str_replace("\253", "&#356;", $string);
a89c13f5 262 // LATIN CAPITAL LETTER Z WITH ACUTE
66488126 263 $string = str_replace("\254", "&#377;", $string);
a89c13f5 264 // SOFT HYPHEN
66488126 265 $string = str_replace("\255", "&#173;", $string);
a89c13f5 266 // LATIN CAPITAL LETTER Z WITH CARON
66488126 267 $string = str_replace("\256", "&#381;", $string);
a89c13f5 268 // LATIN CAPITAL LETTER Z WITH DOT ABOVE
66488126 269 $string = str_replace("\257", "&#379;", $string);
a89c13f5 270 // DEGREE SIGN
66488126 271 $string = str_replace("\260", "&#176;", $string);
a89c13f5 272 // LATIN SMALL LETTER A WITH OGONEK
66488126 273 $string = str_replace("\261", "&#261;", $string);
a89c13f5 274 // OGONEK
66488126 275 $string = str_replace("\262", "&#731;", $string);
a89c13f5 276 // LATIN SMALL LETTER L WITH STROKE
66488126 277 $string = str_replace("\263", "&#322;", $string);
a89c13f5 278 // ACUTE ACCENT
66488126 279 $string = str_replace("\264", "&#180;", $string);
a89c13f5 280 // LATIN SMALL LETTER L WITH CARON
66488126 281 $string = str_replace("\265", "&#318;", $string);
a89c13f5 282 // LATIN SMALL LETTER S WITH ACUTE
66488126 283 $string = str_replace("\266", "&#347;", $string);
a89c13f5 284 // CARON
66488126 285 $string = str_replace("\267", "&#711;", $string);
a89c13f5 286 // CEDILLA
66488126 287 $string = str_replace("\270", "&#184;", $string);
a89c13f5 288 // LATIN SMALL LETTER S WITH CARON
66488126 289 $string = str_replace("\271", "&#353;", $string);
a89c13f5 290 // LATIN SMALL LETTER S WITH CEDILLA
66488126 291 $string = str_replace("\272", "&#351;", $string);
a89c13f5 292 // LATIN SMALL LETTER T WITH CARON
66488126 293 $string = str_replace("\273", "&#357;", $string);
a89c13f5 294 // LATIN SMALL LETTER Z WITH ACUTE
66488126 295 $string = str_replace("\274", "&#378;", $string);
a89c13f5 296 // DOUBLE ACUTE ACCENT
66488126 297 $string = str_replace("\275", "&#733;", $string);
a89c13f5 298 // LATIN SMALL LETTER Z WITH CARON
66488126 299 $string = str_replace("\276", "&#382;", $string);
a89c13f5 300 // LATIN SMALL LETTER Z WITH DOT ABOVE
66488126 301 $string = str_replace("\277", "&#380;", $string);
a89c13f5 302 // LATIN CAPITAL LETTER R WITH ACUTE
66488126 303 $string = str_replace("\300", "&#340;", $string);
a89c13f5 304 // LATIN CAPITAL LETTER A WITH ACUTE
66488126 305 $string = str_replace("\301", "&#193;", $string);
a89c13f5 306 // LATIN CAPITAL LETTER A WITH CIRCUMFLEX
66488126 307 $string = str_replace("\302", "&#194;", $string);
a89c13f5 308 // LATIN CAPITAL LETTER A WITH BREVE
66488126 309 $string = str_replace("\303", "&#258;", $string);
a89c13f5 310 // LATIN CAPITAL LETTER A WITH DIAERESIS
66488126 311 $string = str_replace("\304", "&#196;", $string);
a89c13f5 312 // LATIN CAPITAL LETTER L WITH ACUTE
66488126 313 $string = str_replace("\305", "&#313;", $string);
a89c13f5 314 // LATIN CAPITAL LETTER C WITH ACUTE
66488126 315 $string = str_replace("\306", "&#262;", $string);
a89c13f5 316 // LATIN CAPITAL LETTER C WITH CEDILLA
66488126 317 $string = str_replace("\307", "&#199;", $string);
a89c13f5 318 // LATIN CAPITAL LETTER C WITH CARON
66488126 319 $string = str_replace("\310", "&#268;", $string);
a89c13f5 320 // LATIN CAPITAL LETTER E WITH ACUTE
66488126 321 $string = str_replace("\311", "&#201;", $string);
a89c13f5 322 // LATIN CAPITAL LETTER E WITH OGONEK
66488126 323 $string = str_replace("\312", "&#280;", $string);
a89c13f5 324 // LATIN CAPITAL LETTER E WITH DIAERESIS
66488126 325 $string = str_replace("\313", "&#203;", $string);
a89c13f5 326 // LATIN CAPITAL LETTER E WITH CARON
66488126 327 $string = str_replace("\314", "&#282;", $string);
a89c13f5 328 // LATIN CAPITAL LETTER I WITH ACUTE
66488126 329 $string = str_replace("\315", "&#205;", $string);
a89c13f5 330 // LATIN CAPITAL LETTER I WITH CIRCUMFLEX
66488126 331 $string = str_replace("\316", "&#206;", $string);
a89c13f5 332 // LATIN CAPITAL LETTER D WITH CARON
66488126 333 $string = str_replace("\317", "&#270;", $string);
a89c13f5 334 // LATIN CAPITAL LETTER D WITH STROKE
66488126 335 $string = str_replace("\320", "&#272;", $string);
a89c13f5 336 // LATIN CAPITAL LETTER N WITH ACUTE
66488126 337 $string = str_replace("\321", "&#323;", $string);
a89c13f5 338 // LATIN CAPITAL LETTER N WITH CARON
66488126 339 $string = str_replace("\322", "&#327;", $string);
a89c13f5 340 // LATIN CAPITAL LETTER O WITH ACUTE
66488126 341 $string = str_replace("\323", "&#211;", $string);
a89c13f5 342 // LATIN CAPITAL LETTER O WITH CIRCUMFLEX
66488126 343 $string = str_replace("\324", "&#212;", $string);
a89c13f5 344 // LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
66488126 345 $string = str_replace("\325", "&#336;", $string);
a89c13f5 346 // LATIN CAPITAL LETTER O WITH DIAERESIS
66488126 347 $string = str_replace("\326", "&#214;", $string);
a89c13f5 348 // MULTIPLICATION SIGN
66488126 349 $string = str_replace("\327", "&#215;", $string);
a89c13f5 350 // LATIN CAPITAL LETTER R WITH CARON
66488126 351 $string = str_replace("\330", "&#344;", $string);
a89c13f5 352 // LATIN CAPITAL LETTER U WITH RING ABOVE
66488126 353 $string = str_replace("\331", "&#366;", $string);
a89c13f5 354 // LATIN CAPITAL LETTER U WITH ACUTE
66488126 355 $string = str_replace("\332", "&#218;", $string);
a89c13f5 356 // LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
66488126 357 $string = str_replace("\333", "&#368;", $string);
a89c13f5 358 // LATIN CAPITAL LETTER U WITH DIAERESIS
66488126 359 $string = str_replace("\334", "&#220;", $string);
a89c13f5 360 // LATIN CAPITAL LETTER Y WITH ACUTE
66488126 361 $string = str_replace("\335", "&#221;", $string);
a89c13f5 362 // LATIN CAPITAL LETTER T WITH CEDILLA
66488126 363 $string = str_replace("\336", "&#354;", $string);
a89c13f5 364 // LATIN SMALL LETTER SHARP S
66488126 365 $string = str_replace("\337", "&#223;", $string);
a89c13f5 366 // LATIN SMALL LETTER R WITH ACUTE
66488126 367 $string = str_replace("\340", "&#341;", $string);
a89c13f5 368 // LATIN SMALL LETTER A WITH ACUTE
66488126 369 $string = str_replace("\341", "&#225;", $string);
a89c13f5 370 // LATIN SMALL LETTER A WITH CIRCUMFLEX
66488126 371 $string = str_replace("\342", "&#226;", $string);
a89c13f5 372 // LATIN SMALL LETTER A WITH BREVE
66488126 373 $string = str_replace("\343", "&#259;", $string);
a89c13f5 374 // LATIN SMALL LETTER A WITH DIAERESIS
66488126 375 $string = str_replace("\344", "&#228;", $string);
a89c13f5 376 // LATIN SMALL LETTER L WITH ACUTE
66488126 377 $string = str_replace("\345", "&#314;", $string);
a89c13f5 378 // LATIN SMALL LETTER C WITH ACUTE
66488126 379 $string = str_replace("\346", "&#263;", $string);
a89c13f5 380 // LATIN SMALL LETTER C WITH CEDILLA
66488126 381 $string = str_replace("\347", "&#231;", $string);
a89c13f5 382 // LATIN SMALL LETTER C WITH CARON
66488126 383 $string = str_replace("\350", "&#269;", $string);
a89c13f5 384 // LATIN SMALL LETTER E WITH ACUTE
66488126 385 $string = str_replace("\351", "&#233;", $string);
a89c13f5 386 // LATIN SMALL LETTER E WITH OGONEK
66488126 387 $string = str_replace("\352", "&#281;", $string);
a89c13f5 388 // LATIN SMALL LETTER E WITH DIAERESIS
66488126 389 $string = str_replace("\353", "&#235;", $string);
a89c13f5 390 // LATIN SMALL LETTER E WITH CARON
66488126 391 $string = str_replace("\354", "&#283;", $string);
a89c13f5 392 // LATIN SMALL LETTER I WITH ACUTE
66488126 393 $string = str_replace("\355", "&#237;", $string);
a89c13f5 394 // LATIN SMALL LETTER I WITH CIRCUMFLEX
66488126 395 $string = str_replace("\356", "&#238;", $string);
a89c13f5 396 // LATIN SMALL LETTER D WITH CARON
66488126 397 $string = str_replace("\357", "&#271;", $string);
a89c13f5 398 // LATIN SMALL LETTER D WITH STROKE
66488126 399 $string = str_replace("\360", "&#273;", $string);
a89c13f5 400 // LATIN SMALL LETTER N WITH ACUTE
66488126 401 $string = str_replace("\361", "&#324;", $string);
a89c13f5 402 // LATIN SMALL LETTER N WITH CARON
66488126 403 $string = str_replace("\362", "&#328;", $string);
a89c13f5 404 // LATIN SMALL LETTER O WITH ACUTE
66488126 405 $string = str_replace("\363", "&#243;", $string);
a89c13f5 406 // LATIN SMALL LETTER O WITH CIRCUMFLEX
66488126 407 $string = str_replace("\364", "&#244;", $string);
a89c13f5 408 // LATIN SMALL LETTER O WITH DOUBLE ACUTE
66488126 409 $string = str_replace("\365", "&#337;", $string);
a89c13f5 410 // LATIN SMALL LETTER O WITH DIAERESIS
66488126 411 $string = str_replace("\366", "&#246;", $string);
a89c13f5 412 // DIVISION SIGN
66488126 413 $string = str_replace("\367", "&#247;", $string);
a89c13f5 414 // LATIN SMALL LETTER R WITH CARON
66488126 415 $string = str_replace("\370", "&#345;", $string);
a89c13f5 416 // LATIN SMALL LETTER U WITH RING ABOVE
66488126 417 $string = str_replace("\371", "&#367;", $string);
a89c13f5 418 // LATIN SMALL LETTER U WITH ACUTE
66488126 419 $string = str_replace("\372", "&#250;", $string);
a89c13f5 420 // LATIN SMALL LETTER U WITH DOUBLE ACUTE
66488126 421 $string = str_replace("\373", "&#369;", $string);
a89c13f5 422 // LATIN SMALL LETTER U WITH DIAERESIS
66488126 423 $string = str_replace("\374", "&#252;", $string);
a89c13f5 424 // LATIN SMALL LETTER Y WITH ACUTE
66488126 425 $string = str_replace("\375", "&#253;", $string);
a89c13f5 426 // LATIN SMALL LETTER T WITH CEDILLA
66488126 427 $string = str_replace("\376", "&#355;", $string);
a89c13f5 428 // DOT ABOVE
66488126 429 $string = str_replace("\377", "&#729;", $string);
a89c13f5 430 }
431 }
432 return $string;
433 }
434
0a86e9f3 435 // iso-8859-7 is Greek.
209e2f82 436 function charset_decode_iso_8859_7 ($string) {
04563822 437 global $default_charset;
173ed887 438
04563822 439 if (strtolower($default_charset) == "iso-8859-7") {
440 return $string;
441 } else {
442 // Only do the slow convert if there are 8-bit characters
443 if (ereg("[\200-\377]", $string)) {
444 // Some diverse characters in the beginning
445 $string = str_replace("\240", "&#160;", $string);
446 $string = str_replace("\241", "&#8216;", $string);
447 $string = str_replace("\242", "&#8217;", $string);
448 $string = str_replace("\243", "&#163;", $string);
449 $string = str_replace("\246", "&#166;", $string);
450 $string = str_replace("\247", "&#167;", $string);
451 $string = str_replace("\250", "&#168;", $string);
452 $string = str_replace("\251", "&#169;", $string);
453 $string = str_replace("\253", "&#171;", $string);
454 $string = str_replace("\254", "&#172;", $string);
455 $string = str_replace("\255", "&#173;", $string);
456 $string = str_replace("\257", "&#8213;", $string);
457 $string = str_replace("\260", "&#176;", $string);
458 $string = str_replace("\261", "&#177;", $string);
459 $string = str_replace("\262", "&#178;", $string);
460 $string = str_replace("\263", "&#179;", $string);
461
462 // Horizontal bar (parentheki pavla)
463 $string = str_replace ("\257", "&#8213;", $string);
464
465 // ISO-8859-7 characters from 11/04 (0xB4) to 11/06 (0xB6)
466 // These are Unicode 900-902
467 while (ereg("([\264-\266])", $string, $res)) {
468 $replace = "&#" . (ord($res[1])+720) . ";";
469 $string = str_replace($res[1], $replace, $string);
470 }
471
472 // 11/07 (0xB7) Middle dot is the same in iso-8859-1
473 $string = str_replace("\267", "&#183;", $string);
474
475 // ISO-8859-7 characters from 11/08 (0xB8) to 11/10 (0xBA)
476 // These are Unicode 900-902
477 while (ereg("([\270-\272])", $string, $res)) {
478 $replace = "&#" . (ord($res[1])+720) . ";";
479 $string = str_replace($res[1], $replace, $string);
480 }
481
482 // 11/11 (0xBB) Right angle quotation mark is the same as in
483 // iso-8859-1
484 $string = str_replace("\273", "&#187;", $string);
485
486 // And now the rest of the charset
487 while (ereg("([\274-\376])", $string, $res)) {
488 $replace = "&#" . (ord($res[1])+720) . ";";
489 $string = str_replace($res[1], $replace, $string);
490 }
491 }
173ed887 492 }
493
494 return $string;
495 }
496
a89c13f5 497 // iso-8859-15 is Latin 9 and has very much the same use as Latin 1
1fd97780 498 // but has the Euro symbol and some characters needed for French.
499 function charset_decode_iso_8859_15 ($string) {
500 // Euro sign
d23e472b 501 $string = str_replace ("\244", "&#8364;", $string);
1fd97780 502 // Latin capital letter S with caron
d23e472b 503 $string = str_replace ("\244", "&#352;", $string);
1fd97780 504 // Latin small letter s with caron
d23e472b 505 $string = str_replace ("\250", "&#353;", $string);
1fd97780 506 // Latin capital letter Z with caron
d23e472b 507 $string = str_replace ("\264", "&#381;", $string);
1fd97780 508 // Latin small letter z with caron
d23e472b 509 $string = str_replace ("\270", "&#382;", $string);
1fd97780 510 // Latin capital ligature OE
d23e472b 511 $string = str_replace ("\274", "&#338;", $string);
1fd97780 512 // Latin small ligature oe
d23e472b 513 $string = str_replace ("\275", "&#339;", $string);
1fd97780 514 // Latin capital letter Y with diaeresis
d23e472b 515 $string = str_replace ("\276", "&#376;", $string);
1fd97780 516
04563822 517 return (charset_decode_iso_8859_1($string));
1fd97780 518 }
519
17ce8467 520 // ISO-8859-15 is Cyrillic
521 function charset_decode_iso_8859_5 ($string) {
d23e472b 522 // Convert to KOI8-R, then return this decoded.
523 $string = convert_cyr_string($string, "i", "k");
524 return charset_decode_koi8r($string);
17ce8467 525 }
526
173ed887 527 // Remove all 8 bit characters from all other ISO-8859 character sets
1fd97780 528 function charset_decode_iso_8859_default ($string) {
529 return (strtr($string, "\240\241\242\243\244\245\246\247".
530 "\250\251\252\253\254\255\256\257".
531 "\260\261\262\263\264\265\266\267".
532 "\270\271\272\273\274\275\276\277".
533 "\300\301\302\303\304\305\306\307".
534 "\310\311\312\313\314\315\316\317".
535 "\320\321\322\323\324\325\326\327".
536 "\330\331\332\333\334\335\336\337".
537 "\340\341\342\343\344\345\346\347".
538 "\350\351\352\353\354\355\356\357".
539 "\360\361\362\363\364\365\366\367".
540 "\370\371\372\373\374\375\376\377",
541 "????????????????????????????????????????".
542 "????????????????????????????????????????".
543 "????????????????????????????????????????".
544 "????????"));
545
546 }
547
548 // This is the same as ISO-646-NO and is used by some
549 // Microsoft programs when sending Norwegian characters
550 function charset_decode_ns_4551_1 ($string) {
551 // These characters are:
552 // Latin capital letter AE
553 // Latin capital letter O with stroke
554 // Latin capital letter A with ring above
555 // and the same as small letters
556 return strtr ($string, "[\\]{|}", "");
557 }
558
17ce8467 559 // KOI8-R is used to encode Russian mail (Cyrrilic). Defined in RFC
560 // 1489.
561 function charset_decode_koi8r ($string) {
562 global $default_charset;
563
564 if ($default_charset == "koi8-r") {
565 return $string;
566 } else {
567 // Convert to Unicode HTML entities.
568 // This code is rather ineffective.
d23e472b 569 $string = str_replace("\200", "&#9472;", $string);
570 $string = str_replace("\201", "&#9474;", $string);
571 $string = str_replace("\202", "&#9484;", $string);
572 $string = str_replace("\203", "&#9488;", $string);
573 $string = str_replace("\204", "&#9492;", $string);
574 $string = str_replace("\205", "&#9496;", $string);
575 $string = str_replace("\206", "&#9500;", $string);
576 $string = str_replace("\207", "&#9508;", $string);
577 $string = str_replace("\210", "&#9516;", $string);
578 $string = str_replace("\211", "&#9524;", $string);
579 $string = str_replace("\212", "&#9532;", $string);
580 $string = str_replace("\213", "&#9600;", $string);
581 $string = str_replace("\214", "&#9604;", $string);
582 $string = str_replace("\215", "&#9608;", $string);
583 $string = str_replace("\216", "&#9612;", $string);
584 $string = str_replace("\217", "&#9616;", $string);
585 $string = str_replace("\220", "&#9617;", $string);
586 $string = str_replace("\221", "&#9618;", $string);
587 $string = str_replace("\222", "&#9619;", $string);
588 $string = str_replace("\223", "&#8992;", $string);
589 $string = str_replace("\224", "&#9632;", $string);
590 $string = str_replace("\225", "&#8729;", $string);
591 $string = str_replace("\226", "&#8730;", $string);
592 $string = str_replace("\227", "&#8776;", $string);
593 $string = str_replace("\230", "&#8804;", $string);
594 $string = str_replace("\231", "&#8805;", $string);
595 $string = str_replace("\232", "&#160;", $string);
596 $string = str_replace("\233", "&#8993;", $string);
597 $string = str_replace("\234", "&#176;", $string);
598 $string = str_replace("\235", "&#178;", $string);
599 $string = str_replace("\236", "&#183;", $string);
600 $string = str_replace("\237", "&#247;", $string);
601 $string = str_replace("\240", "&#9552;", $string);
602 $string = str_replace("\241", "&#9553;", $string);
603 $string = str_replace("\242", "&#9554;", $string);
604 $string = str_replace("\243", "&#1105;", $string);
605 $string = str_replace("\244", "&#9555;", $string);
606 $string = str_replace("\245", "&#9556;", $string);
607 $string = str_replace("\246", "&#9557;", $string);
608 $string = str_replace("\247", "&#9558;", $string);
609 $string = str_replace("\250", "&#9559;", $string);
610 $string = str_replace("\251", "&#9560;", $string);
611 $string = str_replace("\252", "&#9561;", $string);
612 $string = str_replace("\253", "&#9562;", $string);
613 $string = str_replace("\254", "&#9563;", $string);
614 $string = str_replace("\255", "&#9564;", $string);
615 $string = str_replace("\256", "&#9565;", $string);
616 $string = str_replace("\257", "&#9566;", $string);
617 $string = str_replace("\260", "&#9567;", $string);
618 $string = str_replace("\261", "&#9568;", $string);
619 $string = str_replace("\262", "&#9569;", $string);
620 $string = str_replace("\263", "&#1025;", $string);
621 $string = str_replace("\264", "&#9570;", $string);
622 $string = str_replace("\265", "&#9571;", $string);
623 $string = str_replace("\266", "&#9572;", $string);
624 $string = str_replace("\267", "&#9573;", $string);
625 $string = str_replace("\270", "&#9574;", $string);
626 $string = str_replace("\271", "&#9575;", $string);
627 $string = str_replace("\272", "&#9576;", $string);
628 $string = str_replace("\273", "&#9577;", $string);
629 $string = str_replace("\274", "&#9578;", $string);
630 $string = str_replace("\275", "&#9579;", $string);
631 $string = str_replace("\276", "&#9580;", $string);
632 $string = str_replace("\277", "&#169;", $string);
633 $string = str_replace("\300", "&#1102;", $string);
634 $string = str_replace("\301", "&#1072;", $string);
635 $string = str_replace("\302", "&#1073;", $string);
636 $string = str_replace("\303", "&#1094;", $string);
637 $string = str_replace("\304", "&#1076;", $string);
638 $string = str_replace("\305", "&#1077;", $string);
639 $string = str_replace("\306", "&#1092;", $string);
640 $string = str_replace("\307", "&#1075;", $string);
641 $string = str_replace("\310", "&#1093;", $string);
642 $string = str_replace("\311", "&#1080;", $string);
643 $string = str_replace("\312", "&#1081;", $string);
644 $string = str_replace("\313", "&#1082;", $string);
645 $string = str_replace("\314", "&#1083;", $string);
646 $string = str_replace("\315", "&#1084;", $string);
647 $string = str_replace("\316", "&#1085;", $string);
648 $string = str_replace("\317", "&#1086;", $string);
649 $string = str_replace("\320", "&#1087;", $string);
650 $string = str_replace("\321", "&#1103;", $string);
651 $string = str_replace("\322", "&#1088;", $string);
652 $string = str_replace("\323", "&#1089;", $string);
653 $string = str_replace("\324", "&#1090;", $string);
654 $string = str_replace("\325", "&#1091;", $string);
655 $string = str_replace("\326", "&#1078;", $string);
656 $string = str_replace("\327", "&#1074;", $string);
657 $string = str_replace("\330", "&#1100;", $string);
658 $string = str_replace("\331", "&#1099;", $string);
659 $string = str_replace("\332", "&#1079;", $string);
660 $string = str_replace("\333", "&#1096;", $string);
661 $string = str_replace("\334", "&#1101;", $string);
662 $string = str_replace("\335", "&#1097;", $string);
663 $string = str_replace("\336", "&#1095;", $string);
664 $string = str_replace("\337", "&#1098;", $string);
665 $string = str_replace("\340", "&#1070;", $string);
666 $string = str_replace("\341", "&#1040;", $string);
667 $string = str_replace("\342", "&#1041;", $string);
668 $string = str_replace("\343", "&#1062;", $string);
669 $string = str_replace("\344", "&#1044;", $string);
670 $string = str_replace("\345", "&#1045;", $string);
671 $string = str_replace("\346", "&#1060;", $string);
672 $string = str_replace("\347", "&#1043;", $string);
673 $string = str_replace("\350", "&#1061;", $string);
674 $string = str_replace("\351", "&#1048;", $string);
675 $string = str_replace("\352", "&#1049;", $string);
676 $string = str_replace("\353", "&#1050;", $string);
677 $string = str_replace("\354", "&#1051;", $string);
678 $string = str_replace("\355", "&#1052;", $string);
679 $string = str_replace("\356", "&#1053;", $string);
680 $string = str_replace("\357", "&#1054;", $string);
681 $string = str_replace("\360", "&#1055;", $string);
682 $string = str_replace("\361", "&#1071;", $string);
683 $string = str_replace("\362", "&#1056;", $string);
684 $string = str_replace("\363", "&#1057;", $string);
685 $string = str_replace("\364", "&#1058;", $string);
686 $string = str_replace("\365", "&#1059;", $string);
687 $string = str_replace("\366", "&#1046;", $string);
688 $string = str_replace("\367", "&#1042;", $string);
689 $string = str_replace("\370", "&#1068;", $string);
690 $string = str_replace("\371", "&#1067;", $string);
691 $string = str_replace("\372", "&#1047;", $string);
692 $string = str_replace("\373", "&#1064;", $string);
693 $string = str_replace("\374", "&#1069;", $string);
694 $string = str_replace("\375", "&#1065;", $string);
695 $string = str_replace("\376", "&#1063;", $string);
696 $string = str_replace("\377", "&#1066;", $string);
17ce8467 697
698 return $string;
699 }
700 }
701
441f2d33 702
703 global $use_gettext;
704
705 // Detect whether gettext is installed.
706 // If it is, set the flag so we can use it.
707 if (! function_exists("_") ||
708 ! function_exists("bindtextdomain") ||
709 ! function_exists("textdomain"))
710 $use_gettext = false;
711 else
712 $use_gettext = true;
713
714
715 // Avoid warnings/errors
716 if (! function_exists("_")) {
717 function _($str) { return $str; };
718 }
719 if (! function_exists("bindtextdomain")) {
720 function bindtextdomain() { return; }
721 }
722 if (! function_exists("textdomain")) {
723 function textdomain() { return; }
724 }
725
726
727 // Set up the language to be output
728 // if $do_search is true, then scan the browser information
729 // for a possible language that we know
730 function set_up_language($sm_language, $do_search = false)
731 {
732 static $SetupAlready = 0;
4dc80232 733 global $HTTP_ACCEPT_LANGUAGE, $use_gettext, $languages, $squirrelmail_language;
441f2d33 734
735 if ($SetupAlready)
736 return;
737 $SetupAlready = 1;
738
739 if ($do_search && ! $sm_language && isset($HTTP_ACCEPT_LANGUAGE)) {
740 $sm_language = substr($HTTP_ACCEPT_LANGUAGE, 0, 2);
741 }
a9af0166 742
441f2d33 743 if (isset($sm_language) && $use_gettext &&
4dc80232 744 $squirrelmail_language != "" &&
441f2d33 745 $languages[$sm_language]["CHARSET"]) {
746 putenv("LC_ALL=".$sm_language);
a9af0166 747 setlocale("LC_ALL", $sm_language);
441f2d33 748 bindtextdomain("squirrelmail", "../locale/");
749 textdomain("squirrelmail");
750 header ("Content-Type: text/html; charset=".$languages[$sm_language]["CHARSET"]);
751 }
752 }
1fd97780 753?>