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