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