Hello, ladies and gentlemen. In this article, I will explain how to translate a WordPress theme or plugin into another language. It’s quite simple to do, even without knowledge of the English language, as there are now many translators that can assist with this task. The best ones currently are ChatGPT, Deepl, and Google Translate. I recommend Deepl, as it generally requires fewer edits after translation. ChatGPT is more suitable for larger texts.

Now let’s get to the translation.

How to Translate a WordPress Theme into Another Language

This guide is applicable only to themes optimized for translation. Typically, such themes have translation files located in the theme folder under languages. In the same folder, you will find the translation template with the.pot extension.

However, there are cases where all the labels are embedded in template files and other files like functions.php, making it difficult to extract them for localization. In such cases, you may need to create a child theme, transfer all template files to it, and then proceed with the translation.

In a way, such a translation can turn into a theme fork because the templates won’t be updated, and new functionality may pass you by.

If you come across such a theme, it’s better to avoid it.

If the theme is optimized for translation, follow these steps:

  1. Download the poedit program: https://poedit.net/wordpress. It’s free.

  2. Download the WordPress theme file and extract it on your computer.

Now, let me provide you with a step-by-step guide with screenshots.

Step-by-Step Guide to Translating a WordPress Theme

Firstly, download the poedit program and install it. You can find it at: https://poedit.net/download.

The program is free, although the Pro version supports mass string editing and offers translation suggestions from the community and automatic machine translation, allowing you to translate a site quickly in some cases.

While this is worthwhile if you need to translate many themes or want to save time, you can also use the free version, which is sufficient for translation. Poedit has Russian localization.

Now, install the program and open it. In the open window, choose “Create New.” Then, locate the file with the name “theme_name.pot.

Creating a new translation in Poedit

The translation template file (.pot) will be located in the theme folder under “language”. Open this file. However, not all themes have such a file.

Next, select the translation language; in my case, it’s Russian.

Selecting the translation language in poedit

If this file is not available, take an alternative route. Open Poedit and click on “Create”.

Creating a new translation in poedit

Choose the translation language.

Language selection in Poedit

Save the new translation file to a location convenient for you. It’s preferable to save it in the theme folder you intend to translate.

Saving a template in Poedit

Then, click on “Extract from the source code”.

Extracting phrases for translation from source code

Afterwards, add the files you wish to translate or the entire theme folder, whichever is more convenient.

Selecting folders and files to extract source code for translation into Poedit

You also need to add keywords for searching text for translation.

Adding key phrases to Poedit

You can find a more detailed list of keywords here: https://gist.github.com/jarrodfreeman/c233dd025455b53518eb9f8b2d30cacb.

Unfortunately, you’ll need to insert keywords one by one.

Now, let’s proceed to the translation. Pay attention to suggested translation options from the community; they may contain errors. Consider the following example:

Translation error from the Poedit community

Continuing the translation, you may encounter situations like this, as there is an expression:

%d Comments:

For the English language, it’s straightforward, but for Russian, it’s different because we have three declensions for singular and plural, for example:

  • 2 or 22 comments;

  • 100 comments;

  • 1 comment.

Therefore, you need to specify the plural form. Of course, this depends on whether the theme you’re translating supports plurals or not.

To do this, go to “Translation” → “Properties”.

Translation properties in Poedit

The default option for Russian is suitable. However, be aware that there are languages with four forms for both singular and plural, so the suitable option depends on the language.

I recommend not changing anything, just for familiarization, so that you understand how it works.

Customizing plurals in Poedit

Sometimes the translator will warn about errors; yellow warnings are just notifications, and red ones are critical errors, for example, forgetting to add a variable in the translation.

Translation error warning

After completing the translation, simply save the file with the name of your language:

  • ru_RU — Russian;
  • de_DE — German;
  • en_EN — English.

You can check your language in the wp-config.php file.

Done, often the theme automatically picks up the language, but if it doesn’t happen, I will now explain how to do it.

How to Connect Translation to a WordPress Theme

You can, of course, simply drop the translation into the main theme folder. However, even that doesn’t always work. Sometimes, localization needs to be explicitly connected. In such a case, you need to add the following hook to the functions.php file:

function lang_load_theme_textdomain(){
	load_theme_textdomain( 'theme_name', get_template_directory() . '/languages' );
}
add_action( 'after_setup_theme', 'lang_load_theme_textdomain' );

Where theme_name should be replaced with the name of your theme, which you can find in the style.css of your parent theme. Look for the Text Domain there.

