function common_language() { $_default_language = common_config('site', 'language'); // Otherwise, find the best match for the languages requested by the // user's browser... if (common_config('site', 'langdetect')) { $httplang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : null; if (!empty($httplang)) { $language = client_prefered_language($httplang); if ($language) { return $language; } } } // Finally, if none of the above worked, use the site's default... return $_default_language; }
function common_language() { // If there is a user logged in and they've set a language preference // then return that one... if (_have_config() && common_logged_in()) { $user = common_current_user(); $user_language = $user->language; if ($user_language) { return $user_language; } } // Otherwise, find the best match for the languages requested by the // user's browser... $httplang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : null; if (!empty($httplang)) { $language = client_prefered_language($httplang); if ($language) { return $language; } } // Finally, if none of the above worked, use the site's default... return common_config('site', 'language'); }
function common_language() { // If there is a user logged in and they've set a language preference // then return that one... if (_have_config() && common_logged_in()) { $user = common_current_user(); $user_language = $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 // user's browser... if (common_config('site', 'langdetect')) { $httplang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : null; if (!empty($httplang)) { $language = client_prefered_language($httplang); if ($language) { return $language; } } } // Finally, if none of the above worked, use the site's default... return common_config('site', 'language'); //return 'zh_CN'; }
function common_language() { // Allow ?uselang=xx override, very useful for debugging // and helping translators check usage and context. if (isset($_GET['uselang'])) { $uselang = strval($_GET['uselang']); if (common_valid_language($uselang)) { return $uselang; } } // If there is a user logged in and they've set a language preference // then return that one... if (_have_config() && common_logged_in()) { $user = common_current_user(); if (common_valid_language($user->language)) { return $user->language; } } // Otherwise, find the best match for the languages requested by the // user's browser... if (common_config('site', 'langdetect')) { $httplang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : null; if (!empty($httplang)) { $language = client_prefered_language($httplang); if ($language) { return $language; } } } // Finally, if none of the above worked, use the site's default... return common_config('site', 'language'); }