Language Switcher WordPress Plugin

Introduction and Installation

No longer maintained!

Note from Jennifer Hodgdon, the plugin author: As of April 2010, this plugin is no longer being maintained. Please read this news posting for more details.

The Language Switcher plugin does work fine for WordPress 2.9.x. If you are attempting to use the Language Switcher on a later version of WordPress and it needs updates, or if you would like more features, and you have funding for your project, you (or a group of users) could consider hiring Poplar ProductivityWare to update the plugin. Or, you can modify it yourself (it is open-source software licensed under the GNU Public License). Or, if you or someone you know would like to take over maintenance of this plugin, please let me know.

If you don't want to use the Language Switcher plugin, the qTranslate plugin for WordPress may be a good alternative. I haven't tried it, but someone recommended it to me as a good alternative in May of 2010.


Translations of this site are available (not sure how up-to-date they are, so use at your own risk):


Introduction

The Language Switcher WordPress plugin allows you to create a bilingual or multi-lingual blog or site, using WordPress. The way it works is that you write the content for your site in multiple languages, using special tags to tell the plugin which text goes with which language. You'll also install "gettext" language files to translate the text generated by your theme, other plugins, and WordPress itself into your target languages. The Language Switcher plugin will then let your site viewers choose a language for viewing your site, and put all the text on the screen into the right language.

Unfortunately, setting up a multi-lingual site does take some work. You will need to follow all the steps on this site carefully to get your site functioning properly, and it will require at least a passing knowledge of WordPress and probably HTML. Also, unfortunately many WordPress themes and plugins that other people have written are not set up properly for internationalization and multi-lingual sites with the Language Switcher. Instructions are given on this site on how to fix them, but it will require some PHP programming (or at least PHP editing) to fix some plugins and themes. So, be prepared! The good news is that the core of WordPress has a lot of functionality, and the Language Switcher works well with the core WordPress functionality.

Note: Language Switcher does not do any translations! It just allows you to display text that you have provided, in the language preferred by your site's visitors. There are other plugins that can be used to create multilingual sites that have different approaches, including automatic machine translations. To find other plugins, see the Plugins article at wordpress.org.

Since setting up a bilingual or multi-lingual site is rather complex, this web site is basically a tutorial on how to get your site set up, from start to finish. Please follow all of the instructions on all of these pages!

Terminology note for Windows and Mac users: the word "directory" in this article is the same as "folder" -- a location containing files on a computer.


Installing or Upgrading Blog Software

WordPress Install or Upgrade