Text-domain for translation

get_template_directory() means that translations are connected from the parent theme.

If you need to enable language support in a child theme, you will need to include the following code in the functions.php of the child theme:

function lang_load_child_theme_textdomain(){
	load_child_theme_textdomain( 'theme_name', get_stylesheet_directory() . '/languages' );
}
add_action( 'after_setup_theme', 'lang_load_child_theme_textdomain' );

Where get_stylesheet_directory() indicates that the translation file is located in the child theme folder.

The theme name (Text Domain) remains the same as that of the parent theme.

As you can see, connecting translations to both the parent and child theme in WordPress is quite straightforward.

How to Translate a WordPress Plugin into Another Language: Step-by-Step Guide

Now let’s get started with translating a plugin into another language, in this example, we’ll use the Russian language. The principle is the same as translating a theme.

Follow these steps:

  1. Download the poedit program: https://poedit.net/wordpress. Install it. It’s free. However, the free version lacks machine translation support and many other features, so you’ll need to manually translate all plugin strings.

  2. Download the WordPress plugin file and extract it on your computer.

Now, a brief introduction: Translating plugins that do not support translation is a bit more complicated. Unlike themes where you can create a child theme, for plugins, it’s usually done through extensions. However, not all plugins support this, and creating an extension involves directly hooking into the plugin’s functionality, which may not provide the necessary functionality for translation.

As a result, you might have to translate the plugin as is.

In the best-case scenario, the plugin will have built-in translation support, and you can proceed with the translation without issues.

If there is no support, you may need to add it, and I’ll write about it a bit later. Now, let’s start translating the WordPress plugin into the Russian language.

First, open the poedit program. Now, there are two scenarios. Let’s start with the first and easiest one, where there’s already a translation template in the plugin folder.

In this case, after opening poedit, click on “Browse for files”.

Viewing files in Poedit

Then, find the .pot template file, which is likely located in the \plugin-name\languages folder. Open it, and now you can begin the translation. I’ll explain what exactly needs to be done shortly.

Translator interface in Poedit

Now, for the second scenario: no translation is available. In this case, you need to create one from scratch. Click on “Create”.

Creating a new translation in Poedit

Choose the language, and then save your project. Make sure to save it in the plugin folder you’re translating. For the Russian language, the file will be named ru_RU. For other languages, it may have a different code, which you can find in the wp-config.php file.

Language selection in Poedit

Now click on the “Extract from the source code” button.

Extracting text for translation from source code in Poedit

Next, specify the project name and indicate the plural form expression. In the Russian language, there are three forms of the plural, and in some languages, there might be four. The default settings generally work perfectly fine.

Customizing translation properties in Poedit

Now, add the entire folder for code extraction for translation or individual files.

Adding files and folders for translation extraction in Poedit

Next, add keywords for code extraction.

Adding keywords to search phrases in Poedit

You can find a complete list of keywords on this website: https://gist.github.com/jarrodfreeman/c233dd025455b53518eb9f8b2d30cacb. Unfortunately, you’ll need to go through this process with each project unless you purchase the Pro version.

Now you can start translating the plugin.

Translation in Poedit

After you finish the translation, simply save it in the plugin/languages folder (place the translation files .po and .mo for ru_RU there). If the plugin initially did not support translation, you’ll need to enable it.

How to Connect Translation to a WordPress Plugin

To achieve this, we need to add a function to the plugin’s executable file:

function plugin_localize_gut() {
load_plugin_textdomain( 'plugin_name', true, basename( dirname( __FILE__ ) ) . '/languages/' );
}
add_action( 'init', 'plugin_localize_gut' );

Where ‘plugin_name’ is the name of the plugin folder. The executable file has the same name as the plugin folder but with the.php format.

After adding this code to the plugin’s executable file, the translation will work. However, keep in mind that when updating, the executable file will be replaced, and this code will be lost. It’s better to ask the developer to add this line independently; it does not affect anything other than translations, doesn’t harm the plugin’s functionality, and significantly simplifies life.

Translating plugins and themes for WordPress is simple

Certainly, at times, translating thousands of lines can be tedious, but translating themes and plugins for WordPress into another language is not the most challenging task. You’ll easily handle it.

With that, I bid you farewell, wishing you success and high-quality translations. All the best!

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

If the materials from this website have been helpful, and you wish to support the blog, you can use the form at the following link: Donate to support the blog