How to make WordPress multilingual

We were recently asked to create the possibility for adding more languages to an existing WordPress site, which already contained quite a few plugins and custom theme modifications. We started by looking at free multilingual plugins, and especially noticed the popularity of qTranslateX and Polylang, besides WPML which comes with a fee.

Around the globe

 

Plugins to add more languages to a WordPress site

After reading reviews and comparisons of the plugins, we decided to start by testing qTranslate X and Polylang, especially after hearing how the relatively expensive WPML plugin slows down sites quite a bit

The main differences we noticed between qTranslate X and Polylang were that the first kept translations on the same page, while Polylang basically lets you create a new page, post or category for each new language and connects the new content with a translated version. Both were easy enough to install and to create the initial setup.

The site we worked on included multiple custom fields, and we soon noticed that qTranslate didn’t give the option of translating those (especially the ones created with Advanced Custom Fields). This was also the case for plugin settings such as SEO fields, meaning we would have some parts showing in the original language if using qTranslate, including for example in search results and parts of the main menu which had not yet been translated. Besides that, qTranslate added language codes to all existing posts and pages, which would make it tricky to uninstall the plugin. We did however like a few features, so might give it another try if on a less complex site.

When it comes to Polylang, you get an extra section on the post editing page, which gives an overview of which languages the page, post or category has been translated to. This lets you easily switch to a translated version, or create a new one when there is none. In the end, we decided to use Polylang for multilingual support, since it fulfilled our needs, which you can read more about below

Below are the steps to go through for internationalizing an existing website with Polylang. You can probably skip some, depending on your needs - some of the steps are quite technical in nature, but in most cases you can probably skip those,

Testing and preparing your theme for multilingual support

If you already have a site with a theme you would like to keep, the first step is to check your theme for language support. Multilingual support will probably be mentioned where you downloaded the theme - and if you notice it there you can skip reading until below the next image. If you however can't find anything about laguage support on the theme site, the quickest way to do this is probably to check if the theme has a folder called “languages”, which contains files with endings .mo and .po, named by their locale, meaning for example ‘es_ES’ (Spanish in Spain) or ‘en_US’, or by language codes such as ‘es’ or ‘en’.

In case there is no ‘languages’ folder, you might still find yourself lucky, finding that the theme is partially prepared for internationalization, but not translated. You would notice this in the template files (e.g. header.php or content.php in your theme folder) wherever translatable content is found – just look for text strings encapsulated in _e() or __() when you open the files in a text editor such as Textpad, Notepad++ or even good old Notepad. In our case, the theme was completely custom made and not updatable through WordPress, so we the theme ourselves, then extracted all strings and created a .po file from there (which can be done at for example ICanLocalize if you make a zip file of your theme folder). If you have a downloaded theme, you would probably be better off creating a child theme where you override the parts you need to be translatable - your friendly developer can probably help with that.

If you find the mentioned language folder, but it doesn't have your language, you can translate with a program called Poedit, which takes all the strings from your theme and lets you translate them one by one, using the {your_theme_name}.po file as a base. Then add the new translation files to the languages folder (and perhaps be nice and share the translations with the theme author if you have a downloaded public theme).

Create a multilingual site

Installation, setup and adding languages

After downloading and activating Polylang, you need to take a few initial steps to add your desired languages to the website.

  1. Adding a language is usually as simple as going to Settings -> Languages, selecting the language from the dropdown and clicking the button “Add new language”. We recommend that you start with the main language of the site, which will simplify the third step if you already have content in one language. As a note, the Language Code in these settings will be used both in your URL:s (if using the directory or subdomain setting) and in the hreflang meta tags (which tell search engines when you have multiple translated versions of the same page).
  2. To translate various smaller texts across the site, such as in widgets or the site title, visit the String Translation tab.
  3. Before leaving the Language settings, remember to select Default language, and select the checkbox saying you want all old content to be seen as having the default language – without a language setting they might not show up. We set our new languages to be set from a directory name in the permalinks and hide language for the default language, which let us keep our old URL structure.

 

Translating your content

