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:
iscI18nProviderandiscL10nCache - Service:
iscI18n
isci18ndirective andiscI18nservice in the JavaScript documentation available with the application. - Directive:
Configuring i18n for Sterling Store
<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
- Override the
<wscdev.war>/ngstore/store/config/i18n.config.jsand place it in the<Extn_workspace>/extn/ngstore/store/config/i18n.config.js. - Update the configuration data as required by your business requirements.
Adding new bundle files
- Add
extn.nls.jsonfile to the<Extn_workspace>/extn/ngstore/store/views/nls/enfolder for adding nls file for the store module. Similarly, add for other locales as required. - Override the
i18n.config.jsto add new entry forextn.nls.jsonin thel10nKitarray.
Overriding existing bundle entries
json path in the extn.nls.json file. Refer to the following sample code snippet:
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
- Override the
i18n.config.jsfile 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>], - Override the
wsc.ui.localesproperty in the customer overrides file asyfs.wsc.ui.locales=de,en,es,fr,it,ja,ko,pl,pt,ru,tr,zh,zh-tw,<new_locale> - Update the
ngstore.gulp.config.jsonfile 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”: “”
}
}
});
}]);