Esempio n. 1
0
 /**
  * add a dictionary to the core dictionary
  * useful to store view specific dictionaries
  * @param string $dictionary_path the relative path driving from "locale/$lang/" to the desired xml file
  * @param string $lang the language of the desired dictionary
  * @example Lang::addDictionary("overview/index","fr_FR"); will try to load the file "locale/fr_FR/overview/index.xml" 
  */
 public static function addDictionary($module, $dictionary_path, $lang = "")
 {
     //echo "<br/> Attempt to add [".$lang."] subdictionary (".$dictionary_path.")";
     //$_SESSION['feedback_positive'][]="Adding dictionary for : ".$lang." (".$dictionary_path.")";
     //sympa: in the case some dev has forgotten to init the linguistic data properly
     if (!isset($_SESSION['ArFramework_lang']) || !isset(Lang::$_dictionary)) {
         //echo "<br/> but first have to init language";
         Lang::initLanguage();
     }
     if ($lang == "") {
         if (isset($_SESSION['ArFramework_lang'])) {
             $lang = Res::session("ArFramework_lang");
         } else {
             return;
         }
         //echo "... switch to [".$lang."] ... ";
     }
     if (file_exists('../app/modules/' . $module . '/Resources/Local/' . $lang . "/" . $dictionary_path . ".xml")) {
         //echo " ...ok!";
         //$_SESSION['feedback_positive'][]="... ok added dictionary for : ".$lang;
         $language = XMLUtilities::xmlfile_to_associative_array('../app/modules/' . $module . '/Resources/Local/' . $lang . "/" . $dictionary_path . ".xml", "UTF-8", "language_translation/translations/translation", "key");
         ////echo "#$language#";
         Lang::$_dictionary = array_merge(Lang::$_dictionary, $language);
     }
 }