diff options
author | Brion Vibber <brion@pobox.com> | 2009-12-19 14:03:31 -0500 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2009-12-19 15:29:53 -0500 |
commit | b244ac6462e1aa8214f97555b554ba98a70c146b (patch) | |
tree | cc7f8379b7fdd37832659dd64b20fb1c23bcd723 /lib | |
parent | a43c310fbcbe91fe849a2e14fdabd9824be7dbfe (diff) |
Ignore user language settings that aren't listed in language config; we'll then fall back to current autodetection. This prevents the surprises where your profile suddenly switches to Arabic because it was selected by default due to lack of a match in the drop-down box.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util.php | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/util.php b/lib/util.php index af4885f40..ed81aeba1 100644 --- a/lib/util.php +++ b/lib/util.php @@ -91,8 +91,16 @@ function common_language() if (_have_config() && common_logged_in()) { $user = common_current_user(); $user_language = $user->language; - if ($user_language) - return $user_language; + + if ($user->language) { + // Validate -- we don't want to end up with a bogus code + // left over from some old junk. + foreach (common_config('site', 'languages') as $code => $info) { + if ($info['lang'] == $user_language) { + return $user_language; + } + } + } } // Otherwise, find the best match for the languages requested by the |