Title: [Plugin: Polylang] Language switcher
Last modified: August 20, 2016

---

# [Plugin: Polylang] Language switcher

 *  Resolved [close](https://wordpress.org/support/users/close/)
 * (@close)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-polylang-language-switcher/)
 * 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/](http://wordpress.org/extend/plugins/polylang/)

Viewing 13 replies - 1 through 13 (of 13 total)

 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-polylang-language-switcher/#post-2578733)
 * > 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).
 *  [In-Form](https://wordpress.org/support/users/in-form/)
 * (@in-form)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-polylang-language-switcher/#post-2578747)
 * 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](https://wordpress.org/support/users/close/)
 * (@close)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-polylang-language-switcher/#post-2578749)
 * > 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](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-polylang-language-switcher/#post-2578787)
 * [@inform](https://wordpress.org/support/users/inform/)
 * You are right. Thank you for reporting. I will correct that in the next version.
 * [@close](https://wordpress.org/support/users/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](https://wordpress.org/support/users/close/)
 * (@close)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-polylang-language-switcher/#post-2578805)
 * _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](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-polylang-language-switcher/#post-2578808)
 * 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](https://wordpress.org/support/users/close/)
 * (@close)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-polylang-language-switcher/#post-2578812)
 * 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/](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](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-polylang-language-switcher/#post-2578814)
 * I did the same. And finally reproduced the bug ! I will come back to you later…
 *  Thread Starter [close](https://wordpress.org/support/users/close/)
 * (@close)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-polylang-language-switcher/#post-2578815)
 * Thanks! Can’t wait! 🙂
 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-polylang-language-switcher/#post-2578816)
 * 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](https://wordpress.org/support/users/close/)
 * (@close)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-polylang-language-switcher/#post-2578820)
 * 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](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-polylang-language-switcher/#post-2578850)
 * 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](https://wordpress.org/support/users/close/)
 * (@close)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-polylang-language-switcher/#post-2578851)
 * 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.

 * ![](https://ps.w.org/polylang/assets/icon-256x256.png?rev=3433336)
 * [Polylang](https://wordpress.org/plugins/polylang/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/polylang/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/polylang/)
 * [Active Topics](https://wordpress.org/support/plugin/polylang/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/polylang/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/polylang/reviews/)

 * 13 replies
 * 3 participants
 * Last reply from: [close](https://wordpress.org/support/users/close/)
 * Last activity: [14 years, 4 months ago](https://wordpress.org/support/topic/plugin-polylang-language-switcher/#post-2578851)
 * Status: resolved