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