Multilingual WordPress Websites with Polylang

Share this article

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 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.

Frequently Asked Questions (FAQs) about Multilingual WordPress Websites with Polylang

How can I translate custom strings in Polylang?

Translating custom strings in Polylang is a straightforward process. First, you need to register your strings using the pll_register_string function. This function allows you to make your strings translatable. After registering your strings, you can translate them using the Strings translations table found under the Languages menu in your WordPress dashboard. Remember to save your changes after translating your strings.

Why is pll_translate_string returning only the default language’s string translation?

The pll_translate_string function returns the translation of a string in the current language. If it’s returning only the default language’s string translation, it could be because the current language hasn’t been properly set. Make sure you’ve set the current language correctly in your Polylang settings. If the problem persists, it could be due to a conflict with another plugin or theme. Try deactivating other plugins or switching to a default theme to see if the issue is resolved.

How do I use the function reference in Polylang?

The function reference in Polylang is a list of functions provided by the plugin that you can use in your code. Each function is documented with its description, parameters, and return values. To use a function, simply include it in your code where necessary. For example, to get the current language, you can use the pll_current_language function like this: echo pll_current_language();.

How do I install and activate the Polylang plugin?

To install the Polylang plugin, go to your WordPress dashboard, navigate to Plugins > Add New, search for Polylang, and click Install Now. After the plugin is installed, click Activate to start using it. Once activated, you can access Polylang’s settings under the Languages menu in your dashboard.

How do I add a new language in Polylang?

To add a new language in Polylang, go to your WordPress dashboard, navigate to Languages > Add New, fill in the necessary details such as the language name, ISO code, and flag, and click Add New Language. The new language will then be available for you to use in your posts, pages, and widgets.

How do I translate a post or page in Polylang?

To translate a post or page in Polylang, edit the post or page you want to translate, click on the plus icon next to the language you want to translate to under the Languages box, and enter your translation in the editor. Once you’re done, click Publish or Update to save your translation.

How do I display a language switcher in Polylang?

To display a language switcher in Polylang, go to your WordPress dashboard, navigate to Appearance > Widgets, drag the Language Switcher widget to your desired widget area, and configure the widget settings as needed. The language switcher will then be displayed on your site, allowing your visitors to switch between languages.

How do I translate a menu in Polylang?

To translate a menu in Polylang, go to your WordPress dashboard, navigate to Appearance > Menus, select the menu you want to translate, click on the plus icon next to the language you want to translate to, and enter your translations for the menu items. Once you’re done, click Save Menu to save your translations.

How do I translate a widget in Polylang?

To translate a widget in Polylang, go to your WordPress dashboard, navigate to Appearance > Widgets, select the widget you want to translate, click on the plus icon next to the language you want to translate to, and enter your translations in the widget settings. Once you’re done, click Save to save your translations.

How do I handle SEO for multilingual sites in Polylang?

Handling SEO for multilingual sites in Polylang involves setting up hreflang tags, translating your metadata, and creating a multilingual XML sitemap. Polylang automatically adds hreflang tags to your pages, but you’ll need to translate your metadata manually using an SEO plugin like Yoast SEO. To create a multilingual XML sitemap, you can use a plugin like Google XML Sitemaps.

Jérémy HeleineJérémy Heleine
View Author

Currently a math student, Jérémy is a passionate guy who is interested in many fields, particularly in the high tech world for which he covers the news everyday on some blogs, and web development which takes much of his free time. He loves learning new things and sharing his knowledge with others.

Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week
Loading form