setLocale() публичный статический Метод

Set locale It will require the correct file and init the needed vars
public static setLocale ( string $language )
$language string The language to load.
Пример #1
0
 /**
  * Do authentication stuff
  * This method could end the script by throwing an exception
  */
 private function validateLogin()
 {
     // check if the user is logged on, if not he shouldn't load any JS-file
     if (!Authentication::isLoggedIn()) {
         throw new Exception('Not logged in.');
     }
     // set interface language
     Language::setLocale(Authentication::getUser()->getSetting('interface_language'));
 }
Пример #2
0
 /**
  * Set language
  *
  * @param string $value The language to load.
  */
 public function setLanguage($value)
 {
     // get the possible languages
     $possibleLanguages = Language::getWorkingLanguages();
     // validate
     if (!in_array($value, array_keys($possibleLanguages))) {
         throw new Exception('Invalid language.');
     }
     // set property
     $this->language = $value;
     // set the locale (we need this for the labels)
     Language::setLocale($this->language);
     // set working language
     Language::setWorkingLanguage($this->language);
 }
Пример #3
0
 /**
  * Set the locale
  */
 private function setLocale()
 {
     $default = $this->get('fork.settings')->get('Core', 'default_interface_language');
     $locale = $default;
     $possibleLocale = array_keys(Language::getInterfaceLanguages());
     // is the user authenticated
     if (Authentication::getUser()->isAuthenticated()) {
         $locale = Authentication::getUser()->getSetting('interface_language', $default);
     } elseif (CommonCookie::exists('interface_language')) {
         // no authenticated user, but available from a cookie
         $locale = CommonCookie::get('interface_language');
     }
     // validate if the requested locale is possible
     if (!in_array($locale, $possibleLocale)) {
         $locale = $default;
     }
     Language::setLocale($locale);
 }