From: Brion Vibber Date: Sat, 19 Dec 2009 19:03:31 +0000 (-0500) Subject: Ignore user language settings that aren't listed in language config; we'll then fall... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f987273f118a12d443b6789c2ab59d7a4b01f678;p=quix0rs-gnu-social.git 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. --- diff --git a/lib/util.php b/lib/util.php index 99a0a1db30..5d20ed82df 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