/** * The method to be called each time a page is loaded. * This method is called by the superclass Controller, in order to prepare linguistic stuff for being rendered in the relevant language * Note: this method has to be called after a Session is started because the session is used to store the current language between two pages (and two calls of initLanguage) * @param $force_load_dictionary force load the dictionary (false by default). use this parameter when language is changed by the user */ public static function initLanguage($force_load_dictionary = false) { //TV: Locale and default language configuration /* * Configuration for: Locale and default language of the website * If a current_language is not already defined, we set here the language defaults of the website: * - first, the navigator language is interpreted as the default language, if accepted by the application * - if the application can't accept the navigator language, we default to the english language */ //echo "<br/> Init language Start"; //$_SESSION['feedback_positive'][]="Init language : start"; if (!isset(Lang::$_languages_config)) { //echo "<br/> Init language : init Languages config "; //$_SESSION['feedback_positive'][]="<br/> Init language : init Languages config "; //first load the list of the languages spoken by this application Lang::loadLanguagesConfig(); } if (!isset($_SESSION['ARFramework_lang'])) { ////echo "C"; //echo "<br/> Init language : setting up Session Language"; //$_SESSION['feedback_positive'][]="<br/> Init language : setting up Session Language"; //get the array of known languages: $knownLanguages = Lang::getKnownLanguages(); $myLanguages = Lang::getBrowserLanguages(); /** * Configuring the application */ // $_SESSION['current_language'] = ''; Res::stsession("ARFramework_lang", ''); if (isset($knownLanguages['default'])) { // $_SESSION['current_language'] = $knownLanguages['default']; Res::stsession("ARFramework_lang", $knownLanguages['default']); } //now take the browser's preferred language and try to find it in the knownlanguage foreach ($myLanguages as $lang => $q) { $lang = str_replace("-", "_", $lang); //if $lang is known if (isset($knownLanguages[$lang])) { //if $lang is known but is an alias, we need to use the target language, not the alias! // $_SESSION['current_language']=$knownLanguages[$lang]; Res::stsession("ARFramework_lang", $knownLanguages[$lang]); break; } } } else { } //load the dictionary if required if (!isset(Lang::$_dictionary) || $force_load_dictionary) { ////echo "D"; //echo "<br/> Init language : init Dictionary ($force_load_dictionary)"; //$_SESSION['feedback_positive'][]="<br/> Init language : init Dictionary (force_load = $force_load_dictionary) for : ".$_SESSION['current_language']; // Lang::loadDictionary($_SESSION['current_language']); Lang::loadDictionary(Res::session("ARFramework_lang")); if (self::LANG_TRANSLATION_ASSISTANCE) { Lang::$_untranslated_dictionary = array(); } } }