Example #1
0
 public static function t($text, $key = null, $module)
 {
     // TODO: use cache, apc cache? special handling for menu?
     //echo "to translate $text, $key, $module".nl;
     if (!I18n::loadLangData($module)) {
         // cannot load lang data, return orig text
         return $text;
     }
     if ($key && isset(I18n::$_langData[$module][$key])) {
         return I18n::$_langData[$module][$key];
     }
     $key = strtoupper('STRING_' . md5($text));
     if ($key && isset(I18n::$_langData[$module][$key])) {
         return I18n::$_langData[$module][$key];
     }
     // try to load system.ini if previous steps can't find match
     if ($module != '_system') {
         return self::t($text, $key, '_system');
     }
     return $text;
 }
Example #2
0
 public static function t($text, $key = null, $module, $prefix = null)
 {
     // TODO: use cache, apc cache? special handling for menu?
     //echo "to translate $text, $key, $module".nl;
     if (!I18n::loadLangData($module)) {
         // cannot load lang data, return orig text
         return $text;
     }
     if ($key && isset(I18n::$_langData[$module][$prefix . $key]) && I18n::$_langData[$module][$prefix . $key] != $text) {
         return I18n::$_langData[$module][$prefix . $key];
     }
     $str_key = strtoupper('STRING_' . md5($text));
     if ($key && isset(I18n::$_langData[$module][$str_key]) && I18n::$_langData[$module][$str_key] != $text) {
         return I18n::$_langData[$module][$str_key];
     }
     if ($key && isset(I18n::$_langData[$module][$key])) {
         return I18n::$_langData[$module][$key];
     }
     // try to load theme.THEME_NAME.ini
     $module = '_theme';
     if (!I18n::loadLangData($module)) {
         return $text;
     }
     if ($key && isset(I18n::$_langData[$module][$key])) {
         return I18n::$_langData[$module][$key];
     }
     // try to load system.ini if previous steps can't find match
     $module != '_system';
     if (!I18n::loadLangData($module)) {
         return $text;
     }
     if ($key && isset(I18n::$_langData[$module][$key])) {
         return I18n::$_langData[$module][$key];
     }
     return $text;
 }