function _i18n_get_lang in Internationalization 5
Same name and namespace in other branches
- 5.2 i18n.module \_i18n_get_lang()
Gets language, checking in order:
1. Path language 2. Session language 3. User language 4. Browser language 5. Default language
4 calls to _i18n_get_lang()
- i18n_frontpage in ./
i18n.module - Language dependent front page This function will search for aliases like 'en/home', 'es/home'...
- i18n_get_lang in ./
i18n.module - This one expects to be called first from common.inc
- i18n_variable_init in ./
i18n.module - Initialization of multilingual variables
- _i18n_variable_exit in ./
i18n.module - Save multilingual variables that may have been changed by other methods than settings pages
File
- ./
i18n.module, line 1068 - Internationalization (i18n) module
Code
function _i18n_get_lang() {
global $user, $i18n_langpath;
static $i18n_lang;
// Check whether the language is already set.
if ($i18n_lang) {
return $i18n_lang;
}
// Language not set, find one
$languages = i18n_supported_languages();
if ($i18n_langpath && array_key_exists($i18n_langpath, $languages)) {
// Sets session language only when language is in path, not for other cases
$_SESSION['language'] = $i18n_lang = $i18n_langpath;
}
elseif (isset($_SESSION['language']) && array_key_exists($_SESSION['language'], $languages)) {
$i18n_lang = $_SESSION['language'];
}
elseif ($user->uid && $user->language && array_key_exists($user->language, $languages)) {
$i18n_lang = $user->language;
}
elseif (variable_get("i18n_browser", 0) && ($lang = i18n_get_browser_lang())) {
$i18n_lang = $lang;
}
else {
$i18n_lang = i18n_default_language();
}
return $i18n_lang;
}