Beispiel #1
0
 /**
  * Load a language and its definition files, depending on what plugins are enabled.
  *
  * @param string $language The name of the language.
  * @return void
  */
 public static function loadLanguage($language = "")
 {
     if (isset(ET::$languageInfo[$language])) {
         return;
     }
     $narr = ET::$cache->filenames;
     if ($narr !== false && isset($narr["language_filename"])) {
         self::$language_filename = $narr["language_filename"];
     }
     //while $narr is empty create an new array
     if (empty($narr)) {
         $narr = array();
     }
     // Clear the currently loaded definitions.
     self::$definitions = array();
     // If the specified language doesn't exist, use the default language.
     self::$language = file_exists(PATH_LANGUAGES . "/" . sanitizeFileName($language) . "/definitions.php") ? $language : C("esoTalk.language");
     // Load the main definitions file.
     $languagePath = PATH_LANGUAGES . "/" . sanitizeFileName(self::$language);
     self::loadDefinitions("{$languagePath}/definitions.php");
     // Set the locale.
     if (isset(ET::$languageInfo[self::$language]["locale"])) {
         setlocale(LC_ALL, ET::$languageInfo[self::$language]["locale"]);
     }
     // Loop through the loaded plugins and include their definition files, if they exist.
     foreach (C("esoTalk.enabledPlugins") as $plugin) {
         if (empty(self::$language_filename) || self::$language_filename[$plugin] == false) {
             if (file_exists($file = "{$languagePath}/definitions." . sanitizeFileName($plugin) . ".php")) {
                 self::loadDefinitions($file);
                 self::$language_filename[$plugin] = $file;
                 $narr["language_filename"] = self::$language_filename;
                 //ET::$cache->store("language_filename" , self::$language_filename);
                 //ET::$cache->store(ET::$cache->fname_key , $narr);
                 ET::$cache->filenames = $narr;
                 ET::$cache->fnamechanged = true;
             }
         } else {
             $file = self::$language_filename[$plugin];
             self::loadDefinitions($file);
         }
     }
     //var_dump($narr);//exit();
     unset($narr);
     // Re-define runtime definitions.
     foreach (self::$runtimeDefinitions as $k => $v) {
         ET::define($k, $v);
     }
 }