summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/locales.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers/locales.php')
-rw-r--r--modules/gallery/helpers/locales.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/modules/gallery/helpers/locales.php b/modules/gallery/helpers/locales.php
index f0807c99..17286adf 100644
--- a/modules/gallery/helpers/locales.php
+++ b/modules/gallery/helpers/locales.php
@@ -136,6 +136,23 @@ class locales_Core {
return in_array($language, array("he", "fa", "ar"));
}
+ 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 = self::locale_from_http_request();
+ }
+ // If we have any preference, override the site's default locale
+ if ($locale) {
+ I18n::instance()->locale($locale);
+ }
+ }
+
/**
* Returns the best match comparing the HTTP accept-language header
* with the installed locales.