How do I add new Language which is not included in AIT Languages plugin?

Updated: October 25, 2017

Note: If you’re willing to help us with translation to language that we currently don’t have, please contact us. We can make a deal 😉

If you want to use also language which is not currently included in theme, you have to create translation from .POT files which are attached to theme.

As theme include also plugins, you need to translate separately words from:

  • Theme admin
  • Theme frontend
  • AIT-Languages plugin
  • AIT-Shortcodes plugin
  • AIT-Toolkit plugin
  • AIT-Updater plugin
  • Revolution Slider plugin
  • + download translation for WordPress itself, to have translated general WordPress Admin too

Theme and each plugin will include own translation .po and .mo files, so for example if you do not need to have translated Revolution Slider plugin, it’s not necessary to create translation files for this plugin.

To have your new language available in selection of languages inside Languages options, you have to allow plugin use this new language. You can do so in functions.php file by adding filter with language code of new language:

add_filter('ait-supported-languages', function($langs){
    $langs[] = 'sr_RS';
    return $langs;
});


We recommend you to use child theme and use this filter in functions.php file of your child theme, so you will not be forced to change functions.php of parent theme after each theme update.

All available languages codes you can find in file of AIT Languages plugin:
./wp-content/plugins/ait-languages/settings/languages.php
From this file you can get language code of language which you are going to use, language code is used in function mentioned above.
For example Serbia language code in our example of code:

file_languages_php

Now, when your theme include function to add new language in functions.php file, you can find your new language in Languages options. In the selection where you can select languages for your website is available your new language.
New language is allowed, but you need to have translation files for WordPress, Theme and Plugins. So nothing is translated now in your new language.
Continue in reading to learn how to get translation files to have translated WordPress Admin, Theme Admin, Theme Frontend and Plugins.

1. Translate WordPress Admin

The best way to get translation files for WordPress Admin is direct download of WordPress in your language.

With downloaded WordPress you’ll download also po and mo files inside folder ./wp-content/languages

Copy WordPress translation files into your WordPress installation.

After this will be translated only WordPress Admin. Theme Admin, Theme Frontend and Plugins are not translated yet, because you need to create translation .po and .mo files from POT files included in theme and plugins, as is mentioned above.
Continue in reading to learn how to create new translation files for your new language.

2. Translate Theme and Plugins

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.

Turn on auto compilation of mo file

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

1. start with click on the button Create new translation:

Create translation

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 Admin now, open POT file for theme admin:
./wp-content/themes/langwitch/ait-theme/languages/admin-langwitch.pot

Select pot file name

3. after opening POT file, “Translation Language” selection appears, here choose your new language, for example Serbia in our example.

Select language

4. now you can start translate words included in this POT file to your new language:

How to work with poEdit

5. if you’re done with translation click Save button to save .po and .mo files.
Don’t forget to write the correct name of file in locale format mentioned above.

Save with correct locale name

6. copy created .mo file to appropriate folder of AIT Languages plugin in ./wp-content/plugins/ait-languages/ait/languages/
in our example, we will copy file admin-sr_RS.mo to folder ./wp-content/plugins/ait-languages/ait/languages/ait-theme/

7. repeat these steps with each POT file if you want translate also Theme Frontend and Plugins.

About Ivan Hudak

Works as an IT consultant for over 7 years now. He's a manager of our support team. Knows everything about all our themes, HTML, CSS, PHP and jQuery.