Translation of templates, themes and plugins in WordPress

Hosting Mautic QuickStart -50% with support in Spanish
24 hours and free training

Send up to 1,000,000 emails/year. Mautic support in Spanish 24 hours, 365 days

Although the WordPress content manager offers support for more than 100 languagesincluding Spanish, is limited exclusively to the administration area (“dashboard”), so keep in mind the plugins or , unless they also have our language.

However, many WordPress themes or plugins only have the English version and, when we use them, their texts appear in English within the pages and posts of our website, to the obvious displeasure of the user.

In this situation, we have two possible solutions: look for another plugin or theme (which may not be to our liking or suit our needs), or make the translation of messages and texts of those plugins and themes.

At first glance, translating a plugin or a theme may seem unattainable for us, because we may think that we have to immerse ourselves in the “guts” of WordPress and that we need to know the technology of this platform in depth.

However, as we will see in this article, just a few basic notions of how to WordPress manages multi-language versions of the themes and plugins, so that we are able to change those messages in English for other messages in Spanish.

What texts and messages can we translate in WordPress?

When we work with WordPress, the text that displays within a web page can be created or generated with one of the following four methods:

  • As part of the content, be they posts or pages, written by a copywriter within the WordPress editor and containing all the relevant information of that web page. In this case, we can use plugins that allow multilingual versions of a post or page (like ).
  • blog taxonomiessuch as categories and tags, also defined by the administrator or editor of the blog and that we can translate using this same plugin, WPML.
  • As part of the topic posts. In this case, the text strings are integrated into the PHP files of the theme and, to translate them, it would be necessary to edit those files and modify those strings.
  • As part of the plugin messages. As with the themes, the text of the messages are inside the PHP files of the plugin and, again, we would have to modify them to do the translation.

When we translate a theme or plugin, we must bear in mind that two sets of messages can be differentiated, depending on where they appear:

  • In the WordPress control panel and that, therefore, only the administrators of the website will see, never the visitors of their web pages.
  • Within web pages, as part of the operation or service of the theme or plugin, and integrated with the rest of the content of the website. Therefore, it will be seen by those who visit the website.
See also  Update to WordPress 5.6

In principle, we will be more interested in translating the “public” messages, the ones that can appear to users, than the control panel messages, which only we will see.

In both cases, the text messages are integrated into the PHP files of the theme or plugin and, as we will see, they all fall into the same batch and there is no distinction in the procedure for translating one or the other texts.

What WordPress themes and plugins can we translate?

We have mentioned that in order to translate a plugin or a theme, we would have to modify its PHP files, which can be an obstacle for those who do not know (nor need to know) this technology.

Fortunately, in the case of plugins and themes, although the messages and texts are inside these files, it is possible to perform translate them without the need to modify those filesbut through auxiliary files that allow this translation to be made.

However, for this to be feasible, the theme or plugin needs to have multilingual support, which we can find in the theme or plugin features such as “translation ready theme” or “translation ready plugin”.

When a theme or a plugin is ready for translation, the text messages are identified and encoded within the PHP files, so that they can be translated without the need to modify these files, but rather by creating new files that associate each text with its translation.

Currently, most themes and plugins are ready for translation although many do not include ours or, when they do, they are translations that use a different style of language than the one we use on the rest of the website.

In other words, in addition to translating the text messages of a topic or text, we can also change the translations that are already doneto put others that are consistent with the rest of the content.

This aspect of the possibilities of translating a theme or plugin can be almost as important as preventing English messages from appearing within a Spanish website. For example, to prevent the user from seeing different messages for the same actions; for example, “Read more” instead of “Continue reading” or the reverse.

How does WordPress manage the translation of texts and messages?

