Skip to content
Previous post Back to DOCUMENTATION Next post

Localisation of a plugin

Overview

The system allows the developers to localise their plugins. To do so, the plugin folder has to contain a dictionary for any language the plugin has to support.

 

Adding a dictionary

To add a dictionary, the developer has to create a file named localisation.XX, where XX is the ISO 639-1 "2-letter code" for the target language.
For example, to add a french dictionary:


vi /symlnks/var/es/htmlplugin//localisation.fr

 

Content of a dictionary

The dictionary is written in JSON-like notation. The file MUST contain a unique object, where each property associates a key (the name of the property) to the translated value.
For example, below are two files for localisation in English and French.

localisation.en


{
  'greetings': 'hello',
  'title': 'My title'
}

localisation.fr


{
  'greetings': 'bonjour',
  'title': 'Mon titre'
}

 

Choice of the dictionary used

When using the getTranslation method, the system will automatically choose the user's current locale. If no dictionary is available for this language, the system will choose the English one instead.

 

Use of ESLocaleManager

If you need to use translations already in the system (dalimstrings.xml), it's possible to use ES localisation strings instead.



var areYouSureText = this.getTranslation('DDMSUi/Are_you_sure');

For optimisation issues, it's also possible to preload all the translations in the plugin definition with the attribute preloadESTranslation.



var myPlugin = {
 preloadESTranslation:['DDMSUi/Are_you_sure', 'DDMSUi/All' , 'DDMSUi/Any']
 , buildComponent:function{
        // ...
    }
}
About the author
Aurelien Knapp
Senior Application Consultant at DALIM SOFTWARE