Пример #1
0
 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
0
 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
0
 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;
 }