The first step in creating a bilingual or multi-lingual site with the Language Switcher is to install or upgrade WordPress. The Language Switcher is mostly compatible with WordPress 2.1.2 and later versions. However, the released versions of WordPress have some little bugs or features that make them not quite compatible with the Language Switcher plugin, so please follow these instructions to install WordPress, or to upgrade to a new version. Important: later on, after using the Language Switcher, please return to this page and follow the instructions below in order to upgrade your bilingual or multi-lingual site to a new version of WordPress.

  1. Read the instructions in the WordPress Installation Guide or (WordPress Upgrade Guide if you are updating from a previous version). But -- don't follow them exactly yet! Instead, follow these slightly modified steps.
  2. Download the latest version of WordPress zip file from the WordPress download page. Important: Do not download from any other site! Especially, do not get a version that has been modified for a foreign language. To make a multi-lingual version work, you will need to start with the English-language, standard version of WordPress. If you start with a different version, you will probably encounter problems, because some foreign-language WordPress versions have modified files that are not compatible with multi-lingual operation.
  3. Unzip the file onto your personal computer.
  4. If you are installing for the first time, set up your MySQL server as described in the Installation Guide. If you are upgrading, back up your previous MySQL database as described in the Upgrading guide.
  5. Modify the configuration file (as described in the Installation guide -- if you are upgrading, you can download your previous configuration file from your site).
  6. If your configuration file (wp-config.php) has this line in it, remove this line -- it seems to be incompatible with the Language Switcher in some circumstances:
    define('ENABLE_CACHE', true);
    Also, if you are using a language that uses a non-western character set (such as Chinese or Hebrew), you may need to remove these two lines from your configuration file, in order to display those characters:
    define('DB_CHARSET', 'utf8');
    define('DB_COLLATE', '');
    See this page on the WordPress support forum for more information. David, a Chinese/English Language Switcher user also wrote and said that for him, removing those lines didn't work. What worked was changing those lines to match what his database was currently using, which you can find in PHPMyAdmin. The Character Set setting is displayed on the PHPMyAdmin home page (it's usually utf8, I think), and the Collate setting is displayed when you choose a database or database table. If you have a working database table that is able to display your language's characters in PHPMyAdmin, then you should be able to choose that DB_COLLATE setting in the wp-config.php file. For David, the DB_COLLATE setting that worked for Chinese/English was 'utf8_unicode-ci'.
  7. Download the zip file of WordPress fixes (if any) corresponding to your WordPress version from the downloads section, and install the files into the correct locations (as specified in the README.txt file contained in the fixes zip file).
  8. If specified in the downloads section for your version, also follow the database fix instructions.
  9. If you are upgrading, delete the obsolete files from your installation, as specified in the Upgrade guide.
  10. Upload the entire set of WordPress files to your server (see the Installation Guide for a description of where to put them).
  11. Run the install.php or upgrade.php file to complete the installation (as described in the installation/upgrade guide).

Installing and Setting Up the Language Switcher Plugin

The next step in creating your multi-lingual site is to install the Language Switcher plugin. After downloading the zip file from the downloads section, follow these steps to install, activate, and set it up:

  1. Upload langswitch.php (the main plugin file) into wp_content/plugins, in your WordPress installation. If you are using WordPress version 2.6 or later, and have changed the location of your wp_content directory, use that location instead, throughout the instructions below.
  2. Upload the flag icon files (*.png) into sub-directory "langswitch_flags" of wp-content/plugins, in your WordPress installation. You can add other flags, or substitute other image files, by putting them in this directory.
  3. If you want to localize Language Switcher so that the administration menus and the title of the language list widget (if you are using Widgets) are displayed in a language besides English, you can use the langswitch.pot file and your favorite localization software to translate Language Switcher. See the translating section for more information; your localization file(s) will need to be named "langswitch-ll.mo", where "ll" is the ISO code of the language you want to use, and they will need to go into sub-directory "langswitch_flags". Several localization files have been provided in the zip file, but they may not be complete or accurate (they came from other plugin users).
  4. Activate the plugin from your WordPress administration panel. If you need more detailed information on how to manage WordPress plugins, please visit the Managing Plugins page on the WordPress site.
  5. Enter information about the languages you want to use in your site on the Language Switcher options page.
    • To get to the page in the administration panel, click on "Options" or "Settings" in the top or side menu, and then "Language Switcher".
    • Type in the two-letter ISO code for your default language (the one someone will see when first visiting the page) at the top; a table of ISO codes is available at this Wikipedia site (be sure to use the two-letter codes from the first column). Note: If you cannot find an ISO code for your language, you can make one up. The Language Switcher does not care, as long as you use consistent 2-letter codes on the Options screen, when entering multilingual text (see the translating content section), and for the MO file names (see the translating static text section).
    • In the table below, enter information about all the languages you will use in your site, one language per line (including the default language). Fields:
      • ISO Code: The two-letter ISO code (or made-up 2-letter code) for the language; for example, "en" for English, and "es" for Spanish (do not type the quotes).
      • Language: The name of the language, in that language. For example, for English, type in "English", and for Spanish, type in "español" (without the quotes).
      • Flag File: The image file name for the flag you want to use for the language (from the langswitch_flags directory in the plugin distribution). For instance, for English, you could use "en.png" for the English flag, "us.png" for the American flag, etc. Enter the file name without the quotes and without the directory name.
      • Time Format: The format you would like to use for time of day for that language, using standard PHP time/date formatting codes found on this PHP documentation page. For instance, to display times in a format like "3:15 PM", you would type in "g:i A", and to use a 24-hour clock, you would use "G:i" (in both cases without the quotes).
      • Date Format: The format you would like to use for dates for that language, using standard PHP time/date formatting codes (see above). For instance, to display dates in a format like "25 Dec. 2008", you would type in "j M. Y"; to get something like "12/25/2008", you could use "m/d/Y"; and to have the day before the month, "d/m/Y" (in all cases without the quotes).
      • Text Missing Message: The message to display on the screen if an article has no translation for the requested language.
    • Click "Update Options" when you have entered all your language information.
    • If you want to change some information, enter the new information in the line with the ISO code you want to change, and click "Update Options".
    • If you want to delete a language, check the "Delete" box in that row and click "Update Options".
    • If you want to add additional languages, type in the information, starting at the first blank line, and click "Update Options".
    • If you want to enter more new languages than there are space for, enter as many as you can, click "Update Options", and then more blank lines will appear on the screen. Repeat until all your languages are entered.
  6. If you do not like the URLs the Language Switcher is producing, or they are not working for you, see the Frequently asked questions section for information on the URL-related options on this screen.

