Setting language without $_GET

dev.xiligroup is being renovated Forums xili-language plugin Setting language without $_GET

Tagged: , ,

This topic contains 0 replies, has 2 voices, and was last updated by  Anonymous 13 years, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2947

    Anonymous

    After I wrote this, I tried writing this code in the beginning of your plugin:

    if(isset($_GET)){

    setcookie(‘lang’, $_GET);

    }

    elseif(isset($_COOKIE)){

    $_GET = $_COOKIE;

    }

    Now it’s working :) I think you must definitely use that in next versions if you didn’t.

    #2948

    Anonymous

    Your approach can be interesting according circumstances of uses. Do you know that xili-language is hookable, so you can change the behaviour how the language of theme is selected. Take a little time to read the source code and discover the « filter » entries. $_GET is a way to find explicitly the lang from URI but the_curlang function give you the language just after the famous loop of wp (specially when page or home or frontpage…).

    #2949

    Anonymous

    Ahm, it requires a bit time. Instead of reading the source code, I rather writing it from the beginning :p

    By the way, I added the code (above) inside set_when_plugin_loaded() function and expanded it:

    if(!is_admin()){

    $myLangs = $this->xili_settings;

    if(isset($_GET))

    {

    $check = false;

    foreach($myLangs as $l){

    if($l->slug == $_GET){

    setcookie(‘lang’, $_GET);

    $check = true;

    break;

    }

    }

    if($check == false){

    foreach($myLangs as $l){

    if($l->name == WPLANG){

    $_GET = $l->slug;

    setcookie(‘lang’, $l->slug);

    break;

    }

    }

    }

    }

    elseif(isset($_COOKIE)){

    $_GET = $_COOKIE;

    }}

    This checks if the get value of lang is available on language lists or not. If it’s not available, it sets the default language. Hope this helps people sharing my opinion.

    Have a good day.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.