Translate theme and plugins on your own without using AIT Languages plugin

Updated: February 13, 2017

If you are not working on multilingual website, but you want just translate theme and plugins on your own to different language, you do not need to use AIT Languages plugin.
Following tutorial will show you how to translate theme and plugins to another language yourself.

Assuming that your WordPress is already installed in your target language you can follow steps below to translate also theme and plugin to this language. Example will describe translation of Theme and Plugin from default English language to German language on German WordPress installation.

Theme Before Translation

Translation POT files packed with Theme and Plugin

Witch each Theme and Plugin we provide also .pot files necessary to create translation files acceptable by WordPress.
You can find .pot files in following folders:

  • Theme frontend – folder ./wp-content/themes/themeName/ait-theme/languages/themeName.pot
  • Theme admin – folder ./wp-content/themes/themeName/ait-theme/languages/admin-themeName.pot
  • AIT plugins – all except AIT Languages plugin – folder ./wp-content/plugins/pluginName/languages/pluginName.pot

For example using theme Cityguide and AIT Elements Toolkit plugin you can locate .pot files:

  • Theme frontend – ./wp-content/themes/cityguide/ait-theme/languages/cityguide.pot
  • Theme admin – ./wp-content/themes/cityguide/ait-theme/languages/admin-cityguide.pot
  • AIT Elements Toolkit plugin – ./wp-content/plugins/ait-toolkit/languages/ait-toolkit.pot

Create own translation from POT files

From existing .pot file you will create .po and .mo file types:

  • .po file type created from .pot file and you will use this file for all further changes in translation
  • .mo file is created automatically during saving .po file, .mo file is the file which WordPress require to load translation

Each .po and .mo file must be saved in correct locale format which consists from Language Code and Country Code.
There are several exceptions when the country code doesn’t exist. The full list of supported languages and codes in WordPress is here Supported Codes. As an example look at Arabic. The result files would be ar.mo and ar.po.

Correct locale formats for .po and .mo files names (both .po and .mo files using the same name):

  • Theme Admin – admin-LanguageCode_CountryCode.po
    example: admin-de_DE.po
  • Theme Frontend – LanguageCode_CountryCode.po
    example: de_DE.po
  • AIT Elements Toolkit plugin – ait-toolkit-LanguageCode_CountryCode.po
    example: ait-toolkit-de_DE.po

To create .mo files we recommend poEdit translation tool.

poEdit

After installation, go to preferences of Poedit via menu File > Preferences and in Editor tab of options select “Automatically compile .mo file on save” to automatically create .mo file during saving .po file.

poedit_preferences

After this, you can start translation and create *.po and *.mo files.

1. start with click on the button Create new translation on the main poEdit screen displayed on screenshot above.

2. window to select POT file appears.
Navigate to POT file from which you’ll create .po and .mo files. So for example, if you are going to translate Theme Frontend now, open POT file for theme frontend:
./wp-content/themes/cityguide/ait-theme/languages/cityguide.pot
To translate theme admin, you have to open file ./wp-content/themes/cityguide/ait-theme/languages/admin-cityguide.pot
To translate theme frontend, you have to open file ./wp-content/themes/cityguide/ait-theme/languages/cityguide.pot
To translate plugin, for example AIT Elements Toolkit, you have to open from plugin folder file ./wp-content/plugins/ait-toolkit/languages/ait-toolkit.pot

Open POT file

In our tutorial we’ll continue with translation of theme frontend.

3. after opening POT file, “Translation Language” selection appears, select language which you are going to create, in our example German.

poEdit select language

4. now you can start translate words included in this POT file to your new language. In screenshot below you can see the Source Text window and Translation window where you have to write your own translation for currently selected word.

poEdit word translation

5. if you’re done with translation, click Save button to save .po and automatically generate .mo file. Don’t forget to write the correct name of saved file in locale format mentioned above. In our example we are going to save translation for frontend, so we are saving file de_DE.po and automatically will be generated file de_DE.mo.
If you are creating translation of Theme Admin, saved file is in format admin-de_DE.po and generated is file admin-de_DE.mo
In case of plugin translation, for example AIT Toolkit is saved file ait-toolkit-de_DE.po and generated is file ait-toolkit-de_DE.mo

poEdit save translation

Now you can find two new files in the folder of theme:
./wp-content/themes/cityguide/ait-theme/languages/de_DE.po
./wp-content/themes/cityguide/ait-theme/languages/de_DE.mo

saved files

6. Your translation is created and available in folder of theme. But with next theme update is theme deleted and replaced with folder of theme from us – where of course your own translations are not included so you should copy created translation files into place, where WordPress can find them and files will not be deleted with next theme or plugin update.

We highly recommend to store your own translation files in the Child Theme to prevent lost of your translation files with next Theme or Plugin update. For more information where you should store translation files, follow please article: Prevent deletion of languages files with theme and plugins update.

  • Child Theme – store translation files of theme in folder of child theme: ./wp-content/themes/ChildThemeName/ait-theme/languages/de_DE.mo

If you store translation files in folders mentioned above, you will not loose translation with next theme or plugin update.

close

If you are going to edit po file and change translations over FTP, download po file to your computer and edit file locally, because generated mo file is not uploaded to your server automatically with saved po file!