/*!
* vue-i18n v8.10.0
* (c) 2019 kazuya kawaguchi
* Released under the MIT License.
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.VueI18n = factory());
}(this, (function () { 'use strict';
/* */
/**
* constants
*/
var numberFormatKeys = [
'style',
'currency',
'currencyDisplay',
'useGrouping',
'minimumIntegerDigits',
'minimumFractionDigits',
'maximumFractionDigits',
'minimumSignificantDigits',
'maximumSignificantDigits',
'localeMatcher',
'formatMatcher'
];
/**
* utilities
*/
function warn (msg, err) {
if (typeof console !== 'undefined') {
console.warn('[vue-i18n] ' + msg);
/* istanbul ignore if */
if (err) {
console.warn(err.stack);
}
}
}
function isObject (obj) {
return obj !== null && typeof obj === 'object'
}
var toString = Object.prototype.toString;
var OBJECT_STRING = '[object Object]';
function isPlainObject (obj) {
return toString.call(obj) === OBJECT_STRING
}
function isNull (val) {
return val === null || val === undefined
}
function parseArgs () {
var args = [], len = arguments.length;
while ( len-- ) args[ len ] = arguments[ len ];
var locale = null;
var params = null;
if (args.length === 1) {
if (isObject(args[0]) || Array.isArray(args[0])) {
params = args[0];
} else if (typeof args[0] === 'string') {
locale = args[0];
}
} else if (args.length === 2) {
if (typeof args[0] === 'string') {
locale = args[0];
}
/* istanbul ignore if */
if (isObject(args[1]) || Array.isArray(args[1])) {
params = args[1];
}
}
return { locale: locale, params: params }
}
function looseClone (obj) {
return JSON.parse(JSON.stringify(obj))
}
function remove (arr, item) {
if (arr.length) {
var index = arr.indexOf(item);
if (index > -1) {
return arr.splice(index, 1)
}
}
}
var hasOwnProperty = Object.prototype.hasOwnProperty;
function hasOwn (obj, key) {
return hasOwnProperty.call(obj, key)
}
function merge (target) {
var arguments$1 = arguments;
var output = Object(target);
for (var i = 1; i < arguments.length; i++) {
var source = arguments$1[i];
if (source !== undefined && source !== null) {
var key = (void 0);
for (key in source) {
if (hasOwn(source, key)) {
if (isObject(source[key])) {
output[key] = merge(output[key], source[key]);
} else {
output[key] = source[key];
}
}
}
}
}
return output
}
function looseEqual (a, b) {
if (a === b) { return true }
var isObjectA = isObject(a);
var isObjectB = isObject(b);
if (isObjectA && isObjectB) {
try {
var isArrayA = Array.isArray(a);
var isArrayB = Array.isArray(b);
if (isArrayA && isArrayB) {
return a.length === b.length && a.every(function (e, i) {
return looseEqual(e, b[i])
})
} else if (!isArrayA && !isArrayB) {
var keysA = Object.keys(a);
var keysB = Object.keys(b);
return keysA.length === keysB.length && keysA.every(function (key) {
return looseEqual(a[key], b[key])
})
} else {
/* istanbul ignore next */
return false
}
} catch (e) {
/* istanbul ignore next */
return false
}
} else if (!isObjectA && !isObjectB) {
return String(a) === String(b)
} else {
return false
}
}
/* */
function extend (Vue) {
if (!Vue.prototype.hasOwnProperty('$i18n')) {
// $FlowFixMe
Object.defineProperty(Vue.prototype, '$i18n', {
get: function get () { return this._i18n }
});
}
Vue.prototype.$t = function (key) {
var values = [], len = arguments.length - 1;
while ( len-- > 0 ) values[ len ] = arguments[ len + 1 ];
var i18n = this.$i18n;
return i18n._t.apply(i18n, [ key, i18n.locale, i18n._getMessages(), this ].concat( values ))
};
Vue.prototype.$tc = function (key, choice) {
var values = [], len = arguments.length - 2;
while ( len-- > 0 ) values[ len ] = arguments[ len + 2 ];
var i18n = this.$i18n;
return i18n._tc.apply(i18n, [ key, i18n.locale, i18n._getMessages(), this, choice ].concat( values ))
};
Vue.prototype.$te = function (key, locale) {
var i18n = this.$i18n;
return i18n._te(key, i18n.locale, i18n._getMessages(), locale)
};
Vue.prototype.$d = function (value) {
var ref;
var args = [], len = arguments.length - 1;
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
return (ref = this.$i18n).d.apply(ref, [ value ].concat( args ))
};
Vue.prototype.$n = function (value) {
var ref;
var args = [], len = arguments.length - 1;
while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
return (ref = this.$i18n).n.apply(ref, [ value ].concat( args ))
};
}
/* */
var mixin = {
beforeCreate: function beforeCreate () {
var options = this.$options;
options.i18n = options.i18n || (options.__i18n ? {} : null);
if (options.i18n) {
if (options.i18n instanceof VueI18n) {
// init locale messages via custom blocks
if (options.__i18n) {
try {
var localeMessages = {};
options.__i18n.forEach(function (resource) {
localeMessages = merge(localeMessages, JSON.parse(resource));
});
Object.keys(localeMessages).forEach(function (locale) {
options.i18n.mergeLocaleMessage(locale, localeMessages[locale]);
});
} catch (e) {
{
warn("Cannot parse locale messages via custom blocks.", e);
}
}
}
this._i18n = options.i18n;
this._i18nWatcher = this._i18n.watchI18nData();
this._i18n.subscribeDataChanging(this);
this._subscribing = true;
} else if (isPlainObject(options.i18n)) {
// component local i18n
if (this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n) {
options.i18n.root = this.$root;
options.i18n.formatter = this.$root.$i18n.formatter;
options.i18n.fallbackLocale = this.$root.$i18n.fallbackLocale;
options.i18n.silentTranslationWarn = this.$root.$i18n.silentTranslationWarn;
options.i18n.silentFallbackWarn = this.$root.$i18n.silentFallbackWarn;
options.i18n.pluralizationRules = this.$root.$i18n.pluralizationRules;
options.i18n.preserveDirectiveContent = this.$root.$i18n.preserveDirectiveContent;
}
// init locale messages via custom blocks
if (options.__i18n) {
try {
var localeMessages$1 = {};
options.__i18n.forEach(function (resource) {
localeMessages$1 = merge(localeMessages$1, JSON.parse(resource));
});
options.i18n.messages = localeMessages$1;
} catch (e) {
{
warn("Cannot parse locale messages via custom blocks.", e);
}
}
}
this._i18n = new VueI18n(options.i18n);
this._i18nWatcher = this._i18n.watchI18nData();
this._i18n.subscribeData
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
lang.rar (4个子文件)
lang
vue-i18n.js 51KB
en.js 919B
lang.js 576B
zh.js 880B
共 4 条
- 1
周小生网易云音乐
- 粉丝: 3
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论10