WordPress Plugin: Simple Language Switcher

A simple and lightweight plugin that displays a customizable language switcher.

Simple Language Switcher is a very simple and lightweight plugin that allows you to display a language switcher on your site.
This plugin allows your visitors to switch the language of your site. This is not a back-end (admin interface) language switcher.


  • You can easily customize the display of your language switcher (language ISO codes, language names or flags).
  • Current language detection with regex: avoids displaying a link to the same page in the same language.
  • Interconnect your post in different languages (avoids the user to be redirected to the home page when switching to another language).
  • Generates rel=”alternate” hreflang=”x” links for SEO purposes.

I recommend you to use this plugin over the WordPress multisite feature, which lets you have one site per language under a single WordPress installation.


  1. Search for “simple language switcher” through the menu Plugins > Add New in your WordPress administration interface
  2. Activate the plugin
  3. Configure the plugin in the menu Settings > Simple Language Switcher
  4. Enjoy!

Is this plugin right for you?

This is not an attempt to make a plugin offering a complete multilingual solution for your multisite network installation; you will find better plugins out there for this.
Then why would you need this one?

  • The features offered by this plugin is all you need.
  • You’re looking for a very simple, lightweight plugin (so simple that you can quickly dive into the code and modify it yourself for it to suit your needs).
  • You want to be able to interconnect your posts in different languages, without the requirement to have each post translated into all the other languages.


Displaying the language switcher

1. as a widget

The easiest way to display the language switcher is to drag and drop the Simple Language Switcher Widget into your sidebar under Appearance > Widgets

2. in your theme

Display the language switcher wherever you want in your theme calling the function simple_language_switcher() (check that the function exists first).
For example, if you are using a child theme of the default WordPress theme, you could add the following code right under the #page element in the header.php file:

<?php if( function_exists( 'simple_language_switcher' ) ) { ?>
<div id="simple-language-switcher"><?php simple_language_switcher(); ?></div>
<?php } ?>

Then add the CSS rules below into your main CSS file:



The settings in the admin interface allow you to:

  1. add the languages you need
  2. customize the output of the language switcher
  3. interconnect your posts in different languages

Go to your administration interface and click on the menu Settings > Simple Language Switcher

Main Settings section

here you can chose the display style for your language switcher

  • Language names: e.g. english | french | dutch
  • Language ISO codes: e.g. en | fr | nl
  • Flags: this will display flag icons for the languages

If you want to use the flags, copy the appropriate flag into the wp-content/plugins/simple-language-switcher/flags folder. A set of available flag icons (from FamFamFam) can be found in the archive file wp-content/plugins/simple-language-switcher/flags/famfamfam_flag_icons.zip. You can extract a flag from that archive and paste it into the wp-content/plugins/simple-language-switcher/flags folder (perhaps you will have to rename it to the appropriate language code).

Note about using flags: the w3 community doesn’t recommend using flags to indicate languages.

“Flags represent countries, not languages. Numerous countries use the same language as another country, and numerous countries have more than one official language. Flags don’t map onto these permutations.”

Source: http://www.w3.org/TR/i18n-html-tech-lang/#ri20040808.173208643

Languages section

