1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
16:
17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33:
34: function trans($string) {
35: return cI18n::__($string);
36: }
37:
38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53:
54: function i18n($string, $domain = 'contenido') {
55: return cI18n::__($string, $domain);
56: }
57:
58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70:
71: function i18nEmulateGettext($string, $domain = 'contenido') {
72: return cI18n::emulateGettext($string, $domain);
73: }
74:
75: 76: 77: 78: 79: 80: 81: 82: 83: 84:
85: function i18nInit($localePath, $langCode, $domain = 'contenido') {
86: cI18n::init($localePath, $langCode, $domain);
87: }
88:
89: 90: 91: 92: 93: 94: 95: 96: 97: 98:
99: function i18nRegisterDomain($domain, $localePath) {
100: cI18n::registerDomain($domain, $localePath);
101: }
102:
103: 104: 105: 106: 107: 108: 109: 110: 111:
112: function i18nStripAcceptLanguages($accept) {
113: $languages = explode(',', $accept);
114: $shortLanguages = array();
115: foreach ($languages as $value) {
116: $components = explode(';', $value);
117: $shortLanguages[] = $components[0];
118: }
119:
120: return $shortLanguages;
121: }
122:
123: 124: 125: 126: 127: 128: 129: 130: 131:
132: function i18nMatchBrowserAccept($accept) {
133: $available_languages = i18nGetAvailableLanguages();
134:
135:
136: foreach ($available_languages as $key => $value) {
137: list($country, $lang, $encoding, $shortaccept) = $value;
138: if ($accept == $shortaccept) {
139: return $key;
140: }
141: }
142:
143: 144: 145: 146: 147:
148: $accept = cString::getPartOfString($accept, 0, 2);
149: foreach ($available_languages as $key => $value) {
150: list($country, $lang, $encoding, $shortaccept) = $value;
151: if ($accept == $shortaccept) {
152: return $key;
153: }
154: }
155:
156:
157:
158: return false;
159: }
160:
161: 162: 163: 164: 165: 166:
167: function i18nGetAvailableLanguages() {
168: 169: 170: 171: 172:
173: $aLanguages = array(
174: 'ar_AA' => array(
175: 'Arabic',
176: 'Arabic Countries',
177: 'ISO8859-6',
178: 'ar',
179: 'en'
180: ),
181: 'be_BY' => array(
182: 'Byelorussian',
183: 'Belarus',
184: 'ISO8859-5',
185: 'be',
186: 'en'
187: ),
188: 'bg_BG' => array(
189: 'Bulgarian',
190: 'Bulgaria',
191: 'ISO8859-5',
192: 'bg',
193: 'en'
194: ),
195: 'cs_CZ' => array(
196: 'Czech',
197: 'Czech Republic',
198: 'ISO8859-2',
199: 'cs',
200: 'cz'
201: ),
202: 'da_DK' => array(
203: 'Danish',
204: 'Denmark',
205: 'ISO8859-1',
206: 'da',
207: 'dk'
208: ),
209: 'de_CH' => array(
210: 'German',
211: 'Switzerland',
212: 'ISO8859-1',
213: 'de-ch',
214: 'de'
215: ),
216: 'de_DE' => array(
217: 'German',
218: 'Germany',
219: 'ISO8859-1',
220: 'de',
221: 'de'
222: ),
223: 'el_GR' => array(
224: 'Greek',
225: 'Greece',
226: 'ISO8859-7',
227: 'el',
228: 'en'
229: ),
230: 'en_GB' => array(
231: 'English',
232: 'Great Britain',
233: 'ISO8859-1',
234: 'en-gb',
235: 'en'
236: ),
237: 'en_US' => array(
238: 'English',
239: 'United States',
240: 'ISO8859-1',
241: 'en',
242: 'en'
243: ),
244: 'es_ES' => array(
245: 'Spanish',
246: 'Spain',
247: 'ISO8859-1',
248: 'es',
249: 'es'
250: ),
251: 'fi_FI' => array(
252: 'Finnish',
253: 'Finland',
254: 'ISO8859-1',
255: 'fi',
256: 'en'
257: ),
258: 'fr_BE' => array(
259: 'French',
260: 'Belgium',
261: 'ISO8859-1',
262: 'fr-be',
263: 'fr'
264: ),
265: 'fr_CA' => array(
266: 'French',
267: 'Canada',
268: 'ISO8859-1',
269: 'fr-ca',
270: 'fr'
271: ),
272: 'fr_FR' => array(
273: 'French',
274: 'France',
275: 'ISO8859-1',
276: 'fr',
277: 'fr'
278: ),
279: 'fr_CH' => array(
280: 'French',
281: 'Switzerland',
282: 'ISO8859-1',
283: 'fr-ch',
284: 'fr'
285: ),
286: 'hr_HR' => array(
287: 'Croatian',
288: 'Croatia',
289: 'ISO8859-2',
290: 'hr',
291: 'en'
292: ),
293: 'hu_HU' => array(
294: 'Hungarian',
295: 'Hungary',
296: 'ISO8859-2',
297: 'hu',
298: 'hu'
299: ),
300: 'is_IS' => array(
301: 'Icelandic',
302: 'Iceland',
303: 'ISO8859-1',
304: 'is',
305: 'en'
306: ),
307: 'it_IT' => array(
308: 'Italian',
309: 'Italy',
310: 'ISO8859-1',
311: 'it',
312: 'it'
313: ),
314: 'iw_IL' => array(
315: 'Hebrew',
316: 'Israel',
317: 'ISO8859-8',
318: 'he',
319: 'he'
320: ),
321: 'nl_BE' => array(
322: 'Dutch',
323: 'Belgium',
324: 'ISO8859-1',
325: 'nl-be',
326: 'nl'
327: ),
328: 'nl_NL' => array(
329: 'Dutch',
330: 'Netherlands',
331: 'ISO8859-1',
332: 'nl',
333: 'nl'
334: ),
335: 'no_NO' => array(
336: 'Norwegian',
337: 'Norway',
338: 'ISO8859-1',
339: 'no',
340: 'en'
341: ),
342: 'pl_PL' => array(
343: 'Polish',
344: 'Poland',
345: 'ISO8859-2',
346: 'pl',
347: 'en'
348: ),
349: 'pt_BR' => array(
350: 'Brazillian',
351: 'Brazil',
352: 'ISO8859-1',
353: 'pt-br',
354: 'br'
355: ),
356: 'pt_PT' => array(
357: 'Portuguese',
358: 'Portugal',
359: 'ISO8859-1',
360: 'pt',
361: 'en'
362: ),
363: 'ro_RO' => array(
364: 'Romanian',
365: 'Romania',
366: 'ISO8859-2',
367: 'ro',
368: 'en'
369: ),
370: 'ru_RU' => array(
371: 'Russian',
372: 'Russia',
373: 'ISO8859-5',
374: 'ru',
375: 'ru'
376: ),
377: 'sh_SP' => array(
378: 'Serbian Latin',
379: 'Yugoslavia',
380: 'ISO8859-2',
381: 'sr',
382: 'en'
383: ),
384: 'sl_SI' => array(
385: 'Slovene',
386: 'Slovenia',
387: 'ISO8859-2',
388: 'sl',
389: 'en'
390: ),
391: 'sk_SK' => array(
392: 'Slovak',
393: 'Slovakia',
394: 'ISO8859-2',
395: 'sk',
396: 'en'
397: ),
398: 'sq_AL' => array(
399: 'Albanian',
400: 'Albania',
401: 'ISO8859-1',
402: 'sq',
403: 'en'
404: ),
405: 'sr_SP' => array(
406: 'Serbian Cyrillic',
407: 'Yugoslavia',
408: 'ISO8859-5',
409: 'sr-cy',
410: 'en'
411: ),
412: 'sv_SE' => array(
413: 'Swedish',
414: 'Sweden',
415: 'ISO8859-1',
416: 'sv',
417: 'se'
418: ),
419: 'tr_TR' => array(
420: 'Turkisch',
421: 'Turkey',
422: 'ISO8859-9',
423: 'tr',
424: 'tr'
425: )
426: );
427:
428: return $aLanguages;
429: }
430:
431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446:
447: function mi18n($key)
448: {
449: $key = trim($key);
450:
451:
452: if (empty($key)) {
453: return 'No module translation ID specified.';
454: }
455:
456:
457: cInclude('classes', 'contenido/class.module.php');
458: cInclude('classes', 'module/class.module.filetranslation.php');
459:
460:
461: $cCurrentModule = cRegistry::getCurrentModuleId();
462: $contenidoTranslateFromFile = new cModuleFileTranslation($cCurrentModule, true);
463: $translations = $contenidoTranslateFromFile->getLangArray();
464:
465: $translation = isset($translations[$key]) ? $translations[$key] : '';
466:
467:
468:
469:
470: if (empty($translation)) {
471:
472: $moduleTranslationMessage = getEffectiveSetting('debug', 'module_translation_message', 'true');
473: $moduleTranslationMessage = 'true' === $moduleTranslationMessage ? true : false;
474: $translation = $moduleTranslationMessage ? 'Module translation not found: ' : '';
475: $translation .= $key;
476: }
477:
478:
479: if (1 < func_num_args()) {
480: $arrArgs = func_get_args();
481: $arrArgs[0] = $translation;
482: $translation = call_user_func_array('sprintf', $arrArgs);
483: }
484:
485: return trim($translation);
486: }
487: