function i18n_init in Internationalization 5.3
Same name and namespace in other branches
- 5 i18n.module \i18n_init()
- 5.2 i18n.module \i18n_init()
- 6 i18n.module \i18n_init()
Implementation of hook_init()
May do a redirect from home page for not to get wrong versions in cache Warning: when in bootstrap mode, this may be called before i18n_get_lang()
File
- ./
i18n.module, line 122 - Internationalization (i18n) module
Code
function i18n_init() {
global $i18n_langpath;
// If not in bootstrap, variable init. This may go before the rest of the code because some variables may need to be loaded
if (!_i18n_is_bootstrap()) {
//include drupal_get_path('module', 'i18n').'/i18n.inc';
i18n_variable_init();
}
$lang = i18n_get_lang();
$path = _i18n_get_original_path();
// Init selection mode
i18n_selection_mode(variable_get('i18n_selection_mode', 'simple'));
// Multi tables, for backwards compatibility and experimentation
_i18n_set_db_prefix($lang);
if ($path == '') {
// Main page
// Check for update or cron scripts to disable rewriting and redirection
if (preg_match('|/(?!index\\.php)\\w+\\.php|', request_uri())) {
i18n_selection_mode('off');
}
elseif ($lang != i18n_default_language()) {
// Redirect to main page in $lang when it's not default language.
_i18n_goto($lang);
}
else {
$_GET['q'] = i18n_frontpage($lang);
}
}
elseif ($lang == $path) {
// When path is only language code
$_GET['q'] = i18n_frontpage($lang);
}
elseif ($i18n_langpath) {
//search alias with and without lang and remove lang.
$_GET['q'] = i18n_get_normal_path($path);
}
}