This section will provide a general overview of how to edit and load a language file bundled with a WordPress plug-in. Language files usually contain translations for inaccessible parts of a WordPress plug-in (such as instructions, buttons and interface elements). In order to translate any dynamic content you will need to use a plugin such as LocoTranslate or WPML – this topic does not cover either of these plugins.
This topic will demonstrate how to translate an English .pot file to a Spanish .po file using the POEdit software. In this example we will be working with the .pot file from our Premium Presentations plug-in but the steps apply to any WordPress plug-in in general.
Locate the root folder of your WordPress plug-in and look for a folder labelled “languages” – this folder should contain a .pot file which is the main catalogue file. Open the .pot file with POEdit to begin editing. See image below for reference:
The .pot file by default does not have a language for translation assigned to it so we will do that in the next step.
Along the bottom of the POEdit interface (beneath the Source text column) you should see a large grey box with a button labelled “Create New Translation” – click on this button to get the Translation Language popup and assign a language for translation to your catalogue file. In this example we will select Spanish from the “Language of the translation” select list. See image below for reference:
Once you’ve assigned a language to your file you should see two new translation columns appear – the first column, “Translation — Spanish“, displays your translations next to each English translation and is adjacent to the “Source Text – English” column. The second column is the actual translation insert field where you insert your translation for the selected English text from the “Source Text – English” column – this column is located beneath the “Source text” column. At this point you can start inserting your translations for each English entry in “Source Text – English” column. See image below for reference:
When you’re done inserting your translations go ahead and save your file – POEdit will now save your file with a .po extension and will also generate a .mo file as well. For this example because we’ve assigned the Spanish language to our file we are going to save the file with the appropriate language code – in this case the filename will be proceeded by the textdomain of the plugin, in this case premiumPresentations, followed by a dash and the language code es_ES. The final filename for this example would be premiumPresentations-es_ES.po. You can use the following link to find your desired language code(s): https://wpcentral.io/internationalization/
Once you are done saving your file make sure it has been saved to the languages folder that resides with the root directory of your WordPress plug-in. Then log into your WordPress website and go to Settings -> General to and set your desired language from the Site Language select list. In this example we have selected “Espanol” from the Site Language list since we are working with the Spanish translation. And that should be it – your WordPress theme should now be translated. See image below for reference:
A few notes to keep in mind
Translation files are meant to translate static inaccessible areas of a WordPress plug-in. If you need to translate dynamic content such as post content you will need to use a translation plugin such as LocoTranslate or WPML.
Furthermore the steps outlined in this example are only for translating a WordPress plug-in. If you need to translate a WordPress theme click here for instructions.
Thanks for reading – we hope you found this article useful.