Installing Plugins and Themes

Installing a Theme

The next step in creating your multi-lingual site, unless you happen to like the default WordPress theme, is to find a theme, and install it. Themes can be found in the WordPress Theme Repository and other web sites. Important: Get an internationalized theme, if possible. If you cannot find an internationalized theme that you like, than get an English-language theme. Internationalizing a non-English theme is much more complex than internationalizing an English-language theme, and you will need to have an internationalized theme in order for its text to switch between languages using the Language Switcher. To install a theme:

  1. Download the theme from the repository, or anywhere you found it. It should come in a zip file.
  2. Unzip and upload the theme's distribution files into the WordPress "themes" directory on your site, which is under "wp-content" (unless you changed the content directory location, using WordPress 2.6 or later).
  3. Visit the WordPress administration page, click on "Presentation" or "Design" or "Appearance" (depending on your WordPress version), and activate your new theme by clicking on it.

Installing Other Plugins

The next step is to find and install other plugins; you can look for plugins in the WordPress Plugins List. Besides Language Switcher, which you should have already installed, you should install any other plugins you plan to use at this point. To install a plugin:

  1. Download the plugin from the plugin's home page (linked from the repository). It should either come in a zip file, or as a bare PHP script.
  2. Unzip and upload the plugin's distribution files into the WordPress "plugins" directory on your site, which is under "wp-content" (unless you changed the content directory location, using WordPress 2.6 or later). Follow the plugin's instructions -- some plugins go into sub-directories of the plugins directory, and some go directly into the plugins directory.
  3. Visit the WordPress administration page, click on "Plugins", and activate your new plugin.

The next page on this site is Theme and plugin modifications.


Questions, Comments, and Bugs

Jennifer Hodgdon, the owner of Poplar ProductivityWare and the author of the Language Switcher, would like to thank everyone who has sent in bug reports and suggestions about the Language Switcher. It would not work so well without your help! Language Switcher is based on Polyglot, by Martin Chlupac (the flags came from the Polyglot distribution), which was in turn based on Language Picker (which no longer exists).

The Language Switcher plugin is provided free, with no warrantee and no guarantee of service or support. And as of April 2010, further development on this plugin has been discontinued (please see note at the top of this page for more information).

