How to translate Wodpress themes and plugins
In the previous article I introduced you to the WordPress system, allowing to translate themes and plugins. Now it’s time to start working on it!
Let’s consider that your theme, or plugin provides the translation support, so you get at least the .pot file. To work on a theme or a plugin translation we will use the free Poedit tool.
If the .po file in our language is missing, then we need to create it from the .pot file, and add all the translations from the scratch.
The text domain is explained in the Adding translation support to WordPress themes and plugins article, but you can simply copy the prefix (text domain) from other existing files in the languages directory.
Using the Mexican Spanish as an example, we will result with the name, like my_theme_name-sp_MX.po. The language code part (sp_MX) is automatically offered by Poedit.
If the .po file is also provided, then to translate the theme / plugin we only need to correct existing translation strings (if you wish), and add the absent ones.
Each time the .po file is being saved, the .mo file is being created / updated in the same folder.
After populating translation strings, the theme / plugin translation is ready. Now it is time to update the .mo file on your website, and to check the result online. There is no need to upload the .po file, neither the .pot file to the website. It is a good practice though to update the .po file as well in case you decide to use it a source for future corrections.
WordPress core also contains some strings for translation, such as:
- complete translation of the administrator’s side (site backend)
- standard system words, like months’ and days’ names, etc.
Translation for them is provided by WordPress itself. In case you need to change any system translations, you can locate the language files in the wp-content/languages folder, named
[language code]_[LOCALE CODE].po
All articles from this series
- Introduction to the structure of the WordPress translation.
- How to translate Wodpress themes and plugins.
- Theme’s original text strings customization.
- How to translate child themes.
- How to handle translations with plugins and theme updates.
- Adding a second language to a WordPress website.
- Adding translation support to WordPress themes and plugins.
As usually, I’ll be glad to answer your questions, or provide more clarification on the topic of this article: