1: <?php
2:
3: 4: 5: 6:
7: class QI18n extends QBaseClass {
8: 9: 10: 11: 12: 13:
14: public static $DefaultTranslationClass = 'QTranslationPoParser';
15:
16: 17: 18: 19: 20: 21: 22: 23: 24:
25: public static function Initialize($strTranslationClass = null) {
26: if (!$strTranslationClass) $strTranslationClass = self::$DefaultTranslationClass;
27: $mixInitializeMethod = array($strTranslationClass, 'Initialize');
28: $objQI18n = call_user_func_array($mixInitializeMethod, array());
29: if (!($objQI18n instanceof QTranslationBase)) {
30: throw new QCallerException(sprintf("Translation class '%s' should extend QTranslationBase", $strTranslationClass));
31: }
32: QApplication::$LanguageObject = $objQI18n;
33: }
34:
35: 36: 37: 38: 39: 40: 41: 42: 43: 44:
45: public static function Load($strLanguageCode = null, $strCountryCode = null, $strTranslationClass = null) {
46: if (!$strTranslationClass) $strTranslationClass = self::$DefaultTranslationClass;
47: $mixLoadMethod = array($strTranslationClass, 'Load');
48: $objQI18n = call_user_func_array($mixLoadMethod, array($strLanguageCode, $strCountryCode));
49: if (!($objQI18n instanceof QTranslationBase)) {
50: throw new QCallerException(sprintf("Translation class '%s' should extend QTranslationBase", $strTranslationClass));
51: }
52: return $objQI18n;
53: }
54: }
55: