Skip to content
Snippets Groups Projects
Commit d73ca37f authored by Olivier PEREZ's avatar Olivier PEREZ
Browse files

Select the right lang in the Language select box

parent 66edd29b
No related branches found
No related tags found
No related merge requests found
......@@ -17,9 +17,6 @@
* Auteurs de Framadate/OpenSondage : Framasoft (https://github.com/framasoft)
*/
// Sort languages
asort($ALLOWED_LANGUAGES);
// Prepare I18N instance
$i18n = \o80\i18n\I18N::instance();
$i18n->setDefaultLang(DEFAULT_LANGUAGE);
......@@ -27,16 +24,12 @@ $i18n->setPath(__DIR__ . '/../../locale');
// Change langauge when user asked for it
if (isset($_POST['lang']) && is_string($_POST['lang']) && in_array($_POST['lang'], array_keys($ALLOWED_LANGUAGES))) {
$locale = $_POST['lang'];
$_SESSION['lang'] = $_POST['lang'];
} elseif (!empty($_SESSION['lang'])) {
$locale = $_SESSION['lang'];
} else {
$locale = DEFAULT_LANGUAGE;
}
/* <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['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('TITLE_IMAGE', IMAGE_TITRE);
$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('date_format', $date_format);
......
......@@ -4,7 +4,7 @@
<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')}" >
{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}
</select>
<span class="input-group-btn">
......
<!DOCTYPE html>
<html lang="{$html_lang}">
<html lang="{$locale}">
<head>
<meta charset="utf-8">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment