@duoduo-oba/ng-devui
Version:
DevUI components based on Angular
555 lines (543 loc) • 19.8 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('@angular/common')) :
typeof define === 'function' && define.amd ? define('ng-devui/i18n', ['exports', '@angular/core', 'rxjs', '@angular/common'], factory) :
(global = global || self, factory((global['ng-devui'] = global['ng-devui'] || {}, global['ng-devui'].i18n = {}), global.ng.core, global.rxjs, global.ng.common));
}(this, (function (exports, core, rxjs, common) { 'use strict';
/**
* @fileoverview added by tsickle
* Generated from: i18n.model.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @record
*/
function I18nInterface() { }
if (false) {
/** @type {?} */
I18nInterface.prototype.locale;
/** @type {?} */
I18nInterface.prototype.common;
/** @type {?} */
I18nInterface.prototype.datePicker;
/** @type {?} */
I18nInterface.prototype.pagination;
/** @type {?} */
I18nInterface.prototype.upload;
/** @type {?} */
I18nInterface.prototype.modal;
}
/**
* @fileoverview added by tsickle
* Generated from: zh-cn.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var zhCN = {
locale: 'zh-cn',
common: {
searchPlaceholder: '请输入关键字',
noData: '没有数据',
noRecordsFound: '找不到相关记录',
btnConfirm: '确定',
loading: '加载中...',
checkAll: '全选',
btnOk: '确定'
},
datePicker: {
today: '今天',
clear: '清除',
daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
monthsOfYear: ['一月',
'二月',
'三月',
'四月',
'五月',
'六月',
'七月',
'八月',
'九月',
'十月',
'十一月',
'十二月'],
},
pagination: {
totalItem: '所有条目',
goTo: '跳至',
pageSize: '每页条数'
},
upload: {
upload: '上传',
chooseFile: '选择文件',
chooseFiles: '选择多个文件',
preload: '预加载',
uploading: '上传中...',
uploaded: '已上传',
uploadFailed: '上传失败',
delete: '删除',
getNotAllowedFileTypeMsg: /**
* @param {?} filename
* @param {?} scope
* @return {?}
*/
function (filename, scope) {
return "\u60A8\u4E0A\u4F20\u7684\u6587\u4EF6\"" + filename + "\"\u4E0D\u5728\u5141\u8BB8\u8303\u56F4\"" + scope + "\"\u5185\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6";
},
getBeyondMaximalFileSizeMsg: /**
* @param {?} filename
* @param {?} maximalSize
* @return {?}
*/
function (filename, maximalSize) {
return "\u60A8\u4E0A\u4F20\u7684\u6587\u4EF6\"" + filename + "\"\u5927\u5C0F\u8D85\u8FC7\u6700\u5927\u9650\u5236" + maximalSize + "M\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6";
},
getExistSameNameFilesMsg: /**
* @param {?} sameNames
* @return {?}
*/
function (sameNames) {
return "\u60A8\u4E0A\u4F20\u7684 \"" + sameNames + "\" \u5B58\u5728\u91CD\u540D\u6587\u4EF6 ,\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6";
}
},
modal: {
warning: '提醒',
error: '错误',
info: '提示'
}
};
/**
* @fileoverview added by tsickle
* Generated from: en-us.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var enUS = {
locale: 'en-us',
common: {
searchPlaceholder: 'Enter a keyword.',
noData: 'No data available.',
noRecordsFound: 'No records found.',
btnConfirm: 'Confirm',
loading: 'Loading...',
checkAll: 'All',
btnOk: 'OK'
},
datePicker: {
today: 'Today',
clear: 'Clear',
daysOfWeek: ['Sun', 'Mon', 'Tues', 'Wed', 'Thur', 'Fri', 'Sat'],
monthsOfYear: ['January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'],
},
pagination: {
totalItem: 'Total Records',
goTo: 'Go To',
pageSize: 'Page Size'
},
upload: {
upload: 'Upload',
chooseFile: '--select--',
chooseFiles: '--select--',
preload: 'Selected',
uploading: 'Uploading...',
uploaded: 'Upload successful',
uploadFailed: 'Upload Failed',
delete: 'Delete',
getNotAllowedFileTypeMsg: /**
* @param {?} filename
* @param {?} scope
* @return {?}
*/
function (filename, scope) {
return "Files with unsupported types: " + filename + ". Supported file types: " + scope;
},
getBeyondMaximalFileSizeMsg: /**
* @param {?} filename
* @param {?} maximalSize
* @return {?}
*/
function (filename, maximalSize) {
return "Maximum file size (MB): " + maximalSize + ". Files whose size exceeds the maximum value: " + filename;
},
getExistSameNameFilesMsg: /**
* @param {?} sameNames
* @return {?}
*/
function (sameNames) {
return "Duplicate files exist : \"" + sameNames + "\"";
}
},
modal: {
warning: 'Warning',
error: 'Error',
info: 'Information'
}
};
/**
* @fileoverview added by tsickle
* Generated from: i18n.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var I18nService = /** @class */ (function () {
function I18nService() {
this.i18nConfig = {
'zh-cn': zhCN,
'en-us': enUS
};
this.i18nSubject = new rxjs.Subject();
}
/**
* @param {?=} lang
* @return {?}
*/
I18nService.prototype.toggleLang = /**
* @param {?=} lang
* @return {?}
*/
function (lang) {
if (lang === void 0) { lang = 'zh-cn'; }
localStorage.setItem('lang', lang);
this.i18nSubject.next(this.getI18nText());
};
/**
* @return {?}
*/
I18nService.prototype.getI18nText = /**
* @return {?}
*/
function () {
/** @type {?} */
var lang = localStorage.getItem('lang') ? localStorage.getItem('lang').toLocaleLowerCase() : 'zh-cn';
if (this.i18nConfig.hasOwnProperty(lang)) {
return this.i18nConfig[lang];
}
else {
return zhCN;
}
};
/**
* @return {?}
*/
I18nService.prototype.langChange = /**
* @return {?}
*/
function () {
return this.i18nSubject.asObservable();
};
I18nService.decorators = [
{ type: core.Injectable, args: [{ providedIn: 'root' },] }
];
/** @nocollapse */ I18nService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function I18nService_Factory() { return new I18nService(); }, token: I18nService, providedIn: "root" });
return I18nService;
}());
if (false) {
/**
* @type {?}
* @private
*/
I18nService.prototype.i18nConfig;
/**
* @type {?}
* @private
*/
I18nService.prototype.i18nSubject;
}
/**
* @fileoverview added by tsickle
* Generated from: i18n.util.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var I18nUtil = /** @class */ (function () {
function I18nUtil() {
}
/**
* @return {?}
*/
I18nUtil.getCurrentLanguage = /**
* @return {?}
*/
function () {
/** @type {?} */
var lang = localStorage.getItem('lang');
if (I18nUtil.supportLanguages.indexOf(lang) < 0) {
lang = I18nUtil.supportLanguages[0];
}
return lang;
};
/**
* @return {?}
*/
I18nUtil.getSupportLanguages = /**
* @return {?}
*/
function () {
return I18nUtil.supportLanguages;
};
I18nUtil.supportLanguages = ['zh-cn', 'en-us', 'ru-ru'];
return I18nUtil;
}());
if (false) {
/**
* @type {?}
* @private
*/
I18nUtil.supportLanguages;
}
/**
* @fileoverview added by tsickle
* Generated from: i18n.format.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var I18nFormat = /** @class */ (function () {
function I18nFormat() {
}
// 通过get方法来做业务没有指定locale的时候fallback
// 通过get方法来做业务没有指定locale的时候fallback
/**
* @private
* @param {?} locale
* @return {?}
*/
I18nFormat.getLocaleAndLang =
// 通过get方法来做业务没有指定locale的时候fallback
/**
* @private
* @param {?} locale
* @return {?}
*/
function (locale) {
/** @type {?} */
var currentLanguage = I18nUtil.getCurrentLanguage();
/** @type {?} */
var localeId;
try {
// 通过get方法来判断是否存在locale
common.getLocaleId(locale);
localeId = (locale || I18nFormat.DEFAULT_LOCALE).toLocaleLowerCase();
}
catch (error) {
localeId = I18nFormat.DEFAULT_LOCALE;
}
return { localeId: localeId, currentLanguage: currentLanguage };
};
// 短格式:y/MM/dd
// 短格式:y/MM/dd
/**
* @param {?} value
* @param {?=} format
* @param {?=} locale
* @param {?=} timezone
* @return {?}
*/
I18nFormat.formatDate =
// 短格式:y/MM/dd
/**
* @param {?} value
* @param {?=} format
* @param {?=} locale
* @param {?=} timezone
* @return {?}
*/
function (value, format, locale, timezone) {
/** @type {?} */
var localeLang = I18nFormat.getLocaleAndLang(locale);
/** @type {?} */
var formatStr = format ? format : I18nFormat.localFormat[localeLang.currentLanguage].short;
return common.formatDate(value, formatStr, localeLang.localeId, timezone);
};
// 完整格式:y/MM/dd hh:mm:ss zzzz
// 完整格式:y/MM/dd hh:mm:ss zzzz
/**
* @param {?} value
* @param {?=} format
* @param {?=} locale
* @param {?=} timezone
* @return {?}
*/
I18nFormat.formatDateTime =
// 完整格式:y/MM/dd hh:mm:ss zzzz
/**
* @param {?} value
* @param {?=} format
* @param {?=} locale
* @param {?=} timezone
* @return {?}
*/
function (value, format, locale, timezone) {
/** @type {?} */
var localeLang = I18nFormat.getLocaleAndLang(locale);
/** @type {?} */
var formatStr = format ? format : I18nFormat.localFormat[localeLang.currentLanguage].full;
return common.formatDate(value, formatStr, localeLang.localeId, timezone);
};
// 完整格式不加GMT:y/MM/dd hh:mm:ss
// 完整格式不加GMT:y/MM/dd hh:mm:ss
/**
* @param {?} value
* @param {?=} format
* @param {?=} locale
* @param {?=} timezone
* @return {?}
*/
I18nFormat.formatDateTimeWithoutGMT =
// 完整格式不加GMT:y/MM/dd hh:mm:ss
/**
* @param {?} value
* @param {?=} format
* @param {?=} locale
* @param {?=} timezone
* @return {?}
*/
function (value, format, locale, timezone) {
/** @type {?} */
var localeLang = I18nFormat.getLocaleAndLang(locale);
// 非用户传入的format,就替换掉完整的格式化字符中中GMT信息
/** @type {?} */
var formatStr = format ? format : (I18nFormat.localFormat[localeLang.currentLanguage].full).replace(' zzzz', '');
return common.formatDate(value, formatStr, localeLang.localeId, timezone);
};
// 默认locale使用英文,因为angular默认只支持英文,其他的需要显示注册
I18nFormat.DEFAULT_LOCALE = 'en-us';
I18nFormat.DATETIME_FORMAT_EN = 'MMM dd, y HH:mm:ss zzzz';
I18nFormat.DATETIME_FORMAT_ZH = 'y/MM/dd HH:mm:ss zzzz';
I18nFormat.DATETIME_FORMAT_RU = 'dd.MM.y HH:mm:ss zzzz';
I18nFormat.DATE_FORMAT_EN = 'MMM dd, y';
I18nFormat.DATE_FORMAT_ZH = 'y/MM/dd';
I18nFormat.DATE_FORMAT_RU = 'dd.MM.y';
I18nFormat.localFormat = {
'zh-cn': { full: I18nFormat.DATETIME_FORMAT_ZH, short: I18nFormat.DATE_FORMAT_ZH },
'en-us': { full: I18nFormat.DATETIME_FORMAT_EN, short: I18nFormat.DATE_FORMAT_EN },
'ru-ru': { full: I18nFormat.DATETIME_FORMAT_RU, short: I18nFormat.DATE_FORMAT_RU }
};
return I18nFormat;
}());
if (false) {
/**
* @type {?}
* @private
*/
I18nFormat.DEFAULT_LOCALE;
/**
* @type {?}
* @private
*/
I18nFormat.DATETIME_FORMAT_EN;
/**
* @type {?}
* @private
*/
I18nFormat.DATETIME_FORMAT_ZH;
/**
* @type {?}
* @private
*/
I18nFormat.DATETIME_FORMAT_RU;
/**
* @type {?}
* @private
*/
I18nFormat.DATE_FORMAT_EN;
/**
* @type {?}
* @private
*/
I18nFormat.DATE_FORMAT_ZH;
/**
* @type {?}
* @private
*/
I18nFormat.DATE_FORMAT_RU;
/**
* @type {?}
* @private
*/
I18nFormat.localFormat;
}
/**
* @fileoverview added by tsickle
* Generated from: i18n-date.pipe.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var I18nDatePipe = /** @class */ (function () {
function I18nDatePipe() {
}
/**
* 使用方式参考:{{dateObj | i18nDate:'full':false}} 参数可选
* @param value 日期表达式,字符串、数字或者日期对象.
* @param format 格式化表达式, 使用 'full','short'或者自定义格式化表达式.
* @param withGMT 是否包含GMT信息,默认包含,只对完整日期有效
* @returns 返回格式化后的字符串.
*/
/**
* 使用方式参考:{{dateObj | i18nDate:'full':false}} 参数可选
* @param {?} value 日期表达式,字符串、数字或者日期对象.
* @param {?=} format 格式化表达式, 使用 'full','short'或者自定义格式化表达式.
* @param {?=} withGMT 是否包含GMT信息,默认包含,只对完整日期有效
* @return {?} 返回格式化后的字符串.
*/
I18nDatePipe.prototype.transform = /**
* 使用方式参考:{{dateObj | i18nDate:'full':false}} 参数可选
* @param {?} value 日期表达式,字符串、数字或者日期对象.
* @param {?=} format 格式化表达式, 使用 'full','short'或者自定义格式化表达式.
* @param {?=} withGMT 是否包含GMT信息,默认包含,只对完整日期有效
* @return {?} 返回格式化后的字符串.
*/
function (value, format, withGMT) {
if (format === void 0) { format = 'full'; }
if (withGMT === void 0) { withGMT = true; }
if (format === 'full') {
/** @type {?} */
var formatValue = I18nFormat.formatDateTime(value);
if (!withGMT) {
formatValue = I18nFormat.formatDateTimeWithoutGMT(value);
}
return formatValue;
}
else if (format === 'short') {
return I18nFormat.formatDate(value);
}
else {
// 默认使用用户传入的format格式化
return I18nFormat.formatDate(value, format);
}
};
I18nDatePipe.decorators = [
{ type: core.Pipe, args: [{ name: 'i18nDate' },] }
];
return I18nDatePipe;
}());
/**
* @fileoverview added by tsickle
* Generated from: i18n.module.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var I18nModule = /** @class */ (function () {
function I18nModule() {
}
I18nModule.decorators = [
{ type: core.NgModule, args: [{
declarations: [
I18nDatePipe
],
exports: [
I18nDatePipe
]
},] }
];
return I18nModule;
}());
exports.I18nDatePipe = I18nDatePipe;
exports.I18nFormat = I18nFormat;
exports.I18nModule = I18nModule;
exports.I18nService = I18nService;
exports.I18nUtil = I18nUtil;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=ng-devui-i18n.umd.js.map