@true-directive/base
Version:
The set of base classes for the TrueDirective Grid
79 lines (78 loc) • 3.16 kB
JavaScript
var Internationalization = /** @class */ (function () {
function Internationalization() {
// List of locales
this.locales = [];
this.locales.push({
name: 'English',
shortName: 'en-US',
shortMonthNames: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
longMonthNames: ['January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November',
'December'],
shortDayNames: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
longDayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday',
'Friday', 'Saturday'],
firstDayOfWeek: 0,
dateFormat: 'mm/dd/yyyy',
timeHMFormat: 'hh:mi am',
timeHMSFormat: 'hh:mi:ss am',
dateTimeHMFormat: 'mm/dd/yyyy hh:mi am',
dateTimeHMSFormat: 'mm/dd/yyyy hh:mi:ss am',
separators: ['.', ','],
currency: '${N1-12.2}',
translates: {
'CONTAINS': 'Contains',
'NOT_CONTAINS': 'Not contains',
'BETWEEN': 'Between',
'NOT_BETWEEN': 'Not between',
'EQUALS': 'Equals',
'NOT_EQUALS': 'Not equals',
'EMPTY': 'Empty',
'NOT_EMPTY': 'Not empty',
'SET_OF_ITEMS': 'Set',
}
});
this._currentLocaleName = this.locales[0].shortName;
}
// Событие изменения локализации. Должно быть определено в производных классах
Internationalization.prototype.localeChangedEvent = function (locale) { };
Object.defineProperty(Internationalization.prototype, "currentLocaleName", {
get: function () {
return this._currentLocaleName;
},
set: function (shortName) {
this._currentLocaleName = shortName;
this.localeChangedEvent(this.locale);
},
enumerable: true,
configurable: true
});
// Adding a locale
Internationalization.prototype.addLocale = function (locale) {
if (!this.locales.find(function (l) { return l.shortName === locale.shortName; })) {
this.locales.push(locale);
}
};
Object.defineProperty(Internationalization.prototype, "locale", {
//
get: function () {
var _this = this;
var res = this.locales.find(function (l) { return l.shortName === _this._currentLocaleName; });
if (!res) {
return this.locales[0];
}
else {
return res;
}
},
enumerable: true,
configurable: true
});
Internationalization.prototype.translate = function (s) {
var res = this.locale.translates[s];
return res ? res : s;
};
return Internationalization;
}());
export { Internationalization };