WordPress as a Multilingual CMS Using WPML

WPML Plugin MenuI’ve been working on a site that requires both English and Spanish content. The user interface elements, such as the primary navigation, copyright statement, and form labels, need to be bilingual as well. The client needs the ability to update all of the content (and write new blog entries) themselves, so early on I decided to use WordPress. I’d read that WordPress can handle multilingual sites, but I wasn’t clear on how that worked exactly. Also, I don’t speak Spanish – which means I can’t provide my own translations – so I needed a solution for that as well. I considered using something like Google’s Language Tools for little things like labels, but I’ve always been suspicious about whether I’m using the preferred form of translated bits of text like “Search” and “Older Entries” and many others.

After much research and a few hours of experimentation, I decided to use a WordPress plugin called WPML by OnTheGoSystems, a small digital photography software development group located in Las Vegas. I was immediately impressed with the amount of documentation that’s available for WPML (which I believe simply stands for “WordPress Multilingual”). I especially like the Roadmap, Getting Started Guide, and a nice argument for using WordPress as a CMS.

After installing the plugin, I set English as the default language and added Spanish as an alternate. WPML can handle multiple languages on a single site (thus the name). The WPML site itself is available in several languages: English, Chinese, German, Japanese, and Spanish – all selectable from any page on the entire site. Did I mention I was impressed? After setting the site’s languages, I set how they would be displayed: 1) different languages in directories (http://domain.com/ – English, http://domain.com/es/ – Spanish), 2) a different domain per language, or 3) a language name added as a parameter (http://domain.com?lang=es – Spanish). In order to provide the site visitor a mechanism for choosing a language, a dropdown language switcher can be added with a single line of PHP code, inserted into the WordPress theme (<?php do_action(‘icl_language_selector’); ?>). The language switcher can be customized using the Custom Language Switcher Guide.

The next step was perhaps the most interesting for me. It involves localizing the WordPress theme. In other words, all the strings of text, such as all the labels for the comment form, need to be translated and made available for WordPress (and the WPML plugin) to display dynamically upon request by the language switcher. This task involves several parts: 1) collecting the texts to be translated, 2) translating the texts, and 3) making the texts available to WordPress. That second part, translating the texts, involves creating a .po (or “Portable Object”) file for each translated language. Each string of text gets paired with its corresponding translation. Additional information is available on the WordPress Theme Localization page.This multilingual site has been a wonderful project so far. Hopefully I can make it available soon for everyone to see. I’d definitely be interested in working on additional multilingual projects in the future.

Be sure to check out the WPML Blog for additional items of interest as well as news updates.