Ejemplo n.º 1
0
 public static function getActiveLanguage()
 {
     global $cAvailableLanguages;
     // look in the order of most volatile first - if we find something, use it.
     // request cache
     if (self::$requestLanguage != "") {
         return self::$requestLanguage;
     }
     // get parameter
     $getParam = WebRequest::get("lang");
     if ($getParam != false) {
         // check value is in list of allowed values
         if (array_key_exists($getParam, $cAvailableLanguages)) {
             // save local cache for other messages this request
             self::$requestLanguage = $getParam;
             // set a cookie to persist that option for this session (do we want
             // this option to set the preferences too?)
             WebRequest::setCookie("lang", $getParam);
             // use this value.
             return $getParam;
         }
     }
     // cookie
     $cookie = WebRequest::getCookie("lang");
     if ($cookie != false) {
         // check value is in list of allowed values
         if (array_key_exists($cookie, $cAvailableLanguages)) {
             // save local cache for other messages this request
             self::$requestLanguage = $cookie;
             // use this value.
             return $cookie;
         }
     }
     // user preference
     // site default
     return "en-GB";
 }