Multilingual WordPress Websites with Polylang

By Jérémy Heleine

WordPress is available in a lot of different languages. However, when you switch to another language in the “General Settings” panel, by default, you can’t use several languages at the same time.

Sometimes, being able to use several languages is what we’re after. I can illustrate this assertion with my own example: my blog is available in two languages (English and French). If you prefer the French language, you can switch to it without any problem, I don’t need to switch the entire website language preferences.

By default, it’s not possible to do this in WordPress, but there are plugins that can help you achieve this goal. In this article I’ll introduce you to an entirely free and complete plugin called Polylang. We’ll look at how to install it, how to configure it and, above all, how to use it to translate the entire website (not only the posts!).

Managing Several Languages on WordPress

Why Use Polylang?

Depending on exactly what you want to do, the default WordPress tools can be enough. For example, you can create a post in a given language, and create the same post in another language, attributing the right tag to differentiate it. It’s just an example, but if you want to keep the things simple, you can do that.

Multilingual WordPress Polylang

However, this isn’t a complete solution. The advantage of using Polylang is that the plugin won’t just let you translate your posts. In fact, if your theme is translated in the right language, your visitors will see an entire translated website. Using my example, when you read a French post on my blog, you’ll see a translated sidebar and footer.

Polylang is a powerful tool that helps you create a multi-language website. Once you’ve configured it, using Polylang to translate your posts is as easy as the example we saw above. Maybe even easier!

Installing Polylang

You can download the Polylang plugin for free via WordPress.org. It can be installed and activated like any other plugin.

Installing Polylang

Managing the Available Languages

Polylang has its own options panel, accessible from the “Languages” entry in the “Settings” menu of your administration panel. We’ll look at the first tab of this panel to start with, “Languages”. As the name suggests, it lets you manage the languages you want to use on your website.

To add a new language, the simplest way is by using the dropdown list labeled “Choose a language”. There are dozens of available languages by default and chances are that you’ll find the one you want. If you can’t, you can still use it by creating your own (its name, locale, code and direction).

You can also choose the order in which your languages must appear in the list. The “Order” text input excepts a number. Languages will be sorted using this number, in ascending order.

Once a language has been added, you can edit its information. These options can be seen by hovering over the language in the list.

Configuring Polylang

By visiting the “Settings” tab in the Polylang options panel, you’ll find some useful options to personalize your multi-language experience.

The first option, and probably the most important one, is the default language you want for your website. It can be any language you’ve added. If you have visitors using a language you don’t support, they’ll see this default language.

If your website is not a new one, chances are great that you already have some published posts. Since you’ve installed Polylang after creating them, existing posts won’t have a language set. You can give them all the default language setting from this tab.

In this tab you’ll also find a few more options you’ll want to check, in particular your URL preference.

A Fully Translated Website

Theme Translation

As mentioned above, Polylang goes further than only translating our posts. Our visitors can have an entire experience in their preferred language.

To do this, you’ll need a translated theme. If the theme you use is translation-ready, you should find in it (probably in a subfolder like languages) a POT file. This file contains all the strings used in the theme. That way you can translate them into all the languages you want.

Now, when Polylang displays the right language on your website, it won’t only display the posts in this language, but also the theme. That way, your visitors won’t see French text in an English page for example.

Note that if you use a WordPress default theme, like Twenty Fifteen, when you add a new language in Polylang, it tries to download and install the translations of this theme in this language.

Dynamic String Translation

We can’t translate everyhting with a simple POT file. For example, widgets’ titles are strings that are created by the user (you), so naturally we can’t use a POT file to translate these. However, there’s another way to translate them thanks to Polylang.

Go in the second tab of Polylang options panel. This tab is called “Strings Translation” and contains various strings that are display on your website. By default, Polylang generates several dynamic strings. You’ll find strings such as site name and description, you can even translate time formats.

Polylang will also retrieve all the widgets you are using. Their titles and content (for the Text widget for example) can then be translated with dynamic strings. It’s worth noting that when you create a widget when Polylang is active, you can now select a language in the widget setting.

In the “Strings Translation” tab, Polylang lists all the registered dynamic strings, in their original language. You can then translate them into the languages you use. Not only your theme can be translated, but also your dynamic content.

Registering Our Own Dynamic Strings

If you’re developing a theme or a plugin, you can make it “Polylang-ready” by registering your own dynamic strings. For example, it can be useful if you need to display a string users can define by themselves. By registering these strings, these same users will be able to provide them into several languages.

To register a string, use the pll_register_string() function. As with any other function defined by another plugin, you should check if this function exists with the following test:

