本文整理汇总了PHP中locales::locale_from_http_request方法的典型用法代码示例。如果您正苦于以下问题:PHP locales::locale_from_http_request方法的具体用法?PHP locales::locale_from_http_request怎么用?PHP locales::locale_from_http_request使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类locales
的用法示例。
在下文中一共展示了locales::locale_from_http_request方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_request_locale
static function set_request_locale()
{
// 1. Check the session specific preference (cookie)
$locale = user::cookie_locale();
// 2. Check the user's preference
if (!$locale) {
$locale = user::active()->locale;
}
// 3. Check the browser's / OS' preference
if (!$locale) {
$locale = locales::locale_from_http_request();
}
// If we have any preference, override the site's default locale
if ($locale) {
I18n::instance()->locale($locale);
}
}
示例2: locale_from_http_request_prefer_inexact_same_language_match_over_exact_other_language_match_test
public function locale_from_http_request_prefer_inexact_same_language_match_over_exact_other_language_match_test()
{
locales::update_installed(array("de_DE", "ar_AR", "fa_IR", "he_IL", "en_US"));
// Accept-Language header from Firefox 3.5/Ubuntu
$_SERVER["HTTP_ACCEPT_LANGUAGE"] = "he,en-us;q=0.9,de-ch;q=0.5,en;q=0.3";
$locale = locales::locale_from_http_request();
$this->assert_equal("he_IL", $locale);
}
示例3: create_pending_request
static function create_pending_request($form)
{
$email_verification = module::get_var("registration", "email_verification");
$user = ORM::factory("pending_user");
$user->name = $form->register_user->inputs["name"]->value;
$user->full_name = $form->register_user->inputs["full_name"]->value;
$user->email = $form->register_user->inputs["email"]->value;
$user->url = $form->register_user->inputs["url"]->value;
$user->request_date = time();
// added by Shad Laws, v2
$user->locale = locales::locale_from_http_request() ? locales::locale_from_http_request() : module::get_var("gallery", "default_locale");
// sets default locale based on browser
if (!$email_verification) {
$user->state = 1;
}
$user->hash = md5(rand());
$user->save();
return $user;
}