Updates: 
April 2010 - Plugin author has stopped using/maintaining this plugin -- see note at top of page...
Version 1.21 - Bug fix for sorting tag clouds by name that affects WordPress 2.9 users only. Still works with older versions of WordPress.
Version 1.20 - Eliminated a cross-site scripting security vulnerability that could have affected some Internet Explorer users if they clicked on a malicious URL that led them to their own site and they were already logged in.
Version 1.19 - Updates for version 2.8 of WordPress (still works with older versions), and fix of a minor bug that might have caused some efficiency issues.
Version 1.18 - New feature: Better category/tag sorting (alphabetical in the current language, rather than alphabetical by the entire category/tag name field, which includes the language tags and multiple languages). Note that this new feature only works in WordPress 2.7 and above with the appropriate WordPress "fixes" file installed (see Downloads section). The plugin itself still works fine with older versions of WordPress -- you just won't have this new feature.
Version 1.17 - Bug fix: plugin wasn't always updating its URL rules when WordPress was updated. Bug fix related to multiple-page posts and their URLs. Updates for WordPress 2.7 (still works with previous versions). New option to force language suffixes on every URL, and some changes to the logic of when to put language suffixes on URLs if the new option is not used.
Version 1.16 - Updates for WordPress 2.6 (still works with previous versions). Add switch-language links to admin screens. Better efficiency in loading options. Post custom fields (meta-data) can now use language tags. Better default URL "slugs" for posts, categories, etc. New options to manage URLs
Version 1.15 - Fix for WordPress 2.5.x widget filtering (needs 2.5 updates installed from download)
Version 1.14 - Fix for WordPress 2.5.x tag filtering
Version 1.13 - Add trailing / to generated URLs, for fewer redirects.
Version 1.12 - Fix bug in URLs generated for page 2, page 3, etc.
Version 1.11 - Fix bug in comment dates in comment RSS feed. Update for compatibility to upcoming version 2.5 of WordPress.
Version 1.10 - New argument for HTML tag added to language list sidebar function. Updates for WordPress 2.3.1. Update to date/time behavior. Another bug fix on next page links. When outputting 'no text in this language' message, only do so if the original post had some text in it.
Version 1.09 - Updates so Language Switcher will work with WordPress 2.3 (still works with earlier versions). Another bug fix on nextpage links. Better logic on finding the user's preferred language (considers browser preferences and only accepts languages that exist in the settings). Fix bug that caused endless backslashes in options entry screen.
Version 1.08 - Another bug fix on nextpage tags and permalinks.
Version 1.07 - Numerous bug fixes, including printing message when title has no text in user's preferred language, setting language correctly in RSS feeds, better permalink behavior, and getting the nextpage tag to work in articles. Also made the language list sidebar function into a Widget, for WordPress 2.2 and above (note that you will need an updated widgets.php file from the fixes zip file to get the Recent Comments Widget to work correctly).
Version 1.06 - Internal release only
Version 1.05 - Bug fixes for static home page links, and for the situation where the post has no information in the user's preferred language.
Version 1.04 - Bug fix for trackback/feed links.
Version 1.03 - Bug fix for language permalink on home page for some users.
Version 1.02 - Bug fix for comment dates/times.
Version 1.01 - Slight changes to syntax of the language listing functions. Added permalink support.
Version 1.0 - Limited initial release.

Comentarios

About Language Switcher

Hi Jennifer,

I'm @laskov on twitter ;). I accidentally saw your suggestion that I should take over maintenance of the LS plug-in.That's exactly what I am doing, at least for my personal use. My version is heavily tweaked, because I want to filter out untranslated posts; I also made some changes in the function that prints the list of languages.

However, right now I don't have the time to release an official plug-in. Maybe I will do that in the future, so it's good to know you give me the green light.

I was utterly unhappy when I learned you're not supporting it any longer. It's a great plug-in.

Yeah, sorry...

I'm really just not doing much work at all with WordPress these days, and have migrated almost all of my personal and work site(s) to Drupal. So it makes no professional sense for me to keep supporting it, and I'm not using it personally either. As I'm sure you know, it does take quite a bit of time to maintain and support a WordPress plugin, and the rewards are mostly intangible (the occasional person saying Thanks).

Good luck, anyway!
--Jennifer

Um, thanks. Will you continue