if (function_exists('pll_register_string')) {
    // The function exists, do whatever you want!

Even if Polylang is installed and activated, this function can be missing. For example, it’s possible to try to call it too soon, before it is created. To ensure that you don’t call it too soon, be sure to call it after the action “plugins_loaded” occurs. For example, this is the case if you register your strings directly in the functions.php file of your theme.

Now that we’ve seen how to call this function, it’s time to see its parameters. This function excepts four parameters, but the last two are optional.

The first parameter is the name of the string. This name is a way to describe it. Refer to your current “Strings Translation” tab for examples of its use. For instance, a string like “l, F j, Y” is not always clear, but with the name “Date Format”, it is.

The second required parameter is the string to translate. You can write this in any language you want, but try to be consistent with the rest of your theme or plugin.

pll_register_string('My awesome string', 'This is a translated string.');

The third parameter represents the group in which your string must be placed. By default, this group is named “polylang” but you can define your own group, by indicating your theme’s name for example. Group names can be seen by your users in the registered strings list. It’s another way for your users to better understand where your string is displayed (if several plugins use Polylang, your users will thank you for indicating that a string is for your plugin and not for another).

The last parameter won’t be useful for everyone, but it might be for some. It’s a boolean set to false by default. If you set if to true, then Polylang will provide a multiline textarea to let the user translating the string, instead of a one line text input.

Retrieving Registered Strings

Once your strings are registered, your users can translate them in the “Strings Translation” tab. But you still need a way to retrieve them, in order to display the right translation!

There are essentially two functions you can use for that. The first one is pll__() (note the two underscores for the __() WordPress function). You give it the string to translate, and it returns the same string, translated into the current language.

$translated_string = pll__('This is a translated string.');

If you don’t want to do anything with this translated string (like injecting it in a function like sprintf() for example), you can directly echo it with pll_e().

pll_e('This is a translated string.');

You can also use a third function: pll_translate_string(). This last one excepts two parameters: the string to translate and the language in which you want the translation. This can be useful if you want to display text like “View this post in [any language]” in the targeted language, for example.

echo pll_translate_string('View this post in French', 'fr');

Posts Translation

Translating a Post

Now that you’ve set up Polylang, all your existing posts should be in the default language. That means they won’t appear in other languages.

In the posts list, you’ll find new columns representing the translation state in every added language. If a “plus” is shown in a post line, that means that the corresponding translation doesn’t exist. You can add a translation by clicking on this “plus”.

There’s nothing else we need to after this point. You write your translation like any other post and that’s it! Do you have another word for this other than “awesome”?

Note that you can also add a translation to a post when you are editing it. Polylang has its own box in the editor, listing the existing translations for the current post. From this list, you can edit existing translations and add others.

Translating Categories and Tags

So far, we’ve translated our theme, widgets and posts, but there are still a few things we haven’t covered: taxonomies like categories and tags. We can translate these, by visiting the “Categories” or “Tags” page of your administration panel. You’ll be able to translate them exactly the same as we did for posts.

Once your categories and tags are translated, you can use them in your posts translations. However, there is a last Polylang option I want to share with you here: the synchronization between translations.

In the “Settings” tab, at the end of the page, you’ll find some checkboxes. By checking some of them, you can activate the synchronization of the corresponding element between all the translations of your posts.

For example, assume that you have a category named “My category”, translated in French by “Ma catégorie”. You’ll write a post in this category, in English, and you want to translate it in French. In this translation, don’t indicate any category: if you’ve activated the taxonomies synchronization, then the “Ma catégorie” category will be automatically selected!

Conquer the World!

In this article I’ve described most of the main options that I find useful in Polylang, but there are others that you’ll surely want to check out. Don’t hesitate to test Polylang in a local installation, and test some of the variations before using this plugin on your production website.

If you want to know more about the options, functions and filters provided by Polylang, you can visit the official Polylang documentation, which is very complete.

  • Rajiv Sathian

    Hi Jeremy,
    Thanks for the post Jeremy.
    I was in search of such a solution and thanks for bringing this solution and its working to my notice certainly I shall give it a try.

  • http://www.techno-proo.com/ Techno-Proo.com

    thanks for the tutorial, just a question, i’m using this plugin developing a multilingual website, i need an option or a code to change the sidebar position, like if the website is in english the sidebar will be in the right, and if the user changes the language of the website in’ll also change and be in the left side, i’ve done all the work with posts, pages, categories, logo and header … but this is holdig me back, so i need some help to finish.

    thank you.

  • http://wpdean.com/ WPDean.com

    Thank you! I will test the Polylang plugin. I have been using older ones that have some issues in the new WordPress projects, so this post is very nice.

  • pojo.me

    Great post. I would like to know about integration of Polylang with plugins like Woocommerce.

    • http://tassedecafe.org Jérémy Heleine

      I didn’t tested with Woocommerce, but a fast search led me to some plugins dedicated to the integration of Polylang into Woocomerce so it appears that, maybe, it’s not so easy to translate Woocommerce with Polylang. By default only, as the good news is that we find plugins that do it for us.

  • Emily Juice

    Polylang is great plugin and Easy to use.

  • Emily Juice

    Polylang is great plugin and Easy to use.

  • http://dzshowstv.com/ dzs-tv

    Thank you i’ll dowload Polylang and test it, i was looking for a plugin like this :) this is a nice share thanks a lot

  • Ye Lu

    I want to delete an added language.How to do it?



Learn Coding Online
Learn Web Development

Start learning web development and design for free with SitePoint Premium!

Instant Website Review

Use Woorank to analyze and optimize your website to improve your website to improve your ranking!

Run a review to see how your site can improve across 70+ metrics!

Get the latest in WordPress, once a week, for free.