i18n

webix.i18n

webix.i18n helper.

Please look into the linked official documentation.

References

helpers
isArray(), template().

Referenced by

mixins
Number().
views
datatable().

External references

Official documentation page.

Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
webix.i18n = {
    _dateMethods:["fullDateFormat", "timeFormat", "dateFormat", "longDateFormat", "parseFormat", "parseTimeFormat"],
    parseFormat:"%Y-%m-%d %H:%i",
    parseTimeFormat:"%H:%i",
    numberFormat:webix.Number.format,
    priceFormat:function(value){ return webix.i18n._price_format(webix.i18n.numberFormat(value, webix.i18n._price_settings)); },

    setLocale:function(locale){
        var extend = function(base,source){
            for (var method in source){
                if(typeof(source[method]) == "object" && !webix.isArray(source[method])){
                    if(!base[method]){
                        base[method] = {};
                    }
                    extend(base[method],source[method]);
                }
                else
                    base[method] = source[method];
            }
        };

        if (typeof locale == "string")
            locale = this.locales[locale];
        if (locale){
            extend(this, locale);
        }
        var helpers = webix.i18n._dateMethods;
        for( var i=0; i<helpers.length; i++){
            var key = helpers[i];
            var utc = webix.i18n[key+"UTC"];
            webix.i18n[key+"Str"] = webix.Date.dateToStr(webix.i18n[key], utc);
            webix.i18n[key+"Date"] = webix.Date.strToDate(webix.i18n[key], utc);
        }

        this._price_format = webix.template(this.price);
        this._price_settings = this.priceSettings || this;

        this.intFormat = webix.Number.numToStr({ groupSize:this.groupSize, groupDelimiter:this.groupDelimiter, decimalSize : 0});
    }
};