• Resolved zearth

    (@zearth)


    Hi, I got a the latest version of wordpress and latest version of polylang.

    the issue right now is when I switch to italian lang it goes ok for the link, but when I visited my home from
    http://www.home.com/it/
    to
    http://www.home.com/

    it goes back to english which I expect it will still be italian lang, currently this is my settings which I used before is ok but now it is not working.

    1. The language code, for example /en/, is added to all urls when using pretty permalinks.
    2. Remove /language/ in pretty permalinks. Example: http://site.localhost.com/en/
    3. (CHECK)Hide URL language information for default language
    4. (CHECK)When using static front page, redirect the language page (example: http://site.localhost.com/en/) to the front page in the right language

    I tried to scramble all setting but still no luck, can you tell me if I have to do an extra setting to work on this part?

    Also I do have a rewriteURL which I’m sure it is not affecting it before, also I tried to disabled the rewriteURL and still the effects are just not working. thanks

    TIA

    regards,
    edward
    http://wordpress.org/plugins/polylang/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter zearth

    (@zearth)

    follow up update,
    I tried to disabled this setting

    – (UNCHECKED) Hide URL language information for default language

    it works with http://www.site.com/en/ but currently all of my english pages and post are 404 error, and if switch on this URL it will cause a problem on my google search list and fb/tweet counter.

    TIA

    Plugin Author Chouby

    (@chouby)

    This bug should be specific to 1.1.3. Did you update?

    Thread Starter zearth

    (@zearth)

    I think I found out now the problem on this error, as well on the top/parent pages causing the error. On my Template function I have a custom rewrite URL, if I remove this and reset the rewrite_rules it works ok, but if I add again it cause error on polylang url structure.

    Do you know a way on how on how I can hookup this on polylang which will side by side works ok? Thanks

    ///// rewrite a new permalink structure s
    add_filter('init','flushRules');
    add_filter('rewrite_rules_array','wp_insertMyRewriteRules');
    function flushRules(){
    global $wp_rewrite;
    $wp_rewrite->flush_rules();
    }
    
    function wp_insertMyRewriteRules($rules){
    $mypath = htmlspecialchars(strip_tags(trim($_SERVER["REQUEST_URI"])));
    $mypath = preg_replace('/(.*)\?(.*)/', '$1', $mypath);
    $urlbit = explode("/",$mypath);
    
    $newrules = array();
    $newrules['news/(press-release|in-the-press|case-studies|events|industry-insight)/?$'] = 'index.php?page_id='.NEWSSYSID.'&posttype=$matches[1]';
    $newrules['news/(press-release|in-the-press|case-studies|events|industry-insight)/page/([0-9]+)/?$'] = 'index.php?page_id='.NEWSSYSID.'&posttype=$matches[1]&paged=$matches[2]';
    $newrules['news/(press-release|in-the-press|case-studies|events|industry-insight)/archive/([0-9]+)/([0-9]+)/?$'] = 'index.php?page_id='.NEWSSYSID.'&posttype=$matches[1]&mm=$matches[3]&year=$matches[2]';
    $newrules['news/(press-release|in-the-press|case-studies|events|industry-insight)/archive/([0-9]+)/([0-9]+)/page/([0-9]+)/?$'] = 'index.php?page_id='.NEWSSYSID.'&posttype=$matches[1]&mm=$matches[3]&year=$matches[2]&paged=$matches[4]';
    $newrules['news/(press-release|in-the-press|case-studies|events|industry-insight)/archive/([0-9]+)/?$'] = 'index.php?page_id='.NEWSSYSID.'&posttype=$matches[1]&year=$matches[2]';
    $newrules['news/(press-release|in-the-press|case-studies|events|industry-insight)/archive/([0-9]+)/page/([0-9]+)/?$'] = 'index.php?page_id='.NEWSSYSID.'&posttype=$matches[1]&year=$matches[2]&paged=$matches[3]';
    
    return $newrules + $rules;
    }
    
    add_filter('query_vars', 'add_my_var');
    function add_my_var($public_query_vars) {
    $public_query_vars[] = 'posttype';
    $public_query_vars[] = 'mm';
    $public_query_vars[] = 'year';
    $public_query_vars[] = 'paged';
    return $public_query_vars;
    }
    ///// rewrite a new permalink structure e
    Thread Starter zearth

    (@zearth)

    its now working, never mind the post above, I used

    add_rewrite_rule()

    to fix the issue

    thanks

    I’d like to elaborate a bit on this.

    The site I’ve developed with polylang works perfectly on my dev and staging environment (ubuntu, php 5.4.17(dev) 5.3.6(test), nginx) but on my client’s (cent os, php 5.3.3, apache) it doesn’t.

    By visiting the site without cookies, the cookie is always set to the default language like so (default lang = sl):

    domain.tld             <-- redirects to /domov/ - cookie = sl
    domain.tld/domov/      <-- cookie = sl
    domain.tld/home/       <-- (english tl of /domov/) - cookie = sl
    domain.tld/startseite/ <-- (german tl of /domov/) -cookie = sl

    On subsequent visit, the cookie value is never touched and stays at sl. Because of that, event though /home/ shows the english content, the menus, widgets and gettext translated template strings don’t change.

    I know the cookie isn’t touched because I can manually edit its value. E.g. I change the cookie value to en and I get menus, widgets and template strings in english as expected.

    I don’t have access to my client’s server right now and can’t look at the logs to debug this. Any idea what might be going on?

    I’ve tried versions 1.1.3 and 1.1.4. Both work on my dev environment, none on my client’s.

    Polylang’s settings:

    Default lang: Slovenian
    Language set from content
    Remove /language/
    
    Everything else unchecked except for a few synchronization items and 1 custom taxonomy.

    Thanks

    Digging deeper $this->curlang is always default. The get_current_language method doesn’t update it because it always exits at the first check:

    if ($this->curlang)
        return $this->curlang;

    Dumping $polylang on every page shows curlang always populated with the default language, no matter which language the post I’m viewing is in:

    object(Polylang_Core)#201 (20) {
      ["curlang"]=>
      object(stdClass)#279 (9) {
        ["term_id"]=>
        string(1) "2"
        ["name"]=>
        string(13) "Slovenščina"
        ["slug"]=>
        string(2) "sl"
        ["term_group"]=>
        string(1) "0"
        ["term_taxonomy_id"]=>
        string(1) "2"
        ["taxonomy"]=>
        string(8) "language"
        ["description"]=>
        string(5) "sl_SI"
        ["parent"]=>
        string(1) "0"
        ["count"]=>
        string(2) "92"
      }
    ...

    Any idea what’ missing on my client’s server? Maybe a configuration setting or something. I need to get their sysadmin to give me full access. Meanwhile I’ll dig some more.

    @chouby, this bit (core.php:486):

    if (false === stripos($_SERVER['SCRIPT_NAME'], $GLOBALS['wp_rewrite']->index)) {
    	$this->curlang = $this->get_preferred_language();
    	return;
    }

    prevent the plugin from working correctly in my case. After commenting it out, everything worked flawlessly.

    What is it for and is it really needed?

    Plugin Author Chouby

    (@chouby)

    That’s rather strange. In fact I test if the script is ‘index.php’. If not (for example if it is wp-signup.php) then the language is loaded from the cookie. If yes, then it is standard content, and the language will be set from content (page, post, etc…)

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Language choose not storing session or cookie?’ is closed to new replies.