Legacy platform

Support for localization

This topic describes the support for localization in the application by using i18next.js.

  • You can find the Sterling Store Engagement application by using i18next.js, which is a third-party JavaScript library used to handle the i18n bundle conversion. See http://i18next.github.io/i18next/pages/doc_features.html for the features supported by i18next.
  • The Sterling Store Engagement application has its own directive, provider, and services for handling i18n in angular code blocks:
    • Directive: isc-i18n
    • Providers: iscI18nProvider and iscL10nCache
    • Service: iscI18n
    For more information, see the documentation of isci18n directive and iscI18n service in the JavaScript documentation available with the application.

Configuring i18n for Sterling Store

You can configure the i18n for the application in <wscdev.war>/ngstore/store/config/i18n.config.js. Refer to the following configuration code snippet:
angular.module('store').config(['iscI18nProvider',function(iscI18nProvider){
        iscI18nProvider.initExtn({
            lngs:["de", "en"], //Comma separated locale codes
            fallbackLng: 'en', // default locale, if none of the locale codes are specified
            l10nKit:[
                {url:'./shared/nls/__lng__/shared.nls.json',ns:'app'},
                {url:'./store/nls/__lng__/login.nls.json',ns:'app'},
                {url:'./store/nls/__lng__/app.nls.json',ns:'app'},
                {url:'./store/nls/__lng__/extn.nls.json',ns:'app'}
            ] 
// array of nls files to be loaded, __lng__ is variable which will be substituted in runtime
        });
    }]);

Customizing the i18n configuration

  1. Override the <wscdev.war>/ngstore/store/config/i18n.config.js and place it in the <Extn_workspace>/extn/ngstore/store/config/i18n.config.js.
  2. Update the configuration data as required by your business requirements.

Adding new bundle files

  1. Add extn.nls.json file to the <Extn_workspace>/extn/ngstore/store/views/nls/en folder for adding nls file for the store module. Similarly, add for other locales as required.
  2. Override the i18n.config.js to add new entry for extn.nls.json in the l10nKit array.

Overriding existing bundle entries

Existing bundle entries can be overridden by adding some additional keys along with the json path in the extn.nls.json file. Refer to the following sample code snippet:
Note: Put the key:value pairs in quotation marks as shown in the code snippet.

    {
        "TITLE_Product":"IBM Sterling Store",
        "order":{
            "LABEL_Order_no":"Order #"        
        }    
    }

New language support

Complete the following steps to support a new language:
  1. Override the i18n.config.js file to add a new entry for languages as shown in the following example:
    lngs:["de", "en", "es", "fr", "it", 
    "ja", "ko", "pl", "pt", "ru", "tr", "zh", "zh-tw", <new_locale>],
  2. Override the wsc.ui.locales property in the customer overrides file as yfs.wsc.ui.locales=de,en,es,fr,it,ja,ko,pl,pt,ru,tr,zh,zh-tw,<new_locale>
  3. Update the ngstore.gulp.config.json file for the new locale to be added for minification.
     "l10nLocales":["de","en","es","fr","it",
    "ja","ko","pl","pt","ru","tr","zh","zh-tw"<,new_locale>]

Customizing date format

The date filter appears on the Order list and Shipments list screens. The dates are formatted as MMM, dd, yyyy for the English locale alone. For all other locales, the format defaults are yyyy/MM/dd. This date format remains the same for From date, To date, and Date filter options drop-down menu.

Date formats can be customized. Refer to the ngstore\store\config\localedateformat.config.js file to learn more. Configure only valid formats understood by the bootstrap Datepicker widget. If the format is not specified or an invalid format is specified for a locale, the date format defaults to yyyy/MM/dd.

Customizing currency format

The ngstore\store\config\currency.config.js file is used to configure currency formatting information for various currency codes. The currency formats that are displayed on the UI, are configured in this file. To add a new currency apart from the currency format that is provided by default, you must extend the currency.config.js file as shown in the following example:

angular.module(‘store’).config([‘iscCurrencyFormatProvider’,function(iscCurrencyFormatProvider){
    iscCurrencyFormatProvider.addCurrencyFormat({
        “currencyCode” : “USD”,
        “currencyDescription” : “US Dollar”,
        “NUMBER_FORMATS” : {
            “CURRENCY_SYM”: “$”,
            “DECIMAL_SEP”: “.”,
            “GROUP_SEP”: “,”,
            “PATTERNS”:
            {
                “gSize”: 3,
                “lgSize”: 3,
                “maxFrac”: 2,
                “minFrac”: 2,
                “minInt”: 1,
                “negPre”: “-\u00a4”,
                “negSuf”: “”,
                “posPre”: “\u00a4”,
                “posSuf”: “”
            }
        }
    });
}]);