コード例 #1
0
 protected static function loadI18NFiles($path)
 {
     static $current_module, $c = 0;
     if (!$current_module) {
         $controller = cmsController::getInstance();
         $current_module = $controller->getCurrentModule();
     }
     $i18nCache = self::$i18nCache;
     $require_list = self::parseLangsPath($path);
     $lang_prefix = self::getLangPrefix();
     $i18nMixed = array();
     if (!in_array($current_module, $require_list)) {
         $require_list[] = $current_module;
     }
     $sz = sizeof($require_list);
     for ($i = 0; $i < $sz; $i++) {
         $require_name = $require_list[$i];
         if ($require_name == false) {
             continue;
         }
         $filename_primary = "i18n." . $lang_prefix . ".php";
         $filename_secondary = "i18n.php";
         $folder = $require_name == "common" ? "/classes/modules/" : "/classes/modules/" . $require_name . "/";
         $folder = CURRENT_WORKING_DIR . $folder;
         $path_primary = $folder . $filename_primary;
         $path_secondary = $folder . $filename_secondary;
         if (array_key_exists($require_name, $i18nCache)) {
             $i18n = $i18nCache[$require_name];
         } else {
             if (file_exists($path_primary)) {
                 include $path_primary;
             } else {
                 if (file_exists($path_secondary)) {
                     include $path_secondary;
                 }
             }
         }
         if (isset($i18n) && is_array($i18n)) {
             $i18nCache[$require_name] = $i18n;
             $i18nMixed = $i18n + $i18nMixed;
             unset($i18n);
         }
     }
     self::$i18nCache = $i18nCache;
     return $i18nMixed;
 }