How to translate a theme (or plugin)

Portable Object Template (POT)

The master theme (or plugin) translation file is a .POT fileBasically, the .POT file is a list of all the text lines used in the theme files in English language:

The .POT file can be found in the languages folder.

Examples:

  • Nordis themewp-content/themes/nordis/languages/nordis.pot
  • PixCustom plugin: wp-content/plugins/pixtheme-custom/languages/pixtheme-custom.pot

 

Portable Object (PO) and Machine Object (MO)

The .PO file includes the original texts and the translations in two columns. It´s a translation that someone else started (the author, a professional translator, a WordPress theme user, etc), and maybe completed. WordPress doesn’t use it.

The .MO file includes the exact same contents as PO file. The two files differ in their format. While a PO file is easy for humans to read, MO files are compiled and are easy for computers to read. WordPress gets translations from .MO files.

The .MO file is automatically created by Poedit whenever you save a PO file. All you can do with these files is to upload or re-upload them whenever you create or update a .PO file.

 

Translate with Poedit

Poedit is a software (available for Windows, Mac and Linux) which you can use to translate the theme or plugin. It’s available for free on poedit.net. Free version comes with a builtin translation memory that remembers your past translations and uses them to make suggestions for similar texts.

Here are the steps:

  1. Open Poedit and select Create New Translation.
  2. Select the .POT file or the .PO file from the theme or plugin you wish to translate which (you can find the files in the wp-content/themes/your-theme/language/ folder).
  3. A box will pop up asking for language of the translation. Select your language:
  4. Hit OK and Poedit will name automatically your file. If you select German (Germany): de_DE.po (plugin_name-de_DE.po for plugin).
  5. Save the file to your computer.
  6. Now you can start translating your theme or your plugin. The space at the top will display all the text ready to translate, and any completed translations will display to the right. The boxes underneath show the source text, your translation and any notes for translators. Translating is really easy – just select a word or phrase, enter your translation.
    IMPORTANT:
    It´s not necessary translate all text strings. Perhaps you don´t want to spend your time translating text strings of the admin theme.
  7. When you’ve finished, save your file. Poedit will automatically create both .po and .mo files. You´ll have to upload both to your theme’s or plugin’s languages folder.

 

Global Languages Folder

Find the languages folder of the theme or plugin:

  • theme – wp-content/themes/languages/
  • plugin – wp-content/plugins/languages/

There you will find a file .pot (for Pitstop this file is named pitstop.pot, for PixCars plugin it’s pixcar.pot etc.). Load this file (as the catalog) in the PoEdit and start translating.

When done, save the .po file in the folder wp-content/languages/themes/ for theme and wp-content/languages/plugins/ for plugin and name this file regarding your locale. For example: for Spanish language you would name your file: pitstop-es_ES.po. The corresponding .mo file will be automatically created next to the .po file.

Note that it is not recommended anymore saving translation files in the theme directory (where you found the theme-slug.pot file), but in the wp-content/languages/themes or wp-content/languages/plugins instead. This way translations are kept when you update the theme or plugin.

 

Translate with Loco Translate plugin

Loco Translate is the best plugin to translate WordPress themes and plugins directly in your WordPress dashboard.

 

The Loco Translate plugin is great for localizing WordPress themes and plugins.

Features:

  • PO editor within WordPress admin
  • You can create and update language files directly in your plugin or theme
  • Extraction of translatable strings
  • MO file compilation
  • PO file backups
  • Built-in WordPress locale codes
 

 

Video instruction

 

 

 

Related Articles

Leave A Comment?

You must be logged in to post a comment.