Um, thanks.

Will you continue supporting the plugin?

Haha jk!

No

I dropped support for this plugin quite a while ago and I'm not using it myself any more, so... sorry, but no.

How to put it on any part of the website instead of a widget?

I want to place the language list on my header instead of displaying it on the sidebar widget?
What code will I put in?

There are instructions

http://poplarware.com/downloads/language_switcher_mods has instructions, right at the top of the page. Please read them, and it should be pretty clear.

blog down after installation

I installed as instructed and get everywhere this on the page:

"Fatal error: Cannot redeclare get_category_children() (previously declared in /home/a3371422/public_html/wp-includes/category-template.php:20) in /home/a3371422/public_html/wp-includes/deprecated.php on line 1319"

I use arras-theme, maybe too complicated for this lugin?

Unsure...

I haven't tried using the Language Switcher on the latest WordPress [see note at top of the page] and I'm not supporting the plugin any more, so I'm not sure if it works with WordPress 3.x.

However, looking at your error, it definitely looks like you are having some other conflict, like maybe you upgraded from a previous version without removing all the old WordPress files? Because there should not be a conflict between wp-includes/category-template.php and wp-includes/deprecated.php -- both of those are internal WordPress files (i.e., not from Language Switcher or your theme).

Good luck...
-- Jennifer

It works

I have 3.0.4 with you plugin and it works perfectly. Pitty that it's no longer maintained.

Good to know...

There's someone I've been in correspondence with who's offered to take over maintaining the Language Switcher, but so far he hasn't come back saying he's ready to do it. Hopefully he will soon! Anyway, it's good to know it still works with WordPress 3.0.x.

Hi Jennifer,I'm @l

Hi Jennifer,
I'm @laskov on twitter ;). I accidentally saw your suggestion that I should take over maintenance of the LS plug-in.That's exactly what I am doing, at least for my personal use. My version is heavily tweaked, because I want to filter out untranslated posts; I also made some changes in the function that prints the list of languages.
However, right now I don't have the time to release an official plug-in. Maybe I will do that in the future, so it's good to know you give me the green light.
I was utterly unhappy when I learned you're not supporting it any longer. It's a great plug-in.
_________
starlas eymour from expresso pas cher

You or someone else?

I don't think it was you -- the person I was talking to had emailed a while back and offered to take over maintenance, and then after a short exchange stopped corresponding. :( Anyway, the plugin is open-source, so anyone can take it and do with it what they like. I am hoping that someone takes over maintaining a general-purpose version of it sometime, since people seem to want to try to make WordPress be multi-lingual (against its wishes, I would say -- which is why I have stopped supporting the plugin and switched to Drupal, which has much cleaner multi-lingual support, although still not perfect in every way).

Anyway, good luck!

compatibility with wordpress 3.0.4

Hi,

I took the risk of updating to 3.0.4. The plugin still works, but somehow parts of website are shown in Italics in the English-mode. Weird. But i might be able to figure out what is wrong. I ll keep you posted.

tim

HTML validation

That is a bit odd. It sounds like it could be some kind of HTML validation error, especially if it is only on certain pages. You might just verify that the posts/pages in question have no HTML validation problems, such as
<em>some emphasized text[/lang_en]</em>
which would leave an open EM (emphasis = italics) tag on your page in English mode.

OH...

WordPress 3.0.4 contained a security fix for some of the text functions in WordPress. I think that the Language Switcher could be using a function that has been changed, so that it is no longer automatically closing the HTML tags that are left open by errors such as the one I just mentioned in the reply above. Maybe that is the problem? I'm not using Language Switcher myself any more (see note at top of page -- I switched to Drupal), so I can't really test. I need to email that guy that wanted to take over support of the Language Switcher and see how he's doing....

Upgrade to WP 3.xx

I love this plugin and it is working so far on the website I just finished http://www.belairmedia.com
I just have this problem that categories are not displayed correctly ([lang_fr]cat[lang/fr]). I think I have seen a fix on your site, but I don't remember where. I'll lurk for it.
Thanks for your work anyway.
Axel

