Our plugins, like many other WordPress plugins, include translation files that help translate it for other languages. We rely heavily on folks from the community to provide us with translations because, frankly, we don’t speak every language here on The Events Calendar team.
While the files are helpful, they may not always be complete. Perhaps the person who started the translation file didn’t complete all of it for one reason or another. In these cases, the translation files are more of a starting point than they are a final solution.
So, we’re going to look at the basics of translations in this article. At the end, you should know the different types of translation files, how they’re used, and where to locate them.
Types of translation files
Translations usually consist of three types of files.
The .pot file
This file is the foundation for all of the translations in a plugin. It contains translatable strings, which is a fancy way of saying it contains words and phrases that can be translated. This file isn’t needed for the translations themselves to work. It merely serves as a blueprint for the translations.
The .po file
.po file is based on the
.pot file. It takes all of translatable strings that are defined in the
.pot file and allows us to provide translations for each string.
In fact, there’s a free app called Poedit that makes this process pretty painless. Open up the
.po file and start entering translations.
Notice something in there? The file is named in a way that identifies the type of translation that not contains, which in this case, is French Canadian.
.po for each translated language. The more files included in the plugin, the more translations that are available to use. The more complete the files are, the more coverage you get with the translation.
The .mo file
.mo file is not as reader-friendly as the
.po file. That’s because it’s what WordPress uses to convert the translated strings in the
.po file into the text that is displayed on the screen.
Locating translation files
By default the translation files are located in the plugin folders. For example, the translation files for The Events Calendar can be found in
Will translations always be located in a
/lang folder? No. It might be
/translations or whatever — it’s totally up to the developer. That’s great for flexibility, but means locating the files can be inconsistent between plugins.
Editing translation files
You can edit the
.po file for a translation right there in the plugin. That’s legit and works. However, it also means that you’ll lose your work the next time the plugin updates and you install it.
A better place to keep your edited translation files is
/wp-content/languages/plugins. That way, your translations not only override the ones in the plugin, but they’ll be left intact if the plugin happens to update later.