1
neill
how to disable Xlanguage auto language detection
  • 2006/8/5 3:25

  • neill

  • Just popping in

  • Posts: 16

  • Since: 2006/7/23


as title says, im building a chinese site for chinese in australia, ofcourse most of my users are from australia, but are chinese, and most likely they will have location set to australia, so they will get english as the auto detection in xlanguage

but i'll like to have default language of chinese to emphasis this is a chinese community

[edit]
dont worry, fixed, this is extreemly difficult to detect, i have to clean my cookie to see the effect

change i made was
xlanguage/include/functions.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];
    }*/
    
return "schinese";
}

2
Dona_Brasil
Re: how to disable Xlanguage auto language detection

If you want to do it hackfree (which makes it easier to update), do it with htaccess.

Let's suppose that you want to make English your default language and that http://www.yourdomain.com/index.php?lang=en is your startpage in English. Add this line to your .htaccessfile

DirectoryIndex index.php?lang=en


or, depending on your language folder name

DirectoryIndex index.php?lang=english


If you then go to http://www.yourdomain.com, you will get your page in English.

Use a different URL for each other language. This has SEO benefits too. This way, the URL were somebody enters your site determines the language.

3
irmtfan
Re: how to disable Xlanguage auto language detection
  • 2006/8/13 20:19

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


phppp as the author of this module give me this solution:

in api.php around line 53 comment these lines:
//}elseif($lang = xlanguage_detectLang())    {
//    $xlanguage["lang"] = $lang;


3lr0n: your solution maybe work but i think its better to solve it inside the module.

also there is many links with this pattern (&):
.../viewtopic.php?topic_id=450&forum=16&post_id=1584&lang=en

Login

Who's Online

315 user(s) are online (248 user(s) are browsing Support Forums)


Members: 0


Guests: 315


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits