Fix the selected item on langs selection

This commit is contained in:
Olivier PEREZ 2015-01-02 00:19:56 +01:00
parent a8345cf7f8
commit ca365ff348
4 changed files with 24 additions and 25 deletions

View File

@ -37,14 +37,14 @@ if (isset($_POST['lang']) && is_string($_POST['lang']) && in_array($_POST['lang'
}
$locale = $mlocale . '.utf8';//unix format
if (strtoupper(substr(PHP_OS,0,3))=='WIN'){
putenv("LC_ALL=$mlocale"); //Windows env. needed to switch between languages
switch ($mlocale){
case 'fr_FR' : $locale = "fra";break; //$locale in windows locale format, needed to use php function that handle text : strftime()
case 'en_GB' : $locale = "english";break; //see http://msdn.microsoft.com/en-us/library/39cwe7zf%28v=vs.90%29.aspx
case 'de_DE' : $locale = "deu";break;
case 'es_ES' : $locale = "esp";break;
}
if (strtoupper(substr(PHP_OS,0,3))=='WIN'){
putenv("LC_ALL=$mlocale"); //Windows env. needed to switch between languages
switch ($mlocale){
case 'fr_FR' : $locale = "fra";break; //$locale in windows locale format, needed to use php function that handle text : strftime()
case 'en_GB' : $locale = "english";break; //see http://msdn.microsoft.com/en-us/library/39cwe7zf%28v=vs.90%29.aspx
case 'de_DE' : $locale = "deu";break;
case 'es_ES' : $locale = "esp";break;
}
}
putenv('LANGUAGE=');//sert à quoi?
@ -66,14 +66,12 @@ $lang = ($_SESSION['langue']!='') ? strtolower($_SESSION['langue']) : 'fr';
/* Date Format */
$date_format['txt_full'] = _("%A, den %e. %B %Y"); //summary in choix_date.php and removal date in choix_(date|autre).php
$date_format['txt_short'] = "%A %e %B %Y"; // radio title
$date_format['txt_day'] = "%a %e";
$date_format['txt_date'] = _("%Y-%m-%d");
$date_format['txt_full'] = _('%A, den %e. %B %Y'); //summary in choix_date.php and removal date in choix_(date|autre).php
$date_format['txt_short'] = _('%A %e %B %Y'); // radio title
$date_format['txt_day'] = _('%a %e');
$date_format['txt_date'] = _('%Y-%m-%d');
if (strtoupper(substr(PHP_OS,0,3))=='WIN'){ //%e can't be used on Windows platform, use %#d instead
foreach($date_format as $k => $v) {
$date_format[$k] = preg_replace('#(?<!%)((?:%%)*)%e#','\1%#d', $v); //replace %e by %#d for windows
}
}

View File

@ -19,21 +19,26 @@
use Framadate\FramaDB;
use Framadate\Utils;
if (session_id() == '') {
session_start();
}
if (ini_get('date.timezone') == '') {
date_default_timezone_set('Europe/Paris');
}
include_once __DIR__ . '/constants.php';
include_once __DIR__ . '/i18n.php';
// Autoloading of dependencies with Composer
require_once __DIR__ . '/../../vendor/autoload.php';
include_once __DIR__ . '/i18n.php';
// Smarty
require_once __DIR__ . '/../../vendor/smarty/smarty/libs/Smarty.class.php';
$smarty = new \Smarty();
$smarty->template_dir = 'tpl/';
$smarty->compile_dir = 'tpl_c/';
$smarty->cache_dir = 'cache/';
$smarty->setTemplateDir('tpl/');
$smarty->setCompileDir('tpl_c/');
$smarty->setCacheDir('cache/');
$smarty->caching = false;
$smarty->assign('APPLICATION_NAME', NOMAPPLICATION);
@ -48,9 +53,5 @@ function smarty_modifier_poll_url($poll_id, $admin=false){return Utils::getUrlSo
function smarty_modifier_markdown($md) {return Utils::markdown($md);}
// End- Smarty
if (session_id() == '') {
session_start();
}
$connect = new FramaDB(DB_CONNECTION_STRING, DB_USER, DB_PASSWORD);
$err = 0;

View File

@ -28,7 +28,7 @@ function bandeau_titre($titre)
echo '
<header role="banner">';
if(count($ALLOWED_LANGUAGES)>1){
echo '<form method="post" action="#">
echo '<form method="post" action="">
<div class="input-group input-group-sm pull-right col-md-2 col-xs-4">
<select name="lang" class="form-control" title="'. _("Select the language") .'" >' . liste_lang() . '</select>
<span class="input-group-btn">

View File

@ -1,10 +1,10 @@
<header role="banner">
{if count($langs)>1}
<form method="post" action="#">
<form method="post" action="">
<div class="input-group input-group-sm pull-right col-md-2 col-xs-4">
<select name="lang" class="form-control" title="${_("Select the language")}" >
{foreach $langs as $lang_key=>$lang_value}
<option lang="{$lang_key|truncate:2:''}" selected value="{$lang_key}">{$lang_value}</option>
<option lang="{substr($lang_key, 0, 2)}" {if substr($lang_key, 0, 2)==$lang}selected{/if} value="{$lang_key}">{$lang_value}</option>
{/foreach}
</select>
<span class="input-group-btn">