Good luck!

As you'll see at the top of this web page, I have stopped working on or supporting this plugin... but I think it should work with WP 3.x. The categegories functionality in WP has not changed much. It could be a problem with how your theme is displaying categories though -- you might read the section on how to modify your theme.

Good luck, or should I say bon chance? :)
---Jennifer

DIFERENTES IDIOMAS PARA WORDPRESS

Mi pregunta es se podria hacer asi de facil como drupal que instalas el modulo de Internationalitation y configuras y tu mismo puedes cambiar el idiomas asi trabaja este plugin espero que alguien me pudiera decir como funciona o si funciona asi

gracias

Depende...

El modulo Internationalization de Drupal es facil, y en este momento, no hay nadie que desarrolla a este plugin Language Switcher. Entonces mi recomendacion seria usar Drupal.
--Jennifer

swiching from ltr to rtl

good work, but I m trying to switch from french to arabic(RTL text direction ) i have translated my theme. evrey thing works but I wont tou change text direction(to RTL in arabic). haw can I change to text direction cane I use this:
$wp_locale= new WP_Locale;
$wp_locale->text_direction="rtl";
if the lang is 'ar'

Not sure...

I have never tried Arabic, or any other RTL language, sorry! As this plugin is no longer supported (see note at the top of this page), you will need to try to get help on the WordPress support forums... good luck!
-- Jennifer

Checking before I try it out

Here's what I want to do. Can this plugin do it?

I will provide the translation for the theme and content. There are several bits of text and graphics in the theme that need to be different depending on the language. I want the user to be able to switch between languages easily and then have only the posts/pages for their language show up using the various theme elements for their language.

Am I in the right place?

Probably not...

As noted at the top of this page, the Language Switcher plugin is no longer maintained by me. I do not know if it works with the current version of WordPress, and the person who contacted me to take over the plugin has not stayed in contact. So, using this plugin could leave you with a blog that only partially works, especially as time goes on and WordPress changes from the last version when I was supporting this plugin. Use at your own risk!

Also, it doesn't work quite as you are hoping. The theme modifications can be done as you are hoping, but the posts don't work quite as you suggested. Each post/page contains the translations for all the languages, rather than having some posts marked as one language and others marked as another language.

Good luck with your site...
--Jennifer

Upgrading to 3.2

Anybody upgrade to WP 3.2 yet? An problems with this plugin?

works

In version 3 it works for me. Thanks.

Plugin not working for homepage

Hello! I have a wordpress theme where i installed the plugin and it works great! Only that there is this homepage where from the administration panel (THIS THEME'S FEATURE) you write your WELCOME MESSAGE to be displayed on the homepage. In here, the [lang_en] .... [/lang_en] (for example) does not work any more. Any suggestions?? Please help. Thank you

Read the doc...

Two things:
a) This plugin is not being maintained - see note at the top of this page. Sorry!
b) There is documentation on this site about how to modify your theme or other plugins to work with the Language Switcher, so you can follow those directions and probably get this theme to work (assuming that the Language Switcher is working for you -- I haven't tested it for several versions of WordPress, so I don't know if it is still compatible).

Good luck!

New plug-in for multilingual WordPress blogs

Hello,

few days ago I've wrote an article about a new plug-in for multilingual WordPress blogs if someone is interested:
The Solution for Multilingual Blogs in WordPress

I think that's a great new solution that I'm currently using myself.
Andreas

Actually you no need to use plugin ...

Actually you no need to use plugin ...

You can add as widget like this.

http://www.justin.my/2012/01/how-to-add-languagetranslate-to-wordpress-w...

Not the same thing...

Your sidebar widget uses automatic translation to translate your blog. This (no longer supported) plugin allows you to translate your own posts and pages into multiple languages, which is not the same thing as automatic translation. They serve different purposes.