Translating a WordPress theme is essential for creating a fully multilingual site. Whether you’re a web agency, developer, or business owner, comprehending translating a WordPress theme is vital for reaching and captivating an international audience.
However, translating themes presents challenges such as maintaining consistency, handling dynamic content, symmetrical layouts, and addressing cultural nuances. Sometimes, specific text strings may not even appear in the translation file! On top of that, technical complexities arise from the diverse structures and functionalities of themes available on the market. Achieving smooth translation requires careful attention to detail and expertise in both language and coding. Luckily there are some efficient tools on the market like Loco Translate or Polylang that can do the heavy lifting for you!
This guide provides a detailed, step-by-step method for translating your WordPress theme. We’ll explore using WordPress plugins like Loco Translate and Polylang, or manual translation with Poedit, to use WordPress’s internationalization and localization features effectively.
-
Ensuring Your WordPress Theme is Translation-Ready
The initial step is to begin with translation-ready themes. Select WordPress themes specifically designed for easy translation, thereby streamlining the entire process for greater efficiency and smoothness.
What Does Translation-Ready Mean for a WordPress Theme
In plain English, it means that developers have prepared the theme for translation by consolidating all text strings into a single language file: a POT file.
Translation-ready themes have been appropriately internationalized, indicating that the text within the theme isn’t hard coded but can be interchanged based on a translation file. The developers gathered all the strings of the theme in a format that’s easy to read and translate into individual PO files.
What is The Difference Between POT, PO, and MO Files?
- POT (portable object template)files: pot files are templates that contain source text prepared by the developer but no translations.
- Portable Object (PO) files: PO files are the files that contain the actual translation. You require a distinct PO file for each language added to your site, containing manual translations. So if you have English, French and Italian, you’ll need 3 PO files: fr.po, en.po and it.po
- Machine Object (MO) files: They have the same content as PO files but they come with another machine-readable format. Your server will use the MO file to display the translations.
Where to Find Translation-Ready WordPress Themes
The easiest way to find translation-ready themes is to follow those 2 easy steps:
- Go to the themes section from WordPress.org and click on the Feature Filter button:
The Feature Filter from WordPress.org
- From the second column Features, simply select the last option Translation-ready:
The Translation Ready filter
💡When you see the translation-ready mention for themes, they include a Portable Object Template (POT) file. That’s handy because this file contains all the strings of text that will need to be translated! |
Getting Technical: How WordPress Internationalization Works
WordPress uses specific language files to store translations of your site’s content (text strings) in different languages. This internationalization process (also called i18n) relies on the “gettext” system to render its core software translatable into diverse languages. WordPress developers use this common localization technology to craft translation-ready themes and plugins, facilitating the creation of multilingual WordPress websites.
To make a string translatable in a WordPress theme, developers have to wrap the original string in a call to one of a set of special functions. These functions collectively are known as “gettext.”
Now that you know more about how translation works in the WordPress ecosystem, let’s review the tools you need to translate your theme!
-
Installing and Configuring Polylang
Using the Polylang plugin is among the simplest methods to translate your WordPress site and a language switcher to it. Widely acclaimed as one of the most popular, highly-rated, and SEO-friendly WordPress Multilingual plugins, it boasts over 700,000 installations and a 4.7/5 rating!
Polylang will come in handy to translate the strings coming from the theme options and to serve the right language to the visitor.
Polylang is very easy to use and there is an installation wizard to help you add your languages to your WordPress site. Here’s how to install and configure Polylang. A Pro version of Polylang is also available but it is not needed to translate your theme.
- Install and activate the plugin from the WordPress Admin from Plugins > Add New Plugin
Installing Polylang directly from the WordPress admin
- Start the installation wizard and select all the languages you need, using the dropdown menu. Your theme will need to be translated in each of those languages.
Adding languages to my site
- Determine how the content without language will be handled: which language should be uniformly applied to all your content lacking a specified language?
Select the default language if there is no target language
- And you have configured Polylang! You are now ready to translate your content and your theme.
In the next two sections, we will see the difference between static and dynamic strings of your theme. We take the opportunity to clarify a crucial point about Polylang and a theme translation:
The Translations table from Polylang is dedicated to theme and plugin options only. You can’t translate static strings in the Translations table.
💡A last piece of advice before translating: Think about creating a child theme to avoid missing your translation when a theme is being updated. Updates to a theme might overwrite your translations, so it’s wise to always back up your translation files. |
3. Translating Your Theme’s Static Strings in WordPress
Static strings are written in PHP within the theme or plugin’s PHP files. When the translation exists, it’s stored in the .po/mo files. For those static strings, Polylang downloads translations of these strings when provided by themes and extensions and renders them automatically on the front end.
So far so good.
But what if the translation for the required language is missing? In that case, you’ll need to create it using Loco Translate or Poedit, both of which enable the creation or modification of .po/mo files. Only then, Polylang can download this translation on the front end as required, based on the current language of the page.
⚠️Important statement: To translate static strings, do not use the Theme and plugin translation for Polylang plugin (which was nos created by us) as it creates significant conflicts with Polylang. Our recommendation is not to use this extension and instead use Loco Translate or Poedit. |
There are two options to translate your theme’s static strings: either opt for a WordPress plugin like Loco Translate or use an application like Poedit. We’ll go over both options so you can determine which solution is best for your WordPress multilingual site.
OPTION A: Using the Loco Translate Plugin for WordPress Theme Translation
Loco Translate is a free plugin crafted to streamline the translation of WordPress themes and plugins. Its user-friendly interface resides directly within your WordPress dashboard, making the translation tasks very convenient. An important point: Loco Translate is fully compatible with Polylang.
To use Loco Translate for theme translation, follow these straightforward steps:
- Install Loco Translate. Navigate to your WordPress dashboard, then head to Plugins > Add New. Search for Loco Translate, proceed to install, and activate the plugin.
Installing Loco Translate from the WordPress admin
- Once activated, Loco Translate will introduce a new menu item in your dashboard. Go to Loco Translate > Themes.
Loco Translate’s menu
- Select the theme you intend to translate. We will select Astra.
Choosing Astra
Astra provides several PO files for several languages as you can see in the figure below:
PO files + translation already made by Astra in a few languages
- Click on the New Language button to add a language for translation or choose from the existing ones to edit.
Add new language button
- In our example we have added the Japanese language:
Adding our language to generate the PO file and starting the Japanese translation
💡PO file recommended location:
✅System directory: Place your custom translations here. They may benefit from community or professional translations available on the official WordPress translation for themes and extensions on wordpress.org. Once the “official” translation is published, your custom translation will be replaced by the official one from the theme or plugin authors. |
- Use the built-in editor provided by Loco Translate to translate text strings. The interface displays the original text on the top (Source text) and a field to add the translation at the bottom (Japanese translation).
Adding the Japanese translation to the PO file
- Save your translations using the Save button, and Loco Translate will automatically generate the necessary .po and .mo files.
- Polylang will then be able to download this translation on the front end as needed, based on the current language of the page.
💡Polylang and Loco Translate are not competitors’ plugins, they are complementary and mutually beneficial. When using them together, you make sure that each part of your WordPress site gets translated properly, including the hardcoded PHP strings from the theme. |
Option B: Employing Poedit for WordPress Theme Translation
Poedit is a cross-platform gettext translation editor that enables users to translate applications, plugins, and themes that use gettext for localization (just like WordPress themes). Overall, Poedit is a valuable tool for WordPress theme translators as it offers a user-friendly interface, supports various file formats, has efficient translation management, integration with WordPress themes, and offline translation capabilities.
What You Need
- Accessible WordPress Theme files on your computer.
- The Poedit software installed on your computer. Poedit is available for free on OS X, Windows and Linux and can be downloaded from here. The free version of Poedit is enough but you can also upgrade to have access to the whole WordPress options and support this Open Source project.
The Poedit App
- Open the Poedit app on your computer and press the Create New button
Create a new translation from POT template
- Open your WordPress theme file and go to Language > POT file
Opening the POT file
- Specify the language of the translation, we will add Japanese.
The Japanese language is created
- Start the translation of the Source text for each string in the Translation field. Poedit offers automatic translation (right column) that can help you translate faster.
Translating my theme to Japanese with Poedit
- Save and rename your file Ja_ja.po
- Now that the translations have been made locally, upload your file on the server to implement the translation. To do so, you can use FTP or cPanel. Go to wp-content\themes\astra\languages and add the new files.
💡In short:
Loco Translate: translates the theme directly from the WordPress admin, no FTP is needed. Poedit: translates the theme from an App (accessible offline) and you’ll need to re-upload your translation file via FTP. Polylang: makes sure to display the right language selected by the user and translate the strings coming from the theme options. Useful to translate the rest of your site and add a language switcher. |
4. Translating Your Theme’s Dynamic Strings in WordPress
Dynamic strings are filled in manually by the user in the WordPress theme options. These strings are stored in the database, more precisely in the WordPress wp_options table.
Polylang uses the wpml-config.xml file to display the strings in the Translations table (accessible from Languages > Translations).
Once this config file is added to the theme, the user can then translate them directly into this table.
The Translations table from Polylang
It’s important to reiterate that the Translations table is dedicated to theme and plugin options only; static strings are not displayed.
If you are a Polylang Pro user and need to add a wpml-config.xml file to your site, the Polylang team will do it for you. Feel free to contact the support from your account at any time. |
Behind the Scenes of Dynamic Strings and Themes Translation
Theme authors have two methods to register dynamic strings from their themes in Polylang’s Translations table:
- They can add their options to the Translations table of Polylang by creating a wpml-config.xml file.
- They have the option to use both functions:
- The pll_register_string function – Saves the option in the Translations table
- The pll_e function – Displays the translation from the Translations table on the frontend.
Use Polylang to Translate the Rest of Your Website
Polylang offers a comprehensive solution for users seeking WordPress internationalization directly from the WordPress admin. With its user-friendly interface, Polylang simplifies the process of translating content, ensuring that websites can serve international audiences effectively.
Key features include:
- Multiple Language Support: Polylang allows users to create multilingual websites with ease, supporting multiple languages simultaneously.
- Translation Management: Users can effortlessly translate posts, pages, categories, tags, menus, and widgets directly from the WordPress dashboard.
- Language Switcher: Polylang provides a customizable language switcher, allowing visitors to switch between languages effortlessly.
- WooCommerce integration: Polylang and WooCommerce integration enables users to create multilingual online stores effortlessly. With Polylang, users can translate all aspects of their WooCommerce-powered websites, including product listings, categories, tags, checkout pages, and more, into multiple languages.
- SEO Optimization: The plugin ensures that translated content is optimized for search engines, helping websites maintain visibility across different language markets. It’s fully integrated with Yoast SEO making it easy to improve your international SEO strategy.
Overall, Polylang, Loco Translate, and Poedit empower users to achieve effective WordPress theme internationalization, facilitating the creation of multilingual websites tailored to global audiences.
Translating your WordPress theme is not a daunting task, all you need is the right tools by your side! Why not try Polylang? It’s free and risk-free! Download Polylang, and translate your WordPress site and your theme for seamless navigation by international visitors!