Commit 4862f1be authored by Okhin's avatar Okhin

Translatiosn are now fixed

parent b7071163
Pipeline #2346 canceled with stages
in 6 minutes and 45 seconds
...@@ -19,7 +19,3 @@ DEBUG=0 ...@@ -19,7 +19,3 @@ DEBUG=0
; Langue par défaut ; Langue par défaut
LANGUAGE='fr' LANGUAGE='fr'
; Variables globales du site
languages=["fr-FR", "en-US"]
...@@ -28,6 +28,8 @@ define("CTX_MODE", getenv('CTX_MODE')); ...@@ -28,6 +28,8 @@ define("CTX_MODE", getenv('CTX_MODE'));
//define("CERTIFICATE","XXXXXXXXXXXXXXXXXXXXXXXXx"); //define("CERTIFICATE","XXXXXXXXXXXXXXXXXXXXXXXXx");
//define("CTX_MODE","PRODUCTION"); //define("CTX_MODE","PRODUCTION");
define("LANGUAGES", ["fr_FR", "en_US"]);
define("PIPLOME_PATH", getenv('PIPLOME_PATH')); define("PIPLOME_PATH", getenv('PIPLOME_PATH'));
define("PIPLOME_URL", getenv('PIPLOME_URL')); define("PIPLOME_URL", getenv('PIPLOME_URL'));
......
...@@ -23,32 +23,46 @@ class Controller ...@@ -23,32 +23,46 @@ class Controller
define("ROOTURL", "https://".$HTTP_HOST.'/'); define("ROOTURL", "https://".$HTTP_HOST.'/');
// Sélection de la langue par header // Sélection de la langue par header
$lang = 'fr-FR'; $lang = 'fr_FR';
$lang_short = 'fr'; $lang_short = 'fr';
var_dump($f3->get('HEADERS')); if ($f3->exists('GET.lang')) {
/*$accept_languages = $f3->exists('HEADERS.Accept-Language') ? $f3->get('HEADERS.Accept-Language').split[','] : []; // On force la langue passée dans l'URL GET
//$accept_languages[] = $f3->exists('GET.lang') ? $f3->get('GET.lang') : 'C' ; $accept_languages = [$f3->get('GET.lang')];
foreach ($f3->get('languages') as $language) { $f3->set('SESSION.lang', $f3->get('GET.lang'));
} else {
if ($f3->exists('SESSION.lang')) {
// On a déjà défini une langue précédemment
$accept_languages = [$f3->get('SESSION.lang')];
} else {
// On récupère la langue du navigateur
$accept_languages = $f3->exists('HEADERS.Accept-Language') ? explode(',', $f3->get('HEADERS.Accept-Language')) : [];
}
}
foreach (LANGUAGES as $language) {
foreach ($accept_languages as $accept_language) { foreach ($accept_languages as $accept_language) {
if (substr($language, $accept_language) > 0) { if (strpos($language, $accept_language)>=0) {
$lang = $language; $lang = $language;
$lang_short = explode($language, '-')[0]; $lang_short = explode($language, '-')[0];
} }
} }
} }
*/
if (!bindtextdomain("messages", dirname(__FILE__)."/../locales")) { var_dump($lang);
if (!bindtextdomain("messages", "../locales/")) {
var_dump(bindtextdomain("messages", "../locales/"));
echo "<!-- bondtextdomain failed -->"; echo "<!-- bondtextdomain failed -->";
} }
// Language ok, set the locale environment // Language ok, set the locale environment
putenv("LC_MESSAGES=".$lang); putenv("LC_MESSAGES=".$lang);
putenv("LANG=".$lang); putenv("LANG=".$lang);
putenv("LANGUAGE=".$lang); putenv("LANGUAGE=".$lang);
// this locale MUST be selected in "dpkg-reconfigure locales"
if (!setlocale(LC_ALL, $lang)) { if (!setlocale(LC_ALL, $lang)) {
echo "<!-- setlocale failed -->"; echo "<!-- setlocale $lang failed -->";
} }
if (!textdomain("messages")) { if (!textdomain("messages")) {
echo "<!-- textdomain failed -->"; echo "<!-- textdomain failed -->";
} }
......
...@@ -90,8 +90,8 @@ ...@@ -90,8 +90,8 @@
<div class="hidden-xs hidden-sm"> <div class="hidden-xs hidden-sm">
<nav id="up-bar" class="navbar navbar-default dark-blue"> <nav id="up-bar" class="navbar navbar-default dark-blue">
<ul class="nav navbar-nav navbar-right blue"> <ul class="nav navbar-nav navbar-right blue">
<li><a href="?lang=fr">{{ _("[FR]")}}</a></li> <li><a href="?lang=fr_FR">{{ _("[FR]")}}</a></li>
<li><a href="?lang=en">{{ _("[EN]")}}</a></li> <li><a href="?lang=en_US">{{ _("[EN]")}}</a></li>
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<check if="{{ array_key_exists('user', @SESSION) }}"> <check if="{{ array_key_exists('user', @SESSION) }}">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment