Hello all,
I explain my problem : I have a website with 4 languages FR-DE-EN-IT and I want that when I click the language the current page need to be translated.
It's work when the page dont have any parameter.
with the page like this :
http://localhost:8888/contographie/index.php --> WORK
http://localhost:8888/contographie/index.php?lang=fr
But when i have this when I want to change to english :
http://localhost:8888/contographie/index.php?lang=fr?lang=en -> is not working :(
here the code
<?php
public function lnkLang_clic($strFormId, $strControlId, $strParameter){
$currentPage = $_SERVER["REQUEST_URI"];
QApplication::Redirect($currentPage.'?lang='.$strParameter);
}
?>
The code in the prepend.inc
<?php
/////////////////////////////
// Start Session Handler (if required)
/////////////////////////////
session_start();
//////////////////////////////////////////////
// Setup Internationalization and Localization (if applicable)
// Note, this is where you would implement code to do Language Setting discovery, as well, for example:
// * Checking against $_GET['language_code']
// * checking against session (example provided below)
// * Checking the URL
// * etc.
// TODO: options to do this are left to the developer
//////////////////////////////////////////////
if(isset($_GET['lang'])){
$_SESSION['language_code'] = $_GET['lang'];
}
if (isset($_SESSION)) {
if (array_key_exists('country_code', $_SESSION))
QApplication::$CountryCode = $_SESSION['country_code'];
if (array_key_exists('language_code', $_SESSION))
QApplication::$LanguageCode = $_SESSION['language_code'];
}
else{
QApplication::$LanguageCode = 'fr';
$_SESSION['language_code'] = QApplication::$LanguageCode;
}
$langFile = __DOCROOT__ . '/lang/lang_' . QApplication::$LanguageCode . '.php';
if(file_exists($langFile)){
require_once($langFile);
}
else{
require_once(__DOCROOT__ . '/lang/lang_fr.php');
}
?>
I hope that you get my problem and can help me, I would be very thankfull :P
What I would like it's that if the page it's like this :
http://localhost:8888/contographie/index.php?lang=fr
if I click english I would like that “?lang=fr” is replaced by “?lang=en” and no add in the end like before.
OR
Never have this parameter visible “?lang=...” but I don't know how to manage the change of language without it
And if the page have parameter the “?lang=fr” is modified like this “&lang=fr” :D
Sorry for my bad english hope that I'm quite understandable with my problem