For each language that you want to add, you should specify:

  • the ISO code (“fr” for French, “en” for English, etc.)
  • the language name (french, english, etc.)
  • the home URL for that language (http://example.com/fr, http://example.com/en, etc.)
  • optionally the regex that will deduce the current language from the URL

About your URLs: it is strongly recommended (for SEO purposes) to have unique URLs for each page in each language and to follow a logical URL pattern for each language that is easily understood by search engines.
For example, you could have the French and Dutch translated pages of your site all preceded respectively by fr/ and nl/, as if they were in separate subdirectories:
http://example.com/fr/a-propos (“about us” page translated into French)
http://example.com/nl/over-ons (“about us” page translated into Dutch)
http://example.com/about-us (original page in English)
Read more about this topic here: http://support.google.com/webmasters/bin/answer.py?hl=en&answer=182192

Regex setting

The regex has only one purpose: to avoid displaying a link to the same page in the same (current) language.
For example, suppose we are now visiting the http://example.com/about-us page, and the language switcher looks like en | fr | nl . If you activate and specify the right regex for each language, there will be no link on the English ISO code as we are already visiting the page in the English version (thus a link will appear for fr and nl that will forward us to the translated versions, but not for en).
For the example URLs used above, the regex for each language would look like:

  • French: ~/fr(?:$|/)~
  • Dutch: ~/nl(?:$|/)~
  • English:

Note that the regex for the English version must be empty in our example, as there is no ISO code in the URL to deduce it is English; if there is no match found with the regex to detect French and Dutch language, the matching language will be English. In other words, the language with the empty regex, will be the matching language if no other match have been found. There can be only one empty regex.

Posts Linking section

This section allows you to specify the relations between your posts in different languages. In other words it allows you, for a specific page, to tell which are the same pages translated into other languages.
Let’s take again our example URLs above. If we are visiting the http://example.com/about-us page and we didn’t specify the translated pages for that page, then the user will, by default, be forwarded to the home URL of the language clicked. However if we do specify the relations between our pages in different languages, then the user may be forwarded to the same page translated into different languages, in our case http://example.com/fr/a-propos and http://example.com/nl/over-ons.

rel=”alternate” hreflang=”x” links

This plugin generates rel=”alternate” hreflang=”x”  helping search engines to serve the correct language to searchers.
Read more about this topic here: http://support.google.com/webmasters/bin/answer.py?hl=en&answer=189077


Did you enjoy this plugin? Please take a moment to rate and comment, this will keep me motivated to update this plugin for bugfixes and WordPress upgrades.

Before you downvote this plugin

  • Again, understand that this is not an attempt to make a plugin for a complete multilingual solution.
  • It didn’t work for you? You found a bug? Give me a description with some details in the support forum, and I will fix it as soon as I can.
  • For some reason, you didn’t like it? Share me your suggestions in the support forum, and perhaps I will work on it.

18 Replies to “WordPress Plugin: Simple Language Switcher”

  1. “I recommend you to use this plugin over the WordPress multisite feature, which lets you have one site per language under a single WordPress installation.”

    Why? I’m trying to decide on an approach to setting up a bilingual site and have had that one recommended to me.

    I would describe your plug-in more as a posts-linker than a language switcher in that the switched-to post isn’t language aware, the menus and other WordPress content doesn’t switch language too based on .mo files, or at least it doesn’t appear to based upon this demo.

    So, I’m wondering why you recommend this approach when it seems incomplete in that sense and to change menus etc. will require another additional solution?

  2. Hi, thanks for the nice plugin.

    I activated it on my site and I notice that it prevents me from signing in to the administration panel. I mean, if I go to site/wp-admin/ I see “You do not have sufficient permissions to access this page.” although if I go to site/wp-login.php I can log in. Any idea what’s the problem?

    I know it’s because of the plugin because deactivating it fixes this issue. I could give you more details if you tell me what you need.


    1. I fixed this issue in the new version 1.1. Thanks for reporting!
      Before you update, make sure to backup the plugin’s directory. Then copy links.php and my-langs.php files from your backup directory to your remote directory.

  3. Hi,

    nice plugin.
    I have used for few days now but today I got the same error message. When opening wp-admin page I got the “You do not have sufficient permissions to access this page.” message.

    Deactivating the language switcher fixed the issue. Let me know if you want more details.



    1. I fixed this issue in the new version 1.1. Thanks for reporting!
      Before you update, make sure to backup the plugin’s directory. Then copy links.php and my-langs.php files from your backup directory to your remote directory.

  4. I am getting php errors after enabling the latest version:

    Warning: fopen(/Library/WebServer/Documents/xxxx/wp-content/plugins/simple-language-switcher/my-langs.php.lock) [function.fopen]: failed to open stream: Permission denied in /Library/WebServer/Documents/xxxx/wp-content/plugins/simple-language-switcher/admin/options-page.php on line 479

    Warning: fclose() expects parameter 1 to be resource, boolean given in /Library/WebServer/Documents/xxxx/wp-content/plugins/simple-language-switcher/admin/options-page.php on line 480

    any idea what could be wrong?
    thanks in advance

  5. Respect 🙂 great plugin for switching language..

    but i want to add something,. if it possible

    example: pageID30(EN) pageID40(RU) are interconnected and i switch EN to RU everything is ok.. but if i click on some new page it return to default (EN)..

    is it possible to stay on language which was on last switch?

      1. i have only 5 pages.. and i want to switch 2-3 languages.. there is not many data..
        Default: English
        SEcond: Russian
        Third: Georgian

        problem is in switching.. if i choice Russian and go other page .. other page is English (default)

        its possible to stay on Russian when russian is choiced

        tnx for answer 🙂

Post a Comment