Language Switcher WordPress Plugin
Note: A German translation of this page is now available -- thanks, Angi!
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.
To see the Language Switcher in action, visit HodgBlog, the plugin author's personal, bilingual blog. In the side bar, or just under a post title, click the Spanish language link, and you should see most of the text on the screen change to Spanish.
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!
Contents of the Language Switcher Plugin Site:
- Language Switcher home page (this page):
- Introduction to the plugin (above)
- Installing or upgrading blog software
- Installing and setting up the Language Switcher plugin
- Installing plugins and themes
- Theme and plugin modifications:
- Translating:
- Translating database-stored text (including posts, pages, categories, tags, etc.)
- Translating static text (text hard-wired into WordPress, plugins, or themes)
- Testing, Questions, and Answers:
- Downloads:
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.
- 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.
- 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.
- Unzip the file onto your personal computer.
- 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.
- Modify the configuration file (as described in the Installation guide -- if you are upgrading, you can download your previous configuration file from your site).
- 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');
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'.
define('DB_COLLATE', ''); - 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).
- If specified in the downloads section for your version, also follow the database fix instructions.
- If you are upgrading, delete the obsolete files from your installation, as specified in the Upgrade guide.
- Upload the entire set of WordPress files to your server (see the Installation Guide for a description of where to put them).
- 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:
- 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.
- 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.
- 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).
- 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.
- 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.
- 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:
- Download the theme from the repository, or anywhere you found it. It should come in a zip file.
- 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).
- 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:
- 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.
- 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.
- Visit the WordPress administration page, click on "Plugins", and activate your new plugin.
If you are using WordPress 2.3, and wish to put multi-lingual tags on your posts using the built-in WordPress tagging functionality, I recommend that you get the Advanced Tag Entry plugin. The built-in tag entry field in WordPress 2.3 is inadequate for multi-lingual tags, because you cannot define tag "slugs" (which are used in tag URLs). However, in WordPress 2.5 and later versions, there is a Tag Management screen you can use to define tags with slugs.
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. However, Poplar ProductivityWare welcomes your comments. So if you have questions about how to install or use the plugin, suggestions for how to make it better, or wish to report a bug in the plugin, please contact Poplar ProductivityWare. Jennifer would really appreciate it if you would carefully re-read the appropriate sections of documentation before contacting her. Thanks!
Poplar ProductivityWare: your Seattle-area source for web databases, web programming, Drupal modules and sites, and WordPress plugins
Home | Services | Experience | Articles | Downloads | News | About | Contact UsPoplar ProductivityWare® is a trademark registered in the U.S. Patent and Trademark Office
Copyright (C) 2003-2009 Poplar ProductivityWare LLC