ImpressPages provides multilingual support for website themes and plugins. 

Translate a plugin

Use __()  function to place translatable text into your plugin. Exampe

$htmlOutput = __('My Sample Text', 'MyPlugin');

Let's say we want to add Spanish translation for "My Sample text". To do so, create Plugin/MyPlugin/translations/MyPlugin-es.json file (Here es is a language code for Spanish), and add the content translation as shown below:

    "My Sample Text": "Texto de ejemplo"

Now the same code will produce English or Spanish text depending on the page language. 

Plugin's admin translations (since 4.2.8)

Plugin's admin translations works the same. Just namespace is 'MyPlugin-admin'.

$htmlOutput = __('My Sample Text', 'MyPlugin-admin');

The translations file in this case will be Plugin/MyPlugin/translations/MyPlugin-admin-es.json 

Translate a theme

echo __('My Sample Text', 'MyTheme');

To translate "My Sample Text" string to Spanish language, create MyTheme-es.json file in your theme's translations subdirectory

    "My Sample Text": "Texto de ejemplo"

Translating third party plugins

If you want to translate third party plugin without touching original code, add PluginName-es.json to file/translations/override folder. Then your translations will not be lost when updating the plugin. 

Public website translations

ImpressPages tries to download required translations when you install new language. Full list of languages with available translations can be found on Transifex website. These translations are made by our community. You can help too and add some translations.

If default translations are missing in your language or you don't like the default ones, you can add your own translations. Just create a JSON file  in files/translations/override directory with required translations. The JSON file uses the same syntax as described in plugin and theme translation cases above. Use Ip-admin-fr.json for administration page translations, and Ip-fr.json for other web site texts (here fr is two character language code). For plugin translations, use your plugin name.

Admin interface translations

Copy file from Ip/Internal/Translations/translations/Ip-admin-xx.json and put it as file/translations/override/Ip-admin-xx.json Replace xx with chosen language code.

Add 'adminLocale' => 'xx' in config.php:

return array(
    'adminLocale' => 'xx',
    'sessionName' => 'ses1477701042', // prevents session conflict when two sites runs on the same server
    'developmentEnvironment' => 0, // displays error and debug information. Change to 0 before deployment to production server
    'showErrors' => 1, // 0 if you don't wish to display errors on the page

Alternatively you can just place an empty json file and put just those translations that you need in addition to the default ones.

Don't forget to logout / login selecting the new language to see the affect. 

comments powered by Disqus