本文整理匯總了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'));
}
示例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);
}
示例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);
}