summaryrefslogtreecommitdiff
path: root/modules/user/helpers/user.php
diff options
context:
space:
mode:
authorAndy Staudacher <andy.st@gmail.com>2009-09-04 11:06:20 -0700
committerAndy Staudacher <andy.st@gmail.com>2009-09-04 11:06:20 -0700
commit001623c755777846a468255d4396d30b253dcdfb (patch)
tree2bf78736cb8da45b3fe584ef0a67cb4898d47a3f /modules/user/helpers/user.php
parentc453c0ef8239bc79e484dd3feb9e275e942e9d48 (diff)
Add new locale preferences: Adding per session (cookie) locale preferences and check the browser's / OS' locale preferences.
Ticket 582.
Diffstat (limited to 'modules/user/helpers/user.php')
-rw-r--r--modules/user/helpers/user.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/modules/user/helpers/user.php b/modules/user/helpers/user.php
index 40acc2ec..b9162b92 100644
--- a/modules/user/helpers/user.php
+++ b/modules/user/helpers/user.php
@@ -87,6 +87,9 @@ class user_Core {
private static function _add_locale_dropdown(&$form, $user=null) {
$locales = locales::installed();
+ foreach ($locales as $locale => $display_name) {
+ $locales[$locale] = SafeString::of_safe_html($display_name);
+ }
if (count($locales) > 1) {
// Put "none" at the first position in the array
$locales = array_merge(array("" => t("« none »")), $locales);
@@ -336,4 +339,19 @@ class user_Core {
}
return $salt . md5($salt . $password);
}
+
+ static function cookie_locale() {
+ $cookie_data = Input::instance()->cookie("g_locale");
+ $locale = null;
+ if ($cookie_data) {
+ if (preg_match("/^([a-z]{2,3}(?:_[A-Z]{2})?)$/", trim($cookie_data), $matches)) {
+ $requested_locale = $matches[1];
+ $installed_locales = locales::installed();
+ if (isset($installed_locales[$requested_locale])) {
+ $locale = $requested_locale;
+ }
+ }
+ }
+ return $locale;
+ }
} \ No newline at end of file