How To Add Translations to Raxa-JSS modules

Steps to add translations to Raxa-JSS module using the i18n library:

  1. Copy the i18n library to the lib folder.
    Link to the library : https://github.com/Raxa/Ext.i18n.Bundle

  2. In the app.js (for each module) give path mapping as follows:

    Ext.Loader.setConfig({
        enabled: true,
        paths: {
            'Ext.i18n': 'lib/i18n'  //Mention the relevant path to the i18n library over here.
        }
    });

  3. Instantiate an instance of i18n bundle to be usable across a module as follows in the app.js of the respective module.
     (read convention, where bundle is name of the .properties file; lang is locale; path is filepath). So the file should be called a default RaxaEmr.properties and a lang version RaxaEmr_en-US.properties (say for en-US) . For registration it will be RaxaEmr.Registration_en-US.properties

    Code to instantiate:

    Ext.require('Ext.i18n.Bundle', function(){
        Ext.i18n.appBundle = Ext.create('Ext.i18n.Bundle',{
            bundle: 'RaxaEmr',
            lang: 'en-US',
            path: 'app/view', //For login
            noCache: true
        });
    });

  4. Suppose you wanted to change the 'Please login' text from Login.js main app view. You'd replace the title for the fieldset as follows:
    Ext.i18n.appBundle.getMsg('RaxaEmr.view.Login.title'),

  5. In the  RaxaEmr_en-US.properties file, the mapping would be like this:
    RaxaEmr.view.Login.title=Please Login

  6. You can add comments to the .properties file by preceding the comment with a #
    eg. # This is a comment.