When a theme or plugin is “translation ready”, the information of the messages and their translations are saved in various files, which we can create or modify with the appropriate editor, and which are identified by the extension of their file name:

  • .POT file (Portable Object Template): This file contains all the text messages, in their original language, that are inside the PHP files of the theme or plugin and that need to be translated. The .POT file is generated by the theme or plugin provider and must be included in the installation. Without a .POT file, we will not be able to do translations.
  • .PO (Portable Object) files: There will be one for each language in which the theme or plugin is translated, and it saves the translation, for a specific language, of each text message identified within the .POT file.

    The name of the .PO files includes the name of the plugin or theme, the language and the variation of the translated messages it contains; for example, for Spanish from Spain, the .PO file would be “-es_ES.po”.

  • .MO (Machine Object) files: There will also be one for each language and it contains the same information as the .PO files, but in a compiled format for WordPress to read and manage.

    When we have finished editing the .PO file, we must compile it into its corresponding .MO file. The name of the .MO files is identical to that of the associated .PO file.

We do not worry about the .POT file, it is enough that we know that it exists, since its creation and management is the total and sole responsibility of the provider of the theme or plugin, which must supply it to us with the entire batch.

For our part, the process that we must carry out to translate or change the translation of a “translation ready” plugin or theme is very simple:

  1. Locate the .PO file of the plugin or theme. If it doesn’t exist, create it.
  2. Edit the .PO file to add or modify the translations.
  3. Generate the .MO file
  4. Save the .PO files in the WordPress language folders.

We can do this process from outside of WordPress, with a specialized editor, or from within, with a plugin, as we will see in the next section.

WordPress language folders for translations

All WordPress translations, both for the main WordPress core (i.e. the admin panel) and for plugins and themes, must be saved in certain folders of the WordPress installation on the web server, so that WordPress knows where to locate them :

  • wp-content/languages: contains the translation files (.PO and .MO) of the texts of the WordPress administration panel. In general, we do not need to modify these files nor is it usually advisable.
  • wp-content/languages/plugins: contains the translation files (.PO and .MO) of the texts of all the plugins. Each filename will include the name of the plugin or theme to identify it. In case a plugin is uninstalled, its files are not deleted.
  • wp-content/languages/themes: contains the translation files (.PO and .MO) of the texts of all the plugins. Each filename will include the name of the plugin or theme to identify it. In case the theme is deleted, its files are not deleted.
  • wp-content/plugins//language: alternative place to store the translation files (.PO and .MO) of a given plugin () and where providers usually include their own translations (when they do). In this case, when uninstalling the plugin, these files are also deleted.
  • wp-content/themes//language: alternative place to store the translation files (.PO and .MO) of a given theme () and where providers usually include their own translations (when they do). In this case, when deleting the theme, these files are also deleted.

In the following image we see a common layout of the translation files in a WordPress installation, through the File Manager of the WePanel tool, where we can also see the different translation files for various plugins:

Click on image to enlarge

When we create a .PO and .MO file, we must save it in the corresponding language folderbe it plugins or themes, although it is recommended to do it in the general languages ​​folder (inside wp-content/languages) so that we continue to have those files in case we reinstall the plugin or theme.

Plugin and theme translation recommendations

When we translate a text message in WordPress, we must take into account some considerations so that the translation fits well within the context of our website and that the user is not left confused by unnatural or inconsistent translations:

  • Maintain the same style or tone of conversation than the other texts on the website. For example, if our website is informal and very close, the messages of the plugins should be too.
  • Do not literally translate the original expressionsbut to think more about the idea that conveys the message in the original language and rewrite it so that it conveys the same thing in the target language.
  • Do not use colloquialisms or technical terms (unless it is a niche website). This recommendation also extends to the rest of the contents of the web page: colloquialisms or highly specialized technical terms can scare away new visitors to the website.
  • Check that the translations are displayed correctly. Plugins and themes have limited space to display your text messages. When we translate a text, this translation must be displayed in that same space, and must be completely legible and without affecting or altering the design or display of the rest of the web page.
  • Keep the same expressions as on the website. We have already mentioned this recommendation above. We must make sure that we use the same text message to represent expressions such as “back”, “read more”, “see page…
Loading Facebook Comments ...
Loading Disqus Comments ...