3
It works fine thanks to Phppp and Dugris for help
This is a rapid hack to make your multinlingual website serve language base on the url asked by the user (with xlanguage).
In this example, if the user is browsing
http://www.example.fr, the site will be showing in french and if he's browsing
http://www.example.com the site will be showing in english.
This is much better if you care about search engine indexing.
Note that both wwww.example.com and
http://www.example.fr should be pointing to the same directory.
I will try to make those changes part of the xlanguage module and submit it to phppp as soon as I find the time.
Modify mainfile.php:
Line 40:
le="color: #000000"><?php // XOOPS Virtual Path (URL) // Virtual path to your main XOOPS directory WITHOUT trailing slash // Example: define('XOOPS_URL', 'http://www.example.com'); $http_host = getenv("HTTP_HOST"); define('XOOPS_URL', 'http://'.$http_host);
Modify /modules/xlanguage/inclule/functions.php:
Line 109:
le="color: #000000"><?php function xlanguage_detectLang() { global $available_languages,$_SERVER; // if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { // $HTTP_ACCEPT_LANGUAGE = $_SERVER['HTTP_ACCEPT_LANGUAGE']; // } // if (!empty($_SERVER['HTTP_USER_AGENT'])) { // $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT']; // } $lang = ''; $xoops_lang =''; // 1. try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE // variable // if (empty($lang) && !empty($HTTP_ACCEPT_LANGUAGE)) { // $accepted = explode(',', $HTTP_ACCEPT_LANGUAGE); // $acceptedCnt = count($accepted); // reset($accepted); // for ($i = 0; $i < $acceptedCnt; $i++) { // $lang = xlanguage_lang_detect($accepted[$i], 1); // if(strncasecmp($lang,'en',2)){ // break; // } // } // } // 2. try to findout user's language by checking its HTTP_USER_AGENT variable // if (empty($lang) && !empty($HTTP_USER_AGENT)) { // $lang = xlanguage_lang_detect($HTTP_USER_AGENT, 2); // } // 3. If we catch a valid language, configure it // if (!empty($lang)) { // $xoops_lang = $available_languages[$lang][1]; // } //Hack by smart $http_host = getenv("HTTP_HOST"); if ($http_host=='www.example.com'){ //your english url $xoops_lang = 'english'; } elseif ($http_host=='www.example.fr'){ //your french url $xoops_lang = 'french'; } else { $xoops_lang = 'english'; } return $xoops_lang; }
Hope this helps