當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Language::setLocale方法代碼示例

本文整理匯總了PHP中Backend\Core\Engine\Language::setLocale方法的典型用法代碼示例。如果您正苦於以下問題:PHP Language::setLocale方法的具體用法?PHP Language::setLocale怎麽用?PHP Language::setLocale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Backend\Core\Engine\Language的用法示例。


在下文中一共展示了Language::setLocale方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: validateLogin

 /**
  * 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'));
 }
開發者ID:bwgraves,項目名稱:forkcms,代碼行數:13,代碼來源:Ajax.php

示例2: setLanguage

 /**
  * 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);
 }
開發者ID:arashrasoulzadeh,項目名稱:forkcms,代碼行數:20,代碼來源:Cronjob.php

示例3: setLocale

 /**
  * 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);
 }
開發者ID:bwgraves,項目名稱:forkcms,代碼行數:21,代碼來源:Url.php


注:本文中的Backend\Core\Engine\Language::setLocale方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。