本文整理汇总了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);
}