Support » Plugin: Polylang » [Plugin: Polylang] Language switcher

  • Resolved close

    (@close)


    Chouby, you seem to spend all your time on this wonderful plugin!
    I noticed the language switcher doesn’t update the preferred language cookie from A to B when no translated (B) version of the actual page is available. In fact, it links back to the same page (A). Wouldn’t it be more logical in that case to go back to the home page or to a Not Found page (both B versions)?

    http://wordpress.org/extend/plugins/polylang/

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Chouby

    (@chouby)

    you seem to spend all your time on this wonderful plugin!

    How did you guess ?

    Coming back to your question, I am not sure I catched what you mean. So I will explain how I expect things to work (with default options).

    You visit a page in English. The cookie is set to English.
    You click on the switcher to visit the French translation:
    If the translation exists, you are sent to the translated page. If it does not exist, you are sent to the homepage in French. In both cases, the cookie is set to French.

    If it does not work this way on your site, then I am interested to know and to have a link.

    In the language switcher there is an option to force the link to the homepage even if there is translation (it was a user request).

    If you want to send the visitor to a “not found page” instead of the homepage when there is no translation, then you need to write some code and use the filter pll_the_language_link (the received url is null when there is no translation available).

    Hi . czech flag have bad name

    need rename
    …/plugins/polylang/flags/cz_CZ.png
    to
    …/plugins/polylang/flags/cs_CZ.png

    thanks

    Thread Starter close

    (@close)

    If it does not exist, you are sent to the homepage in French. In both cases, the cookie is set to French.

    Unfortunately it’s not working like that on my site. The cookie is not changed when the translation does not exist. Nor am I sent to the homepage (which uses a different template). I’ll send a link via your private website, my site is still in progress.

    Plugin Author Chouby

    (@chouby)

    @inform

    You are right. Thank you for reporting. I will correct that in the next version.

    @close

    Obviously, there is a bug. I will try to reproduce it on my test site.
    Which version of Polylang are you using ?

    Please check if I am right for the options:
    *You keep /language/ in pretty permalinks
    *You don’t hide the language code for default language
    *You add the language code to all urls

    What is the default language ?
    Which permalink structure are you using ?

    Thread Starter close

    (@close)

    Which version of Polylang are you using ? -> 0.7.2

    Please check if I am right for the options:
    *You keep /language/ in pretty permalinks -> Yes
    *You don’t hide the language code for default language -> Yes (I don’t hide)
    *You add the language code to all urls -> Yes

    What is the default language ? -> Dutch
    Which permalink structure are you using ? -> /%postname%/

    Actually, I switched these settings endlessly, but no results. May I be missing something?
    I deactivated ALL plugins except Polylang. I re-read the documentation. This is a page-only site. I don’t use the widget, I don’t use any pll-functions.
    However, I noticed my .htaccess was not writable, so I made it writable and saved the settings again. Still no changes. These are the rewrite rules.

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /d/
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /d/index.php [L]
    </IfModule>

    # END WordPress

    Plugin Author Chouby

    (@chouby)

    I do not succeed to reproduce…

    On the admin side, on the “all pages” panel, on the line corresponding to your non translated page, do you see a pencil or a plus in the English column ?

    If you edit the page (not quick edit) and just resave it, does it change something ?

    Thread Starter close

    (@close)

    In the English column is a plus. No change when saved again.

    Wow, I just installed a new WP site and could reproduce this behaviour immediately…
    http://www.janboeijink.nl/wptest/test-nl/
    This is a Dutch page and there is no English translation available.
    The ‘English’ link goes to the Dutch page again…

    Plugin Author Chouby

    (@chouby)

    I did the same. And finally reproduced the bug ! I will come back to you later…

    Thread Starter close

    (@close)

    Thanks! Can’t wait! 🙂

    Plugin Author Chouby

    (@chouby)

    I finally got it ! This one was really well hidden and I believed it would drive me crazy !

    The bug occurs when no page for posts is set (a case I did not test previously). Obviously, since you don’t have posts, you don’t set this page for posts !

    Here is a quick fix that I will of course introduce in the future version.

    Edit the file include/core.php at line 459 (0.7.2) and replace:

    $this->get_post($wp_query->queried_object_id, $language) == ($id = $this->get_post($this->page_for_posts, $language)))

    by

    $this->get_post($wp_query->queried_object_id, $language) == ($id = $this->get_post($this->page_for_posts, $language)) && $id)

    thank you for your patience !

    Thread Starter close

    (@close)

    Man, you’re fast!!! I didn’t even need to be patient :-)))
    It works on both sites! But what is a page for posts?

    Which makes me think… wouldn’t it be better if the cookie is changed, independently of the link being succesful or not?

    Anyway, thank you so much & good night!

    Plugin Author Chouby

    (@chouby)

    When using a static front page, your homepage does not display anymore the list of posts. So WordPress allows you to setup a page which will display the list of posts. It is setup in Settings->Reading, just below the static front page.

    In fact, the cookie is not very important in Polylang. It’s used only on pages which have not a defined language ie the homepage (not in all cases) and the Error 404 page. In all other cases, the language is defined by the content being requested.

    Thread Starter close

    (@close)

    I see. Thanks for explaining.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘[Plugin: Polylang] Language switcher’ is closed to new replies.