Finally, your initial setup should be complete, and you can start translating. However, we’d recommend starting by translating any categories and tags you have – especially the ones you plan to use for the new languages. This might also be a good time to clean up old and unused tags and categories, to simplify the user interface when writing posts.

  1. Go to Posts -> Categories (or Tags), double check that all current categories have a check mark in the column for your default language – otherwise go back to the language settings to apply the language.
  2. Click the plus sign for the category and language you want to translate. This reloads the page and then lets you fill in the new category information on the left, where you usually create a new one. You’ll notice that your original category name is shown under Translations, and Language is set to the one you selected.
  3. Once you have saved, you’ll notice the translated category in the list, and there’s a pen where you clicked the plus sign before, to let you edit the translated category. If you only want to see categories, posts and pages from one language, you can select the language in the admin bar, where it says Show all languages.
  4. Repeat the process for tags, posts and pages – the process is basically the same as usual, and quite easy to understand, but if you have any questions feel free to ask in the comment (or go to the plugin page and ask in the support forums).
  5. One thing to remember is that the page and post editing pages might be synchronized across languages depending on what you selected in the language settings. This might give unwanted effects if you for example want different custom fields or featured image depending on language – if possible, try it out on a copy of the website before you apply any such settings to your live site.
  6. After translating your key pages and categories, you need to create or select a menu for each language. Simply go to Appearances -> Menus and the tab Manage Locations. From there you can either select a menu for a language from the dropdowns or click Use new menu to create a new one.

 

Customize for each language

Customizing the look and feel

You might have widgets or other features which have been cuswtomized for one language. Polylang has great documentation if you want to make certain parts of your theme unavailable in some language versions, for example if your home page template has special content to show in your main language but hidden for others - in our case there was a quiz in English which didn't need translation, so we set the template to only load that section for the English version of the page. When it comes to widgets, you can go to Appearance -> Widgets and follow these simple steps:

  1. Open the settings editor for the widget you want to keep as exclusive to one language. At the bottom of the settings you’ll see a new dropdown to show the widget for all or only specific languages, where the default is "all languages". Besides the possibilty to hide widgets, this also means you can have a different set of widgets in the same area for each language. For widgets which are just text based, you can go back to the String Translations in the language settings to check if it has been translated.
  2. Polylang comes with a widget which can be displayed to let visitors switch language, and you can also add language switching to your menu. Besides that, the plugin has functions to help handling a number of scenarios, which can be used in themes to customize and enhance parts of your website for one or multiple language. If that's not good enough, it's also possible for a developer to create a custom widget or language switching feature.
  3. If you have plugins such as Advanced Custom Fields or Dynamic Widgets, where you specify a specific category, post or page for the feature, you will probably need to add the newly translated page versions in the settings for that plugin. This is most often handled the same as usual for the specific plugin, so we won’t cover it here.

 

Things to note

There might be some minor conflicts when Polylang or another multilingual plugin is combined with other plugins in your setup, especially when it comes to ones handling permalinks. In our case there was an old plugin for custom permalinks, one for shortlinks, an SEO plugin plus custom theme code creating havoc for the site before we managed to create the right settings and adjust the theme code to make it work with Polylang. In case of plugin conflicts, the best option is often to contact plugin developers and ask for help, or possibly an update of their plugin - most WordPress won't have as many plugins altering permalink structure as in our case, meaning in most cases you probably won't have any conflicts.

Written 2015-10-09 (Updated 2016-10-10)
emil.hunefalk 150x150 140x1401

Written by Emil Hunefalk


Emil has been a blogger and web developer since the late 1990's. He has web, mobile and desktop experience from both large and small projects, in some cases handling everything from user experience to development.

Share your thoughts

Emil,  20 October, 2015

Hi David, thanks for the tip about POEditor, it looks like a really interesting option, and I haven't noticed the WP plugin before. However, from what I can see, it does more or less the same as the POEdit software, which in our case was used to translate language files for themes and plugins, but not pages, posts and categories - and we would also have missed the option to customize pages depending on language (e.g. showing or hiding a page section for specific languages). It could probably be used together with for example Polylang or WPML though, to handle the parts where those come short.

David,  14 October, 2015

Hi Emil! Thanks for sharing this "how to" article. I think a better way to internationalize a WordPress blog is using a software localization management platform, as it was mentioned above. My recommendation is to have a look at https://poeditor.com/ that has a simple and intuitive user interface, making the localization process easier and smoother for anyone. It includes a WordPress plugin https://wordpress.org/plugins/poeditor/ to easily manage the translations via the POEditor API. Cheers!

Show all related articles..

Best Value Hosting 2016


Why wait? Get today's best deals now!