How to Translate a WordPress Theme or Plugin to your Language
Posted in: Plugins, Themes, WordPress

How to Translate a WordPress Theme or Plugin to your Language

In this guide, you will learn how to translate a WordPress plugin or theme into your language using Poedit which is a free program to write translations.

The plugin or theme needs to be translation-ready before we can translate it to a different language.

Now, to check if the plugin or theme is translation-ready, we need to check if the author of the plugin or theme has provided the .pot (portable object template) file or the .po (portable object) file.

The .po file contains the actual translation and the .pot file is a template for creating the .po file (actual translation). So, the author may provide the actual translation into some language (.po file), or just the .pot file.

This means we can either use the .pot or the .po file to write the translation of a plugin or theme into our language.

Translating using a Plugin

Loco Translate is a WordPress plugin that allows you to edit WordPress translation files of any theme or plugin in your browser and also integrate them with automated translation services. This is a great option when you want to translate any plugins or themes right from the WordPress admin panel.

You can use it to translate any WordPress themes or plugins that are ready for translation.

Translating without using any Plugin

Now, in the WordPress installation directory of your server, navigate to the “wp-content” directory. Here, you will see the “plugins” and “themes” directories. In the plugins directory, you will find all the installed plugins and installed themes in the themes directory.

Let’s assume we are going to translate a theme named “PressBook”, so we will open the “themes” directory. And, inside this directory, we will open the directory with the theme. In this case, the name of the directory is “pressbook”.

Here, you will find all the theme files and folders. So, we just need to look for language files (.pot or .po files). Generally, these files are inside the language or lang directory of the theme. In this case, it’s the “pressbook.pot” file.

Once, you have found the language file, download it to your local PC. Now, we need to follow these steps:

  • Download and install Poedit as per your operating system.
  • Open Poedit and click on “Create new translation”.
Create New Translation - Poedit
Create New Translation – Poedit
  • Browse the .pot or .po file that you downloaded earlier. In this case, the file name is “pressbook.pot”.
  • Now, you will be asked for a translation language. So, select the language in which you want to translate. Here, we select the French language.
Translation Language - Poedit
Translation Language – Poedit
  • After selecting the language, you can start translating the text. To do so, click on the text and write its translation in the “Translation” field below.
  • Here, you will also be able to see translation suggestions for the text.
Source text and Translation - Poedit
Source text and Translation – Poedit

When you are done with translations, click on the “Validate” and then the “Save” button. This will generate the .po and .mo (Machine Object) files. The .mo file is the binary file that the machine can read and it is generated from the .po file.

So, we have fr_FR.po and fr_FR.mo files ready. Now, we just need to move them to the “wp-content/languages/themes” directory inside the WordPress installation directory.

If you can’t find the “languages” directory inside of wp-content. Then, you can create it. Similarly, depending on what you are translating, you will need to create another directory (themes or plugins) inside of the “languages” directory.

There is one more step before moving the language files. We need to rename them so the theme or plugin text-domain appears first, then the dash (-) followed by the file name. In this case, we will need to rename “fr_FR.po” and “fr_FR.mo” to “pressbook-fr_FR.po” and “pressbook-fr_FR.mo” respectively.

You can find the text-domain of the theme or plugin inside the style.css file of the theme and the main file of the plugin (generally, it’s plugin-name.php).

Finally, move the language files to the “wp-content/languages/themes” in case of theme translation or “wp-content/languages/themes” in the case of plugin translation.

Lastly, you can check to see if the translation is working by changing the language of your WordPress site.

Go to your WordPress admin area, “Settings” > “General” > “Site Language” to change the language.

You can repeat the same process if you see new strings (text) added to the translation file in the theme or plugin updates.

Back to Top