Select the right lang in the Language select box
This commit is contained in:
parent
66edd29b9b
commit
d73ca37f5c
@ -17,9 +17,6 @@
|
|||||||
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Sort languages
|
|
||||||
asort($ALLOWED_LANGUAGES);
|
|
||||||
|
|
||||||
// Prepare I18N instance
|
// Prepare I18N instance
|
||||||
$i18n = \o80\i18n\I18N::instance();
|
$i18n = \o80\i18n\I18N::instance();
|
||||||
$i18n->setDefaultLang(DEFAULT_LANGUAGE);
|
$i18n->setDefaultLang(DEFAULT_LANGUAGE);
|
||||||
@ -27,16 +24,12 @@ $i18n->setPath(__DIR__ . '/../../locale');
|
|||||||
|
|
||||||
// Change langauge when user asked for it
|
// Change langauge when user asked for it
|
||||||
if (isset($_POST['lang']) && is_string($_POST['lang']) && in_array($_POST['lang'], array_keys($ALLOWED_LANGUAGES))) {
|
if (isset($_POST['lang']) && is_string($_POST['lang']) && in_array($_POST['lang'], array_keys($ALLOWED_LANGUAGES))) {
|
||||||
$locale = $_POST['lang'];
|
|
||||||
$_SESSION['lang'] = $_POST['lang'];
|
$_SESSION['lang'] = $_POST['lang'];
|
||||||
} elseif (!empty($_SESSION['lang'])) {
|
|
||||||
$locale = $_SESSION['lang'];
|
|
||||||
} else {
|
|
||||||
$locale = DEFAULT_LANGUAGE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* <html lang="$html_lang"> */
|
/* <html lang="$html_lang"> */
|
||||||
$html_lang = substr($locale, 0, 2);
|
$i18n->get('Something, just to load the dictionary');
|
||||||
|
$locale = $i18n->getLoadedLang();
|
||||||
|
|
||||||
/* Date Format */
|
/* Date Format */
|
||||||
$date_format['txt_full'] = __('Date', 'FULL'); //summary in create_date_poll.php and removal date in choix_(date|autre).php
|
$date_format['txt_full'] = __('Date', 'FULL'); //summary in create_date_poll.php and removal date in choix_(date|autre).php
|
||||||
|
@ -30,7 +30,7 @@ $smarty->assign('SERVER_URL', Utils::get_server_name());
|
|||||||
$smarty->assign('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']);
|
$smarty->assign('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']);
|
||||||
$smarty->assign('TITLE_IMAGE', IMAGE_TITRE);
|
$smarty->assign('TITLE_IMAGE', IMAGE_TITRE);
|
||||||
$smarty->assign('use_nav_js', file_exists($_SERVER['DOCUMENT_ROOT'] . '/nav/nav.js'));
|
$smarty->assign('use_nav_js', file_exists($_SERVER['DOCUMENT_ROOT'] . '/nav/nav.js'));
|
||||||
$smarty->assign('html_lang', $html_lang);
|
$smarty->assign('locale', $locale);
|
||||||
$smarty->assign('langs', $ALLOWED_LANGUAGES);
|
$smarty->assign('langs', $ALLOWED_LANGUAGES);
|
||||||
$smarty->assign('date_format', $date_format);
|
$smarty->assign('date_format', $date_format);
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<div class="input-group input-group-sm pull-right col-md-2 col-xs-4">
|
<div class="input-group input-group-sm pull-right col-md-2 col-xs-4">
|
||||||
<select name="lang" class="form-control" title="{__('Language selector', 'Select the language')}" >
|
<select name="lang" class="form-control" title="{__('Language selector', 'Select the language')}" >
|
||||||
{foreach $langs as $lang_key=>$lang_value}
|
{foreach $langs as $lang_key=>$lang_value}
|
||||||
<option lang="{substr($lang_key, 0, 2)}" {if substr($lang_key, 0, 2)==$html_lang}selected{/if} value="{$lang_key|html}">{$lang_value|html}</option>
|
<option lang="{substr($lang_key, 0, 2)}" {if substr($lang_key, 0, 2)==$locale}selected{/if} value="{$lang_key|html}">{$lang_value|html}</option>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</select>
|
</select>
|
||||||
<span class="input-group-btn">
|
<span class="input-group-btn">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="{$html_lang}">
|
<html lang="{$locale}">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user