vue-i18n 8.17.6 → 8.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/decls/i18n.js +5 -2
- package/dist/vue-i18n.common.js +61 -39
- package/dist/vue-i18n.esm.browser.js +62 -38
- package/dist/vue-i18n.esm.browser.min.js +1 -1
- package/dist/vue-i18n.esm.js +61 -39
- package/dist/vue-i18n.js +61 -39
- package/dist/vue-i18n.min.js +2 -2
- package/package.json +36 -35
- package/src/directive.js +1 -1
- package/src/index.js +54 -37
- package/src/mixin.js +15 -8
- package/types/index.d.ts +31 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,50 @@
|
|
|
1
1
|
|
|
2
|
+
## v8.18.2 (2020-06-08)
|
|
3
|
+
|
|
4
|
+
#### :zap: Improved Features
|
|
5
|
+
* [#917](https://github.com/kazupon/vue-i18n/pull/917) fix: improve IVueI18n interface ([@kazupon](https://github.com/kazupon))
|
|
6
|
+
|
|
7
|
+
#### :pencil: Documentation
|
|
8
|
+
* [#902](https://github.com/kazupon/vue-i18n/pull/902) docs: [RU] Translation update ([@Alex-Sokolov](https://github.com/Alex-Sokolov))
|
|
9
|
+
* [#901](https://github.com/kazupon/vue-i18n/pull/901) docs: (zh) inverse $d $n ([@stan-chen](https://github.com/stan-chen))
|
|
10
|
+
|
|
11
|
+
#### Committers: 4
|
|
12
|
+
- Alexander Sokolov ([@Alex-Sokolov](https://github.com/Alex-Sokolov))
|
|
13
|
+
- Rafał Chłodnicki ([@rchl](https://github.com/rchl))
|
|
14
|
+
- Stanley Chen ([@stan-chen](https://github.com/stan-chen))
|
|
15
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## v8.18.1 (2020-05-27)
|
|
19
|
+
|
|
20
|
+
#### :bug: Bug Fixes
|
|
21
|
+
* [#896](https://github.com/kazupon/vue-i18n/pull/896) Fix flow types and enable flow types testing on CI ([@rchl](https://github.com/rchl))
|
|
22
|
+
|
|
23
|
+
#### Committers: 1
|
|
24
|
+
- Rafał Chłodnicki ([@rchl](https://github.com/rchl))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## v8.18.0 (2020-05-26)
|
|
28
|
+
|
|
29
|
+
#### :star: New Features
|
|
30
|
+
* [#892](https://github.com/kazupon/vue-i18n/pull/892) Add onComponentInstanceCreated constructor option ([@rchl](https://github.com/rchl))
|
|
31
|
+
|
|
32
|
+
#### :zap: Improved Features
|
|
33
|
+
* [#890](https://github.com/kazupon/vue-i18n/pull/890) chore: set up linting for typescript definitions ([@rchl](https://github.com/rchl))
|
|
34
|
+
|
|
35
|
+
#### Committers: 1
|
|
36
|
+
- Rafał Chłodnicki ([@rchl](https://github.com/rchl))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## v8.17.7 (2020-05-19)
|
|
40
|
+
|
|
41
|
+
#### :bug: Bug Fixes
|
|
42
|
+
* [#882](https://github.com/kazupon/vue-i18n/pull/882) fix v-t pluralisation when choice is 0 ([@mikejacoutot](https://github.com/mikejacoutot))
|
|
43
|
+
|
|
44
|
+
#### Committers: 1
|
|
45
|
+
- [@mikejacoutot](https://github.com/mikejacoutot)
|
|
46
|
+
|
|
47
|
+
|
|
2
48
|
## v8.17.6 (2020-05-15)
|
|
3
49
|
|
|
4
50
|
#### :bug: Bug Fixes
|
package/decls/i18n.js
CHANGED
|
@@ -45,13 +45,15 @@ declare type NumberFormatOptions = {
|
|
|
45
45
|
};
|
|
46
46
|
declare type NumberFormat = { [key: string]: NumberFormatOptions };
|
|
47
47
|
declare type NumberFormats = { [key: Locale]: NumberFormat };
|
|
48
|
-
declare type Modifiers = { [key: string]: (str
|
|
48
|
+
declare type Modifiers = { [key: string]: (str: string) => string };
|
|
49
49
|
|
|
50
50
|
declare type TranslateResult = string | LocaleMessages;
|
|
51
51
|
declare type DateTimeFormatResult = string;
|
|
52
52
|
declare type NumberFormatResult = string;
|
|
53
53
|
declare type MissingHandler = (locale: Locale, key: Path, vm?: any) => string | void;
|
|
54
54
|
declare type PostTranslationHandler = (str: string, key?: string) => string;
|
|
55
|
+
declare type GetChoiceIndex = (choice: number, choicesLength: number) => number
|
|
56
|
+
declare type ComponentInstanceCreatedListener = (newI18n: I18n, rootI18n: I18n) => void;
|
|
55
57
|
|
|
56
58
|
declare type FormattedNumberPartType = 'currency' | 'decimal' | 'fraction' | 'group' | 'infinity' | 'integer' | 'literal' | 'minusSign' | 'nan' | 'plusSign' | 'percentSign';
|
|
57
59
|
declare type FormattedNumberPart = {
|
|
@@ -84,6 +86,7 @@ declare type I18nOptions = {
|
|
|
84
86
|
warnHtmlInMessage?: WarnHtmlInMessageLevel,
|
|
85
87
|
sharedMessages?: LocaleMessage,
|
|
86
88
|
postTranslation?: PostTranslationHandler,
|
|
89
|
+
componentInstanceCreatedListener?: ComponentInstanceCreatedListener,
|
|
87
90
|
};
|
|
88
91
|
|
|
89
92
|
declare type IntlAvailability = {
|
|
@@ -142,7 +145,7 @@ declare interface I18n {
|
|
|
142
145
|
setNumberFormat (locale: Locale, format: NumberFormat): void,
|
|
143
146
|
mergeNumberFormat (locale: Locale, format: NumberFormat): void,
|
|
144
147
|
n (value: number, ...args: any): NumberFormatResult,
|
|
145
|
-
getChoiceIndex:
|
|
148
|
+
getChoiceIndex: GetChoiceIndex,
|
|
146
149
|
pluralizationRules: PluralizationRules,
|
|
147
150
|
preserveDirectiveContent: boolean
|
|
148
151
|
};
|
package/dist/vue-i18n.common.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* vue-i18n v8.
|
|
2
|
+
* vue-i18n v8.18.2
|
|
3
3
|
* (c) 2020 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -252,16 +252,19 @@ var mixin = {
|
|
|
252
252
|
this._i18n = options.i18n;
|
|
253
253
|
this._i18nWatcher = this._i18n.watchI18nData();
|
|
254
254
|
} else if (isPlainObject(options.i18n)) {
|
|
255
|
+
var rootI18n = this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n
|
|
256
|
+
? this.$root.$i18n
|
|
257
|
+
: null;
|
|
255
258
|
// component local i18n
|
|
256
|
-
if (
|
|
259
|
+
if (rootI18n) {
|
|
257
260
|
options.i18n.root = this.$root;
|
|
258
|
-
options.i18n.formatter =
|
|
259
|
-
options.i18n.fallbackLocale =
|
|
260
|
-
options.i18n.formatFallbackMessages =
|
|
261
|
-
options.i18n.silentTranslationWarn =
|
|
262
|
-
options.i18n.silentFallbackWarn =
|
|
263
|
-
options.i18n.pluralizationRules =
|
|
264
|
-
options.i18n.preserveDirectiveContent =
|
|
261
|
+
options.i18n.formatter = rootI18n.formatter;
|
|
262
|
+
options.i18n.fallbackLocale = rootI18n.fallbackLocale;
|
|
263
|
+
options.i18n.formatFallbackMessages = rootI18n.formatFallbackMessages;
|
|
264
|
+
options.i18n.silentTranslationWarn = rootI18n.silentTranslationWarn;
|
|
265
|
+
options.i18n.silentFallbackWarn = rootI18n.silentFallbackWarn;
|
|
266
|
+
options.i18n.pluralizationRules = rootI18n.pluralizationRules;
|
|
267
|
+
options.i18n.preserveDirectiveContent = rootI18n.preserveDirectiveContent;
|
|
265
268
|
}
|
|
266
269
|
|
|
267
270
|
// init locale messages via custom blocks
|
|
@@ -291,6 +294,10 @@ var mixin = {
|
|
|
291
294
|
if (options.i18n.sync === undefined || !!options.i18n.sync) {
|
|
292
295
|
this._localeWatcher = this.$i18n.watchLocale();
|
|
293
296
|
}
|
|
297
|
+
|
|
298
|
+
if (rootI18n) {
|
|
299
|
+
rootI18n.onComponentInstanceCreated(this._i18n);
|
|
300
|
+
}
|
|
294
301
|
} else {
|
|
295
302
|
if (process.env.NODE_ENV !== 'production') {
|
|
296
303
|
warn("Cannot be interpreted 'i18n' option.");
|
|
@@ -618,7 +625,7 @@ function t (el, binding, vnode) {
|
|
|
618
625
|
}
|
|
619
626
|
|
|
620
627
|
var vm = vnode.context;
|
|
621
|
-
if (choice) {
|
|
628
|
+
if (choice != null) {
|
|
622
629
|
el._vt = el.textContent = (ref$1 = vm.$i18n).tc.apply(ref$1, [ path, choice ].concat( makeParams(locale, args) ));
|
|
623
630
|
} else {
|
|
624
631
|
el._vt = el.textContent = (ref$2 = vm.$i18n).t.apply(ref$2, [ path ].concat( makeParams(locale, args) ));
|
|
@@ -1151,6 +1158,7 @@ var VueI18n = function VueI18n (options) {
|
|
|
1151
1158
|
this._numberFormatters = {};
|
|
1152
1159
|
this._path = new I18nPath();
|
|
1153
1160
|
this._dataListeners = [];
|
|
1161
|
+
this._componentInstanceCreatedListener = options.componentInstanceCreatedListener || null;
|
|
1154
1162
|
this._preserveDirectiveContent = options.preserveDirectiveContent === undefined
|
|
1155
1163
|
? false
|
|
1156
1164
|
: !!options.preserveDirectiveContent;
|
|
@@ -1158,6 +1166,41 @@ var VueI18n = function VueI18n (options) {
|
|
|
1158
1166
|
this._warnHtmlInMessage = options.warnHtmlInMessage || 'off';
|
|
1159
1167
|
this._postTranslation = options.postTranslation || null;
|
|
1160
1168
|
|
|
1169
|
+
/**
|
|
1170
|
+
* @param choice {number} a choice index given by the input to $tc: `$tc('path.to.rule', choiceIndex)`
|
|
1171
|
+
* @param choicesLength {number} an overall amount of available choices
|
|
1172
|
+
* @returns a final choice index
|
|
1173
|
+
*/
|
|
1174
|
+
this.getChoiceIndex = function (choice, choicesLength) {
|
|
1175
|
+
var thisPrototype = Object.getPrototypeOf(this$1);
|
|
1176
|
+
if (thisPrototype && thisPrototype.getChoiceIndex) {
|
|
1177
|
+
var prototypeGetChoiceIndex = (thisPrototype.getChoiceIndex);
|
|
1178
|
+
return (prototypeGetChoiceIndex).call(this$1, choice, choicesLength)
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
// Default (old) getChoiceIndex implementation - english-compatible
|
|
1182
|
+
var defaultImpl = function (_choice, _choicesLength) {
|
|
1183
|
+
_choice = Math.abs(_choice);
|
|
1184
|
+
|
|
1185
|
+
if (_choicesLength === 2) {
|
|
1186
|
+
return _choice
|
|
1187
|
+
? _choice > 1
|
|
1188
|
+
? 1
|
|
1189
|
+
: 0
|
|
1190
|
+
: 1
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
return _choice ? Math.min(_choice, 2) : 0
|
|
1194
|
+
};
|
|
1195
|
+
|
|
1196
|
+
if (this$1.locale in this$1.pluralizationRules) {
|
|
1197
|
+
return this$1.pluralizationRules[this$1.locale].apply(this$1, [choice, choicesLength])
|
|
1198
|
+
} else {
|
|
1199
|
+
return defaultImpl(choice, choicesLength)
|
|
1200
|
+
}
|
|
1201
|
+
};
|
|
1202
|
+
|
|
1203
|
+
|
|
1161
1204
|
this._exist = function (message, key) {
|
|
1162
1205
|
if (!message || !key) { return false }
|
|
1163
1206
|
if (!isNull(this$1._path.getPathValue(message, key))) { return true }
|
|
@@ -1273,6 +1316,12 @@ VueI18n.prototype.watchLocale = function watchLocale () {
|
|
|
1273
1316
|
}, { immediate: true })
|
|
1274
1317
|
};
|
|
1275
1318
|
|
|
1319
|
+
VueI18n.prototype.onComponentInstanceCreated = function onComponentInstanceCreated (newI18n) {
|
|
1320
|
+
if (this._componentInstanceCreatedListener) {
|
|
1321
|
+
this._componentInstanceCreatedListener(newI18n, this);
|
|
1322
|
+
}
|
|
1323
|
+
};
|
|
1324
|
+
|
|
1276
1325
|
prototypeAccessors.vm.get = function () { return this._vm };
|
|
1277
1326
|
|
|
1278
1327
|
prototypeAccessors.messages.get = function () { return looseClone(this._getMessages()) };
|
|
@@ -1582,6 +1631,7 @@ VueI18n.prototype._getLocaleChain = function _getLocaleChain (start, fallbackLoc
|
|
|
1582
1631
|
if (isArray(fallbackLocale)) {
|
|
1583
1632
|
defaults = fallbackLocale;
|
|
1584
1633
|
} else if (isObject(fallbackLocale)) {
|
|
1634
|
+
/* $FlowFixMe */
|
|
1585
1635
|
if (fallbackLocale['default']) {
|
|
1586
1636
|
defaults = fallbackLocale['default'];
|
|
1587
1637
|
} else {
|
|
@@ -1730,34 +1780,6 @@ VueI18n.prototype.fetchChoice = function fetchChoice (message, choice) {
|
|
|
1730
1780
|
return choices[choice].trim()
|
|
1731
1781
|
};
|
|
1732
1782
|
|
|
1733
|
-
/**
|
|
1734
|
-
* @param choice {number} a choice index given by the input to $tc: `$tc('path.to.rule', choiceIndex)`
|
|
1735
|
-
* @param choicesLength {number} an overall amount of available choices
|
|
1736
|
-
* @returns a final choice index
|
|
1737
|
-
*/
|
|
1738
|
-
VueI18n.prototype.getChoiceIndex = function getChoiceIndex (choice, choicesLength) {
|
|
1739
|
-
// Default (old) getChoiceIndex implementation - english-compatible
|
|
1740
|
-
var defaultImpl = function (_choice, _choicesLength) {
|
|
1741
|
-
_choice = Math.abs(_choice);
|
|
1742
|
-
|
|
1743
|
-
if (_choicesLength === 2) {
|
|
1744
|
-
return _choice
|
|
1745
|
-
? _choice > 1
|
|
1746
|
-
? 1
|
|
1747
|
-
: 0
|
|
1748
|
-
: 1
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
|
-
return _choice ? Math.min(_choice, 2) : 0
|
|
1752
|
-
};
|
|
1753
|
-
|
|
1754
|
-
if (this.locale in this.pluralizationRules) {
|
|
1755
|
-
return this.pluralizationRules[this.locale].apply(this, [choice, choicesLength])
|
|
1756
|
-
} else {
|
|
1757
|
-
return defaultImpl(choice, choicesLength)
|
|
1758
|
-
}
|
|
1759
|
-
};
|
|
1760
|
-
|
|
1761
1783
|
VueI18n.prototype.tc = function tc (key, choice) {
|
|
1762
1784
|
var ref;
|
|
1763
1785
|
|
|
@@ -2105,6 +2127,6 @@ Object.defineProperty(VueI18n, 'availabilities', {
|
|
|
2105
2127
|
});
|
|
2106
2128
|
|
|
2107
2129
|
VueI18n.install = install;
|
|
2108
|
-
VueI18n.version = '8.
|
|
2130
|
+
VueI18n.version = '8.18.2';
|
|
2109
2131
|
|
|
2110
2132
|
module.exports = VueI18n;
|
|
@@ -226,16 +226,19 @@ var mixin = {
|
|
|
226
226
|
this._i18n = options.i18n;
|
|
227
227
|
this._i18nWatcher = this._i18n.watchI18nData();
|
|
228
228
|
} else if (isPlainObject(options.i18n)) {
|
|
229
|
+
const rootI18n = this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n
|
|
230
|
+
? this.$root.$i18n
|
|
231
|
+
: null;
|
|
229
232
|
// component local i18n
|
|
230
|
-
if (
|
|
233
|
+
if (rootI18n) {
|
|
231
234
|
options.i18n.root = this.$root;
|
|
232
|
-
options.i18n.formatter =
|
|
233
|
-
options.i18n.fallbackLocale =
|
|
234
|
-
options.i18n.formatFallbackMessages =
|
|
235
|
-
options.i18n.silentTranslationWarn =
|
|
236
|
-
options.i18n.silentFallbackWarn =
|
|
237
|
-
options.i18n.pluralizationRules =
|
|
238
|
-
options.i18n.preserveDirectiveContent =
|
|
235
|
+
options.i18n.formatter = rootI18n.formatter;
|
|
236
|
+
options.i18n.fallbackLocale = rootI18n.fallbackLocale;
|
|
237
|
+
options.i18n.formatFallbackMessages = rootI18n.formatFallbackMessages;
|
|
238
|
+
options.i18n.silentTranslationWarn = rootI18n.silentTranslationWarn;
|
|
239
|
+
options.i18n.silentFallbackWarn = rootI18n.silentFallbackWarn;
|
|
240
|
+
options.i18n.pluralizationRules = rootI18n.pluralizationRules;
|
|
241
|
+
options.i18n.preserveDirectiveContent = rootI18n.preserveDirectiveContent;
|
|
239
242
|
}
|
|
240
243
|
|
|
241
244
|
// init locale messages via custom blocks
|
|
@@ -264,6 +267,10 @@ var mixin = {
|
|
|
264
267
|
if (options.i18n.sync === undefined || !!options.i18n.sync) {
|
|
265
268
|
this._localeWatcher = this.$i18n.watchLocale();
|
|
266
269
|
}
|
|
270
|
+
|
|
271
|
+
if (rootI18n) {
|
|
272
|
+
rootI18n.onComponentInstanceCreated(this._i18n);
|
|
273
|
+
}
|
|
267
274
|
} else {
|
|
268
275
|
{
|
|
269
276
|
warn(`Cannot be interpreted 'i18n' option.`);
|
|
@@ -570,7 +577,7 @@ function t (el, binding, vnode) {
|
|
|
570
577
|
}
|
|
571
578
|
|
|
572
579
|
const vm = vnode.context;
|
|
573
|
-
if (choice) {
|
|
580
|
+
if (choice != null) {
|
|
574
581
|
el._vt = el.textContent = vm.$i18n.tc(path, choice, ...makeParams(locale, args));
|
|
575
582
|
} else {
|
|
576
583
|
el._vt = el.textContent = vm.$i18n.t(path, ...makeParams(locale, args));
|
|
@@ -1091,6 +1098,8 @@ class VueI18n {
|
|
|
1091
1098
|
|
|
1092
1099
|
|
|
1093
1100
|
|
|
1101
|
+
|
|
1102
|
+
|
|
1094
1103
|
|
|
1095
1104
|
|
|
1096
1105
|
|
|
@@ -1134,6 +1143,7 @@ class VueI18n {
|
|
|
1134
1143
|
this._numberFormatters = {};
|
|
1135
1144
|
this._path = new I18nPath();
|
|
1136
1145
|
this._dataListeners = [];
|
|
1146
|
+
this._componentInstanceCreatedListener = options.componentInstanceCreatedListener || null;
|
|
1137
1147
|
this._preserveDirectiveContent = options.preserveDirectiveContent === undefined
|
|
1138
1148
|
? false
|
|
1139
1149
|
: !!options.preserveDirectiveContent;
|
|
@@ -1141,6 +1151,41 @@ class VueI18n {
|
|
|
1141
1151
|
this._warnHtmlInMessage = options.warnHtmlInMessage || 'off';
|
|
1142
1152
|
this._postTranslation = options.postTranslation || null;
|
|
1143
1153
|
|
|
1154
|
+
/**
|
|
1155
|
+
* @param choice {number} a choice index given by the input to $tc: `$tc('path.to.rule', choiceIndex)`
|
|
1156
|
+
* @param choicesLength {number} an overall amount of available choices
|
|
1157
|
+
* @returns a final choice index
|
|
1158
|
+
*/
|
|
1159
|
+
this.getChoiceIndex = (choice, choicesLength) => {
|
|
1160
|
+
const thisPrototype = Object.getPrototypeOf(this);
|
|
1161
|
+
if (thisPrototype && thisPrototype.getChoiceIndex) {
|
|
1162
|
+
const prototypeGetChoiceIndex = (thisPrototype.getChoiceIndex);
|
|
1163
|
+
return (prototypeGetChoiceIndex).call(this, choice, choicesLength)
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
// Default (old) getChoiceIndex implementation - english-compatible
|
|
1167
|
+
const defaultImpl = (_choice, _choicesLength) => {
|
|
1168
|
+
_choice = Math.abs(_choice);
|
|
1169
|
+
|
|
1170
|
+
if (_choicesLength === 2) {
|
|
1171
|
+
return _choice
|
|
1172
|
+
? _choice > 1
|
|
1173
|
+
? 1
|
|
1174
|
+
: 0
|
|
1175
|
+
: 1
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
return _choice ? Math.min(_choice, 2) : 0
|
|
1179
|
+
};
|
|
1180
|
+
|
|
1181
|
+
if (this.locale in this.pluralizationRules) {
|
|
1182
|
+
return this.pluralizationRules[this.locale].apply(this, [choice, choicesLength])
|
|
1183
|
+
} else {
|
|
1184
|
+
return defaultImpl(choice, choicesLength)
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
|
|
1188
|
+
|
|
1144
1189
|
this._exist = (message, key) => {
|
|
1145
1190
|
if (!message || !key) { return false }
|
|
1146
1191
|
if (!isNull(this._path.getPathValue(message, key))) { return true }
|
|
@@ -1254,6 +1299,12 @@ class VueI18n {
|
|
|
1254
1299
|
}, { immediate: true })
|
|
1255
1300
|
}
|
|
1256
1301
|
|
|
1302
|
+
onComponentInstanceCreated (newI18n) {
|
|
1303
|
+
if (this._componentInstanceCreatedListener) {
|
|
1304
|
+
this._componentInstanceCreatedListener(newI18n, this);
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1257
1308
|
get vm () { return this._vm }
|
|
1258
1309
|
|
|
1259
1310
|
get messages () { return looseClone(this._getMessages()) }
|
|
@@ -1560,6 +1611,7 @@ class VueI18n {
|
|
|
1560
1611
|
if (isArray(fallbackLocale)) {
|
|
1561
1612
|
defaults = fallbackLocale;
|
|
1562
1613
|
} else if (isObject(fallbackLocale)) {
|
|
1614
|
+
/* $FlowFixMe */
|
|
1563
1615
|
if (fallbackLocale['default']) {
|
|
1564
1616
|
defaults = fallbackLocale['default'];
|
|
1565
1617
|
} else {
|
|
@@ -1697,34 +1749,6 @@ class VueI18n {
|
|
|
1697
1749
|
return choices[choice].trim()
|
|
1698
1750
|
}
|
|
1699
1751
|
|
|
1700
|
-
/**
|
|
1701
|
-
* @param choice {number} a choice index given by the input to $tc: `$tc('path.to.rule', choiceIndex)`
|
|
1702
|
-
* @param choicesLength {number} an overall amount of available choices
|
|
1703
|
-
* @returns a final choice index
|
|
1704
|
-
*/
|
|
1705
|
-
getChoiceIndex (choice, choicesLength) {
|
|
1706
|
-
// Default (old) getChoiceIndex implementation - english-compatible
|
|
1707
|
-
const defaultImpl = (_choice, _choicesLength) => {
|
|
1708
|
-
_choice = Math.abs(_choice);
|
|
1709
|
-
|
|
1710
|
-
if (_choicesLength === 2) {
|
|
1711
|
-
return _choice
|
|
1712
|
-
? _choice > 1
|
|
1713
|
-
? 1
|
|
1714
|
-
: 0
|
|
1715
|
-
: 1
|
|
1716
|
-
}
|
|
1717
|
-
|
|
1718
|
-
return _choice ? Math.min(_choice, 2) : 0
|
|
1719
|
-
};
|
|
1720
|
-
|
|
1721
|
-
if (this.locale in this.pluralizationRules) {
|
|
1722
|
-
return this.pluralizationRules[this.locale].apply(this, [choice, choicesLength])
|
|
1723
|
-
} else {
|
|
1724
|
-
return defaultImpl(choice, choicesLength)
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
|
|
1728
1752
|
tc (key, choice, ...values) {
|
|
1729
1753
|
return this._tc(key, this.locale, this._getMessages(), null, choice, ...values)
|
|
1730
1754
|
}
|
|
@@ -2056,6 +2080,6 @@ Object.defineProperty(VueI18n, 'availabilities', {
|
|
|
2056
2080
|
});
|
|
2057
2081
|
|
|
2058
2082
|
VueI18n.install = install;
|
|
2059
|
-
VueI18n.version = '8.
|
|
2083
|
+
VueI18n.version = '8.18.2';
|
|
2060
2084
|
|
|
2061
2085
|
export default VueI18n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=["style","currency","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits","localeMatcher","formatMatcher","unit"];function e(t,e){"undefined"!=typeof console&&(console.warn("[vue-i18n] "+t),e&&console.warn(e.stack))}const n=Array.isArray;function s(t){return null!==t&&"object"==typeof t}function r(t){return"string"==typeof t}const i=Object.prototype.toString,a="[object Object]";function o(t){return i.call(t)===a}function l(t){return null==t}function c(...t){let e=null,n=null;return 1===t.length?s(t[0])||Array.isArray(t[0])?n=t[0]:"string"==typeof t[0]&&(e=t[0]):2===t.length&&("string"==typeof t[0]&&(e=t[0]),(s(t[1])||Array.isArray(t[1]))&&(n=t[1])),{locale:e,params:n}}function h(t){return JSON.parse(JSON.stringify(t))}function u(t,e){return!!~t.indexOf(e)}const m=Object.prototype.hasOwnProperty;function _(t,e){return m.call(t,e)}function f(t){const e=Object(t);for(let t=1;t<arguments.length;t++){const n=arguments[t];if(null!=n){let t;for(t in n)_(n,t)&&(s(n[t])?e[t]=f(e[t],n[t]):e[t]=n[t])}}return e}function g(t,e){if(t===e)return!0;const n=s(t),r=s(e);if(!n||!r)return!n&&!r&&String(t)===String(e);try{const n=Array.isArray(t),s=Array.isArray(e);if(n&&s)return t.length===e.length&&t.every((t,n)=>g(t,e[n]));if(n||s)return!1;{const n=Object.keys(t),s=Object.keys(e);return n.length===s.length&&n.every(n=>g(t[n],e[n]))}}catch(t){return!1}}var p={beforeCreate(){const t=this.$options;if(t.i18n=t.i18n||(t.__i18n?{}:null),t.i18n){if(t.i18n instanceof Y){if(t.__i18n)try{let e={};t.__i18n.forEach(t=>{e=f(e,JSON.parse(t))}),Object.keys(e).forEach(n=>{t.i18n.mergeLocaleMessage(n,e[n])})}catch(t){}this._i18n=t.i18n,this._i18nWatcher=this._i18n.watchI18nData()}else if(o(t.i18n)){if(this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof Y&&(t.i18n.root=this.$root,t.i18n.formatter=this.$root.$i18n.formatter,t.i18n.fallbackLocale=this.$root.$i18n.fallbackLocale,t.i18n.formatFallbackMessages=this.$root.$i18n.formatFallbackMessages,t.i18n.silentTranslationWarn=this.$root.$i18n.silentTranslationWarn,t.i18n.silentFallbackWarn=this.$root.$i18n.silentFallbackWarn,t.i18n.pluralizationRules=this.$root.$i18n.pluralizationRules,t.i18n.preserveDirectiveContent=this.$root.$i18n.preserveDirectiveContent),t.__i18n)try{let e={};t.__i18n.forEach(t=>{e=f(e,JSON.parse(t))}),t.i18n.messages=e}catch(t){}const{sharedMessages:e}=t.i18n;e&&o(e)&&(t.i18n.messages=f(t.i18n.messages,e)),this._i18n=new Y(t.i18n),this._i18nWatcher=this._i18n.watchI18nData(),(void 0===t.i18n.sync||t.i18n.sync)&&(this._localeWatcher=this.$i18n.watchLocale())}}else this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof Y?this._i18n=this.$root.$i18n:t.parent&&t.parent.$i18n&&t.parent.$i18n instanceof Y&&(this._i18n=t.parent.$i18n)},beforeMount(){const t=this.$options;t.i18n=t.i18n||(t.__i18n?{}:null),t.i18n?t.i18n instanceof Y?(this._i18n.subscribeDataChanging(this),this._subscribing=!0):o(t.i18n)&&(this._i18n.subscribeDataChanging(this),this._subscribing=!0):this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof Y?(this._i18n.subscribeDataChanging(this),this._subscribing=!0):t.parent&&t.parent.$i18n&&t.parent.$i18n instanceof Y&&(this._i18n.subscribeDataChanging(this),this._subscribing=!0)},beforeDestroy(){if(!this._i18n)return;const t=this;this.$nextTick(()=>{t._subscribing&&(t._i18n.unsubscribeDataChanging(t),delete t._subscribing),t._i18nWatcher&&(t._i18nWatcher(),t._i18n.destroyVM(),delete t._i18nWatcher),t._localeWatcher&&(t._localeWatcher(),delete t._localeWatcher)})}},d={name:"i18n",functional:!0,props:{tag:{type:[String,Boolean],default:"span"},path:{type:String,required:!0},locale:{type:String},places:{type:[Array,Object]}},render(t,{data:e,parent:n,props:s,slots:r}){const{$i18n:i}=n;if(!i)return;const{path:a,locale:o,places:l}=s,c=r(),h=i.i(a,o,function(t){let e;for(e in t)if("default"!==e)return!1;return Boolean(e)}(c)||l?function(t,e){const n=e?function(t){return Array.isArray(t)?t.reduce(v,{}):Object.assign({},t)}(e):{};if(!t)return n;const s=(t=t.filter(t=>t.tag||""!==t.text.trim())).every(y);return t.reduce(s?b:v,n)}(c.default,l):c),u=s.tag&&!0!==s.tag||!1===s.tag?s.tag:"span";return u?t(u,e,h):h}};function b(t,e){return e.data&&e.data.attrs&&e.data.attrs.place&&(t[e.data.attrs.place]=e),t}function v(t,e,n){return t[n]=e,t}function y(t){return Boolean(t.data&&t.data.attrs&&t.data.attrs.place)}var $={name:"i18n-n",functional:!0,props:{tag:{type:[String,Boolean],default:"span"},value:{type:Number,required:!0},format:{type:[String,Object]},locale:{type:String}},render(e,{props:n,parent:i,data:a}){const o=i.$i18n;if(!o)return null;let l=null,c=null;r(n.format)?l=n.format:s(n.format)&&(n.format.key&&(l=n.format.key),c=Object.keys(n.format).reduce((e,s)=>u(t,s)?Object.assign({},e,{[s]:n.format[s]}):e,null));const h=n.locale||o.locale,m=o._ntp(n.value,h,l,c),_=m.map((t,e)=>{const n=a.scopedSlots&&a.scopedSlots[t.type];return n?n({[t.type]:t.value,index:e,parts:m}):t.value}),f=n.tag&&!0!==n.tag||!1===n.tag?n.tag:"span";return f?e(f,{attrs:a.attrs,class:a.class,staticClass:a.staticClass},_):_}};function F(t,e,n){M(t,n)&&T(t,e,n)}function k(t,e,n,s){if(!M(t,n))return;const r=n.context.$i18n;(function(t,e){const n=e.context;return t._locale===n.$i18n.locale})(t,n)&&g(e.value,e.oldValue)&&g(t._localeMessage,r.getLocaleMessage(r.locale))||T(t,e,n)}function w(t,n,s,r){if(!s.context)return void e("Vue instance does not exists in VNode context");const i=s.context.$i18n||{};n.modifiers.preserve||i.preserveDirectiveContent||(t.textContent=""),t._vt=void 0,delete t._vt,t._locale=void 0,delete t._locale,t._localeMessage=void 0,delete t._localeMessage}function M(t,n){const s=n.context;return s?!!s.$i18n||(e("VueI18n instance does not exists in Vue instance"),!1):(e("Vue instance does not exists in VNode context"),!1)}function T(t,n,s){const i=n.value,{path:a,locale:l,args:c,choice:h}=function(t){let e,n,s,i;r(t)?e=t:o(t)&&(e=t.path,n=t.locale,s=t.args,i=t.choice);return{path:e,locale:n,args:s,choice:i}}(i);if(!a&&!l&&!c)return void e("value type not supported");if(!a)return void e("`path` is required in v-t directive");const u=s.context;t._vt=t.textContent=h?u.$i18n.tc(a,h,...C(l,c)):u.$i18n.t(a,...C(l,c)),t._locale=u.$i18n.locale,t._localeMessage=u.$i18n.getLocaleMessage(u.$i18n.locale)}function C(t,e){const n=[];return t&&n.push(t),e&&(Array.isArray(e)||o(e))&&n.push(e),n}let L;function D(t){D.installed=!0;(L=t).version&&Number(L.version.split(".")[0]);!function(t){t.prototype.hasOwnProperty("$i18n")||Object.defineProperty(t.prototype,"$i18n",{get(){return this._i18n}}),t.prototype.$t=function(t,...e){const n=this.$i18n;return n._t(t,n.locale,n._getMessages(),this,...e)},t.prototype.$tc=function(t,e,...n){const s=this.$i18n;return s._tc(t,s.locale,s._getMessages(),this,e,...n)},t.prototype.$te=function(t,e){const n=this.$i18n;return n._te(t,n.locale,n._getMessages(),e)},t.prototype.$d=function(t,...e){return this.$i18n.d(t,...e)},t.prototype.$n=function(t,...e){return this.$i18n.n(t,...e)}}(L),L.mixin(p),L.directive("t",{bind:F,update:k,unbind:w}),L.component(d.name,d),L.component($.name,$),L.config.optionMergeStrategies.i18n=function(t,e){return void 0===e?t:e}}const x=/^(?:\d)+/,O=/^(?:\w)+/;const I=0,W=1,j=2,N=3,A=0,S=4,R=5,H=6,P=7,V=8,E=[];E[A]={ws:[A],ident:[3,I],"[":[S],eof:[P]},E[1]={ws:[1],".":[2],"[":[S],eof:[P]},E[2]={ws:[2],ident:[3,I],0:[3,I],number:[3,I]},E[3]={ident:[3,I],0:[3,I],number:[3,I],ws:[1,W],".":[2,W],"[":[S,W],eof:[P,W]},E[S]={"'":[R,I],'"':[H,I],"[":[S,j],"]":[1,N],eof:V,else:[S,I]},E[R]={"'":[S,I],eof:V,else:[R,I]},E[H]={'"':[S,I],eof:V,else:[H,I]};const z=/^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;function B(t){if(null==t)return"eof";switch(t.charCodeAt(0)){case 91:case 93:case 46:case 34:case 39:return t;case 95:case 36:case 45:return"ident";case 9:case 10:case 13:case 160:case 65279:case 8232:case 8233:return"ws"}return"ident"}function U(t){const e=t.trim();return("0"!==t.charAt(0)||!isNaN(t))&&(n=e,z.test(n)?function(t){const e=t.charCodeAt(0);return e!==t.charCodeAt(t.length-1)||34!==e&&39!==e?t:t.slice(1,-1)}(e):"*"+e);var n}class J{constructor(){this._cache=Object.create(null)}parsePath(t){let e=this._cache[t];return e||(e=function(t){const e=[];let n,s,r,i,a,o,l,c=-1,h=A,u=0;const m=[];function _(){const e=t[c+1];if(h===R&&"'"===e||h===H&&'"'===e)return c++,r="\\"+e,m[I](),!0}for(m[W]=function(){void 0!==s&&(e.push(s),s=void 0)},m[I]=function(){void 0===s?s=r:s+=r},m[j]=function(){m[I](),u++},m[N]=function(){if(u>0)u--,h=S,m[I]();else{if(u=0,void 0===s)return!1;if(!1===(s=U(s)))return!1;m[W]()}};null!==h;)if("\\"!==(n=t[++c])||!_()){if(i=B(n),(a=(l=E[h])[i]||l.else||V)===V)return;if(h=a[0],(o=m[a[1]])&&(r=void 0===(r=a[2])?n:r,!1===o()))return;if(h===P)return e}}(t))&&(this._cache[t]=e),e||[]}getPathValue(t,e){if(!s(t))return null;const n=this.parsePath(e);if(0===n.length)return null;{const e=n.length;let s=t,r=0;for(;r<e;){const t=s[n[r]];if(void 0===t)return null;s=t,r++}return s}}}const q=/<\/?[\w\s="/.':;#-\/]+>/,G=/(?:@(?:\.[a-z]+)?:(?:[\w\-_|.]+|\([\w\-_|.]+\)))/g,X=/^@(?:\.([a-z]+))?:/,Z=/[()]/g,K={upper:t=>t.toLocaleUpperCase(),lower:t=>t.toLocaleLowerCase(),capitalize:t=>`${t.charAt(0).toLocaleUpperCase()}${t.substr(1)}`},Q=new class{constructor(){this._caches=Object.create(null)}interpolate(t,e){if(!e)return[t];let n=this._caches[t];return n||(n=function(t){const e=[];let n=0,s="";for(;n<t.length;){let r=t[n++];if("{"===r){s&&e.push({type:"text",value:s}),s="";let i="";for(r=t[n++];void 0!==r&&"}"!==r;)i+=r,r=t[n++];const a="}"===r,o=x.test(i)?"list":a&&O.test(i)?"named":"unknown";e.push({value:i,type:o})}else"%"===r?"{"!==t[n]&&(s+=r):s+=r}return s&&e.push({type:"text",value:s}),e}(t),this._caches[t]=n),function(t,e){const n=[];let r=0;const i=Array.isArray(e)?"list":s(e)?"named":"unknown";if("unknown"===i)return n;for(;r<t.length;){const s=t[r];switch(s.type){case"text":n.push(s.value);break;case"list":n.push(e[parseInt(s.value,10)]);break;case"named":"named"===i&&n.push(e[s.value])}r++}return n}(n,e)}};class Y{constructor(t={}){!L&&"undefined"!=typeof window&&window.Vue&&D(window.Vue);const e=t.locale||"en-US",n=!1!==t.fallbackLocale&&(t.fallbackLocale||"en-US"),s=t.messages||{},r=t.dateTimeFormats||{},i=t.numberFormats||{};this._vm=null,this._formatter=t.formatter||Q,this._modifiers=t.modifiers||{},this._missing=t.missing||null,this._root=t.root||null,this._sync=void 0===t.sync||!!t.sync,this._fallbackRoot=void 0===t.fallbackRoot||!!t.fallbackRoot,this._formatFallbackMessages=void 0!==t.formatFallbackMessages&&!!t.formatFallbackMessages,this._silentTranslationWarn=void 0!==t.silentTranslationWarn&&t.silentTranslationWarn,this._silentFallbackWarn=void 0!==t.silentFallbackWarn&&!!t.silentFallbackWarn,this._dateTimeFormatters={},this._numberFormatters={},this._path=new J,this._dataListeners=[],this._preserveDirectiveContent=void 0!==t.preserveDirectiveContent&&!!t.preserveDirectiveContent,this.pluralizationRules=t.pluralizationRules||{},this._warnHtmlInMessage=t.warnHtmlInMessage||"off",this._postTranslation=t.postTranslation||null,this._exist=((t,e)=>!(!t||!e)&&(!l(this._path.getPathValue(t,e))||!!t[e])),"warn"!==this._warnHtmlInMessage&&"error"!==this._warnHtmlInMessage||Object.keys(s).forEach(t=>{this._checkLocaleMessage(t,this._warnHtmlInMessage,s[t])}),this._initVM({locale:e,fallbackLocale:n,messages:s,dateTimeFormats:r,numberFormats:i})}_checkLocaleMessage(t,n,s){const i=(t,n,s,a)=>{if(o(s))Object.keys(s).forEach(e=>{const r=s[e];o(r)?(a.push(e),a.push("."),i(t,n,r,a),a.pop(),a.pop()):(a.push(e),i(t,n,r,a),a.pop())});else if(Array.isArray(s))s.forEach((e,s)=>{o(e)?(a.push(`[${s}]`),a.push("."),i(t,n,e,a),a.pop(),a.pop()):(a.push(`[${s}]`),i(t,n,e,a),a.pop())});else if(r(s)){if(q.test(s)){const r=`Detected HTML in message '${s}' of keypath '${a.join("")}' at '${n}'. Consider component interpolation with '<i18n>' to avoid XSS. See https://bit.ly/2ZqJzkp`;"warn"===t?e(r):"error"===t&&function(t,e){"undefined"!=typeof console&&(console.error("[vue-i18n] "+t),e&&console.error(e.stack))}(r)}}};i(n,t,s,[])}_initVM(t){const e=L.config.silent;L.config.silent=!0,this._vm=new L({data:t}),L.config.silent=e}destroyVM(){this._vm.$destroy()}subscribeDataChanging(t){this._dataListeners.push(t)}unsubscribeDataChanging(t){!function(t,e){if(t.length){const n=t.indexOf(e);if(n>-1)t.splice(n,1)}}(this._dataListeners,t)}watchI18nData(){const t=this;return this._vm.$watch("$data",()=>{let e=t._dataListeners.length;for(;e--;)L.nextTick(()=>{t._dataListeners[e]&&t._dataListeners[e].$forceUpdate()})},{deep:!0})}watchLocale(){if(!this._sync||!this._root)return null;const t=this._vm;return this._root.$i18n.vm.$watch("locale",e=>{t.$set(t,"locale",e),t.$forceUpdate()},{immediate:!0})}get vm(){return this._vm}get messages(){return h(this._getMessages())}get dateTimeFormats(){return h(this._getDateTimeFormats())}get numberFormats(){return h(this._getNumberFormats())}get availableLocales(){return Object.keys(this.messages).sort()}get locale(){return this._vm.locale}set locale(t){this._vm.$set(this._vm,"locale",t)}get fallbackLocale(){return this._vm.fallbackLocale}set fallbackLocale(t){this._localeChainCache={},this._vm.$set(this._vm,"fallbackLocale",t)}get formatFallbackMessages(){return this._formatFallbackMessages}set formatFallbackMessages(t){this._formatFallbackMessages=t}get missing(){return this._missing}set missing(t){this._missing=t}get formatter(){return this._formatter}set formatter(t){this._formatter=t}get silentTranslationWarn(){return this._silentTranslationWarn}set silentTranslationWarn(t){this._silentTranslationWarn=t}get silentFallbackWarn(){return this._silentFallbackWarn}set silentFallbackWarn(t){this._silentFallbackWarn=t}get preserveDirectiveContent(){return this._preserveDirectiveContent}set preserveDirectiveContent(t){this._preserveDirectiveContent=t}get warnHtmlInMessage(){return this._warnHtmlInMessage}set warnHtmlInMessage(t){const e=this._warnHtmlInMessage;if(this._warnHtmlInMessage=t,e!==t&&("warn"===t||"error"===t)){const t=this._getMessages();Object.keys(t).forEach(e=>{this._checkLocaleMessage(e,this._warnHtmlInMessage,t[e])})}}get postTranslation(){return this._postTranslation}set postTranslation(t){this._postTranslation=t}_getMessages(){return this._vm.messages}_getDateTimeFormats(){return this._vm.dateTimeFormats}_getNumberFormats(){return this._vm.numberFormats}_warnDefault(t,e,n,s,i,a){if(!l(n))return n;if(this._missing){const n=this._missing.apply(null,[t,e,s,i]);if(r(n))return n}if(this._formatFallbackMessages){const t=c(...i);return this._render(e,a,t.params,e)}return e}_isFallbackRoot(t){return!t&&!l(this._root)&&this._fallbackRoot}_isSilentFallbackWarn(t){return this._silentFallbackWarn instanceof RegExp?this._silentFallbackWarn.test(t):this._silentFallbackWarn}_isSilentFallback(t,e){return this._isSilentFallbackWarn(e)&&(this._isFallbackRoot()||t!==this.fallbackLocale)}_isSilentTranslationWarn(t){return this._silentTranslationWarn instanceof RegExp?this._silentTranslationWarn.test(t):this._silentTranslationWarn}_interpolate(t,e,n,s,i,a,c){if(!e)return null;const h=this._path.getPathValue(e,n);if(Array.isArray(h)||o(h))return h;let u;if(l(h)){if(!o(e))return null;if(!r(u=e[n]))return null}else{if(!r(h))return null;u=h}return(u.indexOf("@:")>=0||u.indexOf("@.")>=0)&&(u=this._link(t,e,u,s,"raw",a,c)),this._render(u,i,a,n)}_link(t,e,n,s,r,i,a){let o=n;const l=o.match(G);for(let n in l){if(!l.hasOwnProperty(n))continue;const c=l[n],h=c.match(X),[m,_]=h,f=c.replace(m,"").replace(Z,"");if(u(a,f))return o;a.push(f);let g=this._interpolate(t,e,f,s,"raw"===r?"string":r,"raw"===r?void 0:i,a);if(this._isFallbackRoot(g)){if(!this._root)throw Error("unexpected error");const t=this._root.$i18n;g=t._translate(t._getMessages(),t.locale,t.fallbackLocale,f,s,r,i)}g=this._warnDefault(t,f,g,s,Array.isArray(i)?i:[i],r),this._modifiers.hasOwnProperty(_)?g=this._modifiers[_](g):K.hasOwnProperty(_)&&(g=K[_](g)),a.pop(),o=g?o.replace(c,g):o}return o}_render(t,e,n,s){let i=this._formatter.interpolate(t,n,s);return i||(i=Q.interpolate(t,n,s)),"string"!==e||r(i)?i:i.join("")}_appendItemToChain(t,e,n){let s=!1;return u(t,e)||(s=!0,e&&(s="!"!==e[e.length-1],e=e.replace(/!/g,""),t.push(e),n&&n[e]&&(s=n[e]))),s}_appendLocaleToChain(t,e,n){let s;const r=e.split("-");do{const e=r.join("-");s=this._appendItemToChain(t,e,n),r.splice(-1,1)}while(r.length&&!0===s);return s}_appendBlockToChain(t,e,n){let s=!0;for(let i=0;i<e.length&&"boolean"==typeof s;i++){const a=e[i];r(a)&&(s=this._appendLocaleToChain(t,a,n))}return s}_getLocaleChain(t,e){if(""===t)return[];this._localeChainCache||(this._localeChainCache={});let i=this._localeChainCache[t];if(!i){e||(e=this.fallbackLocale),i=[];let a,o=[t];for(;n(o);)o=this._appendBlockToChain(i,o,e);(o=r(a=n(e)?e:s(e)?e.default?e.default:null:e)?[a]:a)&&this._appendBlockToChain(i,o,null),this._localeChainCache[t]=i}return i}_translate(t,e,n,s,r,i,a){const o=this._getLocaleChain(e,n);let c;for(let e=0;e<o.length;e++){const n=o[e];if(!l(c=this._interpolate(n,t[n],s,r,i,a,[s])))return c}return null}_t(t,e,n,s,...r){if(!t)return"";const i=c(...r),a=i.locale||e;let o=this._translate(n,a,this.fallbackLocale,t,s,"string",i.params);if(this._isFallbackRoot(o)){if(!this._root)throw Error("unexpected error");return this._root.$t(t,...r)}return o=this._warnDefault(a,t,o,s,r,"string"),this._postTranslation&&null!=o&&(o=this._postTranslation(o,t)),o}t(t,...e){return this._t(t,this.locale,this._getMessages(),null,...e)}_i(t,e,n,s,r){const i=this._translate(n,e,this.fallbackLocale,t,s,"raw",r);if(this._isFallbackRoot(i)){if(!this._root)throw Error("unexpected error");return this._root.$i18n.i(t,e,r)}return this._warnDefault(e,t,i,s,[r],"raw")}i(t,e,n){return t?(r(e)||(e=this.locale),this._i(t,e,this._getMessages(),null,n)):""}_tc(t,e,n,s,r,...i){if(!t)return"";void 0===r&&(r=1);const a={count:r,n:r},o=c(...i);return o.params=Object.assign(a,o.params),i=null===o.locale?[o.params]:[o.locale,o.params],this.fetchChoice(this._t(t,e,n,s,...i),r)}fetchChoice(t,e){if(!t&&!r(t))return null;const n=t.split("|");return n[e=this.getChoiceIndex(e,n.length)]?n[e].trim():t}getChoiceIndex(t,e){return this.locale in this.pluralizationRules?this.pluralizationRules[this.locale].apply(this,[t,e]):((t,e)=>(t=Math.abs(t),2===e?t?t>1?1:0:1:t?Math.min(t,2):0))(t,e)}tc(t,e,...n){return this._tc(t,this.locale,this._getMessages(),null,e,...n)}_te(t,e,n,...s){const r=c(...s).locale||e;return this._exist(n[r],t)}te(t,e){return this._te(t,this.locale,this._getMessages(),e)}getLocaleMessage(t){return h(this._vm.messages[t]||{})}setLocaleMessage(t,e){"warn"!==this._warnHtmlInMessage&&"error"!==this._warnHtmlInMessage||this._checkLocaleMessage(t,this._warnHtmlInMessage,e),this._vm.$set(this._vm.messages,t,e)}mergeLocaleMessage(t,e){"warn"!==this._warnHtmlInMessage&&"error"!==this._warnHtmlInMessage||this._checkLocaleMessage(t,this._warnHtmlInMessage,e),this._vm.$set(this._vm.messages,t,f({},this._vm.messages[t]||{},e))}getDateTimeFormat(t){return h(this._vm.dateTimeFormats[t]||{})}setDateTimeFormat(t,e){this._vm.$set(this._vm.dateTimeFormats,t,e),this._clearDateTimeFormat(t,e)}mergeDateTimeFormat(t,e){this._vm.$set(this._vm.dateTimeFormats,t,f(this._vm.dateTimeFormats[t]||{},e)),this._clearDateTimeFormat(t,e)}_clearDateTimeFormat(t,e){for(let n in e){const e=`${t}__${n}`;this._dateTimeFormatters.hasOwnProperty(e)&&delete this._dateTimeFormatters[e]}}_localizeDateTime(t,e,n,s,r){let i=e,a=s[i];const o=this._getLocaleChain(e,n);for(let t=0;t<o.length;t++){const e=o[t];if(i=e,!l(a=s[e])&&!l(a[r]))break}if(l(a)||l(a[r]))return null;{const e=a[r],n=`${i}__${r}`;let s=this._dateTimeFormatters[n];return s||(s=this._dateTimeFormatters[n]=new Intl.DateTimeFormat(i,e)),s.format(t)}}_d(t,e,n){if(!n)return new Intl.DateTimeFormat(e).format(t);const s=this._localizeDateTime(t,e,this.fallbackLocale,this._getDateTimeFormats(),n);if(this._isFallbackRoot(s)){if(!this._root)throw Error("unexpected error");return this._root.$i18n.d(t,n,e)}return s||""}d(t,...e){let n=this.locale,i=null;return 1===e.length?r(e[0])?i=e[0]:s(e[0])&&(e[0].locale&&(n=e[0].locale),e[0].key&&(i=e[0].key)):2===e.length&&(r(e[0])&&(i=e[0]),r(e[1])&&(n=e[1])),this._d(t,n,i)}getNumberFormat(t){return h(this._vm.numberFormats[t]||{})}setNumberFormat(t,e){this._vm.$set(this._vm.numberFormats,t,e),this._clearNumberFormat(t,e)}mergeNumberFormat(t,e){this._vm.$set(this._vm.numberFormats,t,f(this._vm.numberFormats[t]||{},e)),this._clearNumberFormat(t,e)}_clearNumberFormat(t,e){for(let n in e){const e=`${t}__${n}`;this._numberFormatters.hasOwnProperty(e)&&delete this._numberFormatters[e]}}_getNumberFormatter(t,e,n,s,r,i){let a=e,o=s[a];const c=this._getLocaleChain(e,n);for(let t=0;t<c.length;t++){const e=c[t];if(a=e,!l(o=s[e])&&!l(o[r]))break}if(l(o)||l(o[r]))return null;{const t=o[r];let e;if(i)e=new Intl.NumberFormat(a,Object.assign({},t,i));else{const n=`${a}__${r}`;(e=this._numberFormatters[n])||(e=this._numberFormatters[n]=new Intl.NumberFormat(a,t))}return e}}_n(t,e,n,s){if(!Y.availabilities.numberFormat)return"";if(!n){return(s?new Intl.NumberFormat(e,s):new Intl.NumberFormat(e)).format(t)}const r=this._getNumberFormatter(t,e,this.fallbackLocale,this._getNumberFormats(),n,s),i=r&&r.format(t);if(this._isFallbackRoot(i)){if(!this._root)throw Error("unexpected error");return this._root.$i18n.n(t,Object.assign({},{key:n,locale:e},s))}return i||""}n(e,...n){let i=this.locale,a=null,o=null;return 1===n.length?r(n[0])?a=n[0]:s(n[0])&&(n[0].locale&&(i=n[0].locale),n[0].key&&(a=n[0].key),o=Object.keys(n[0]).reduce((e,s)=>u(t,s)?Object.assign({},e,{[s]:n[0][s]}):e,null)):2===n.length&&(r(n[0])&&(a=n[0]),r(n[1])&&(i=n[1])),this._n(e,i,a,o)}_ntp(t,e,n,s){if(!Y.availabilities.numberFormat)return[];if(!n){return(s?new Intl.NumberFormat(e,s):new Intl.NumberFormat(e)).formatToParts(t)}const r=this._getNumberFormatter(t,e,this.fallbackLocale,this._getNumberFormats(),n,s),i=r&&r.formatToParts(t);if(this._isFallbackRoot(i)){if(!this._root)throw Error("unexpected error");return this._root.$i18n._ntp(t,e,n,s)}return i||[]}}let tt;Object.defineProperty(Y,"availabilities",{get(){if(!tt){const t="undefined"!=typeof Intl;tt={dateTimeFormat:t&&void 0!==Intl.DateTimeFormat,numberFormat:t&&void 0!==Intl.NumberFormat}}return tt}}),Y.install=D,Y.version="8.17.6";export default Y;
|
|
1
|
+
const t=["style","currency","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits","localeMatcher","formatMatcher","unit"];function e(t,e){"undefined"!=typeof console&&(console.warn("[vue-i18n] "+t),e&&console.warn(e.stack))}const n=Array.isArray;function s(t){return null!==t&&"object"==typeof t}function r(t){return"string"==typeof t}const a=Object.prototype.toString,i="[object Object]";function o(t){return a.call(t)===i}function l(t){return null==t}function c(...t){let e=null,n=null;return 1===t.length?s(t[0])||Array.isArray(t[0])?n=t[0]:"string"==typeof t[0]&&(e=t[0]):2===t.length&&("string"==typeof t[0]&&(e=t[0]),(s(t[1])||Array.isArray(t[1]))&&(n=t[1])),{locale:e,params:n}}function h(t){return JSON.parse(JSON.stringify(t))}function u(t,e){return!!~t.indexOf(e)}const m=Object.prototype.hasOwnProperty;function _(t,e){return m.call(t,e)}function f(t){const e=Object(t);for(let t=1;t<arguments.length;t++){const n=arguments[t];if(null!=n){let t;for(t in n)_(n,t)&&(s(n[t])?e[t]=f(e[t],n[t]):e[t]=n[t])}}return e}function p(t,e){if(t===e)return!0;const n=s(t),r=s(e);if(!n||!r)return!n&&!r&&String(t)===String(e);try{const n=Array.isArray(t),s=Array.isArray(e);if(n&&s)return t.length===e.length&&t.every((t,n)=>p(t,e[n]));if(n||s)return!1;{const n=Object.keys(t),s=Object.keys(e);return n.length===s.length&&n.every(n=>p(t[n],e[n]))}}catch(t){return!1}}var g={beforeCreate(){const t=this.$options;if(t.i18n=t.i18n||(t.__i18n?{}:null),t.i18n){if(t.i18n instanceof Y){if(t.__i18n)try{let e={};t.__i18n.forEach(t=>{e=f(e,JSON.parse(t))}),Object.keys(e).forEach(n=>{t.i18n.mergeLocaleMessage(n,e[n])})}catch(t){}this._i18n=t.i18n,this._i18nWatcher=this._i18n.watchI18nData()}else if(o(t.i18n)){const e=this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof Y?this.$root.$i18n:null;if(e&&(t.i18n.root=this.$root,t.i18n.formatter=e.formatter,t.i18n.fallbackLocale=e.fallbackLocale,t.i18n.formatFallbackMessages=e.formatFallbackMessages,t.i18n.silentTranslationWarn=e.silentTranslationWarn,t.i18n.silentFallbackWarn=e.silentFallbackWarn,t.i18n.pluralizationRules=e.pluralizationRules,t.i18n.preserveDirectiveContent=e.preserveDirectiveContent),t.__i18n)try{let e={};t.__i18n.forEach(t=>{e=f(e,JSON.parse(t))}),t.i18n.messages=e}catch(t){}const{sharedMessages:n}=t.i18n;n&&o(n)&&(t.i18n.messages=f(t.i18n.messages,n)),this._i18n=new Y(t.i18n),this._i18nWatcher=this._i18n.watchI18nData(),(void 0===t.i18n.sync||t.i18n.sync)&&(this._localeWatcher=this.$i18n.watchLocale()),e&&e.onComponentInstanceCreated(this._i18n)}}else this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof Y?this._i18n=this.$root.$i18n:t.parent&&t.parent.$i18n&&t.parent.$i18n instanceof Y&&(this._i18n=t.parent.$i18n)},beforeMount(){const t=this.$options;t.i18n=t.i18n||(t.__i18n?{}:null),t.i18n?t.i18n instanceof Y?(this._i18n.subscribeDataChanging(this),this._subscribing=!0):o(t.i18n)&&(this._i18n.subscribeDataChanging(this),this._subscribing=!0):this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof Y?(this._i18n.subscribeDataChanging(this),this._subscribing=!0):t.parent&&t.parent.$i18n&&t.parent.$i18n instanceof Y&&(this._i18n.subscribeDataChanging(this),this._subscribing=!0)},beforeDestroy(){if(!this._i18n)return;const t=this;this.$nextTick(()=>{t._subscribing&&(t._i18n.unsubscribeDataChanging(t),delete t._subscribing),t._i18nWatcher&&(t._i18nWatcher(),t._i18n.destroyVM(),delete t._i18nWatcher),t._localeWatcher&&(t._localeWatcher(),delete t._localeWatcher)})}},d={name:"i18n",functional:!0,props:{tag:{type:[String,Boolean],default:"span"},path:{type:String,required:!0},locale:{type:String},places:{type:[Array,Object]}},render(t,{data:e,parent:n,props:s,slots:r}){const{$i18n:a}=n;if(!a)return;const{path:i,locale:o,places:l}=s,c=r(),h=a.i(i,o,function(t){let e;for(e in t)if("default"!==e)return!1;return Boolean(e)}(c)||l?function(t,e){const n=e?function(t){return Array.isArray(t)?t.reduce(v,{}):Object.assign({},t)}(e):{};if(!t)return n;const s=(t=t.filter(t=>t.tag||""!==t.text.trim())).every(y);return t.reduce(s?b:v,n)}(c.default,l):c),u=s.tag&&!0!==s.tag||!1===s.tag?s.tag:"span";return u?t(u,e,h):h}};function b(t,e){return e.data&&e.data.attrs&&e.data.attrs.place&&(t[e.data.attrs.place]=e),t}function v(t,e,n){return t[n]=e,t}function y(t){return Boolean(t.data&&t.data.attrs&&t.data.attrs.place)}var F={name:"i18n-n",functional:!0,props:{tag:{type:[String,Boolean],default:"span"},value:{type:Number,required:!0},format:{type:[String,Object]},locale:{type:String}},render(e,{props:n,parent:a,data:i}){const o=a.$i18n;if(!o)return null;let l=null,c=null;r(n.format)?l=n.format:s(n.format)&&(n.format.key&&(l=n.format.key),c=Object.keys(n.format).reduce((e,s)=>u(t,s)?Object.assign({},e,{[s]:n.format[s]}):e,null));const h=n.locale||o.locale,m=o._ntp(n.value,h,l,c),_=m.map((t,e)=>{const n=i.scopedSlots&&i.scopedSlots[t.type];return n?n({[t.type]:t.value,index:e,parts:m}):t.value}),f=n.tag&&!0!==n.tag||!1===n.tag?n.tag:"span";return f?e(f,{attrs:i.attrs,class:i.class,staticClass:i.staticClass},_):_}};function k(t,e,n){M(t,n)&&C(t,e,n)}function $(t,e,n,s){if(!M(t,n))return;const r=n.context.$i18n;(function(t,e){const n=e.context;return t._locale===n.$i18n.locale})(t,n)&&p(e.value,e.oldValue)&&p(t._localeMessage,r.getLocaleMessage(r.locale))||C(t,e,n)}function w(t,n,s,r){if(!s.context)return void e("Vue instance does not exists in VNode context");const a=s.context.$i18n||{};n.modifiers.preserve||a.preserveDirectiveContent||(t.textContent=""),t._vt=void 0,delete t._vt,t._locale=void 0,delete t._locale,t._localeMessage=void 0,delete t._localeMessage}function M(t,n){const s=n.context;return s?!!s.$i18n||(e("VueI18n instance does not exists in Vue instance"),!1):(e("Vue instance does not exists in VNode context"),!1)}function C(t,n,s){const a=n.value,{path:i,locale:l,args:c,choice:h}=function(t){let e,n,s,a;r(t)?e=t:o(t)&&(e=t.path,n=t.locale,s=t.args,a=t.choice);return{path:e,locale:n,args:s,choice:a}}(a);if(!i&&!l&&!c)return void e("value type not supported");if(!i)return void e("`path` is required in v-t directive");const u=s.context;t._vt=t.textContent=null!=h?u.$i18n.tc(i,h,...T(l,c)):u.$i18n.t(i,...T(l,c)),t._locale=u.$i18n.locale,t._localeMessage=u.$i18n.getLocaleMessage(u.$i18n.locale)}function T(t,e){const n=[];return t&&n.push(t),e&&(Array.isArray(e)||o(e))&&n.push(e),n}let L;function D(t){D.installed=!0;(L=t).version&&Number(L.version.split(".")[0]);!function(t){t.prototype.hasOwnProperty("$i18n")||Object.defineProperty(t.prototype,"$i18n",{get(){return this._i18n}}),t.prototype.$t=function(t,...e){const n=this.$i18n;return n._t(t,n.locale,n._getMessages(),this,...e)},t.prototype.$tc=function(t,e,...n){const s=this.$i18n;return s._tc(t,s.locale,s._getMessages(),this,e,...n)},t.prototype.$te=function(t,e){const n=this.$i18n;return n._te(t,n.locale,n._getMessages(),e)},t.prototype.$d=function(t,...e){return this.$i18n.d(t,...e)},t.prototype.$n=function(t,...e){return this.$i18n.n(t,...e)}}(L),L.mixin(g),L.directive("t",{bind:k,update:$,unbind:w}),L.component(d.name,d),L.component(F.name,F),L.config.optionMergeStrategies.i18n=function(t,e){return void 0===e?t:e}}const I=/^(?:\d)+/,x=/^(?:\w)+/;const O=0,W=1,j=2,N=3,A=0,S=4,R=5,H=6,P=7,V=8,E=[];E[A]={ws:[A],ident:[3,O],"[":[S],eof:[P]},E[1]={ws:[1],".":[2],"[":[S],eof:[P]},E[2]={ws:[2],ident:[3,O],0:[3,O],number:[3,O]},E[3]={ident:[3,O],0:[3,O],number:[3,O],ws:[1,W],".":[2,W],"[":[S,W],eof:[P,W]},E[S]={"'":[R,O],'"':[H,O],"[":[S,j],"]":[1,N],eof:V,else:[S,O]},E[R]={"'":[S,O],eof:V,else:[R,O]},E[H]={'"':[S,O],eof:V,else:[H,O]};const z=/^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;function B(t){if(null==t)return"eof";switch(t.charCodeAt(0)){case 91:case 93:case 46:case 34:case 39:return t;case 95:case 36:case 45:return"ident";case 9:case 10:case 13:case 160:case 65279:case 8232:case 8233:return"ws"}return"ident"}function U(t){const e=t.trim();return("0"!==t.charAt(0)||!isNaN(t))&&(n=e,z.test(n)?function(t){const e=t.charCodeAt(0);return e!==t.charCodeAt(t.length-1)||34!==e&&39!==e?t:t.slice(1,-1)}(e):"*"+e);var n}class J{constructor(){this._cache=Object.create(null)}parsePath(t){let e=this._cache[t];return e||(e=function(t){const e=[];let n,s,r,a,i,o,l,c=-1,h=A,u=0;const m=[];function _(){const e=t[c+1];if(h===R&&"'"===e||h===H&&'"'===e)return c++,r="\\"+e,m[O](),!0}for(m[W]=function(){void 0!==s&&(e.push(s),s=void 0)},m[O]=function(){void 0===s?s=r:s+=r},m[j]=function(){m[O](),u++},m[N]=function(){if(u>0)u--,h=S,m[O]();else{if(u=0,void 0===s)return!1;if(!1===(s=U(s)))return!1;m[W]()}};null!==h;)if("\\"!==(n=t[++c])||!_()){if(a=B(n),(i=(l=E[h])[a]||l.else||V)===V)return;if(h=i[0],(o=m[i[1]])&&(r=void 0===(r=i[2])?n:r,!1===o()))return;if(h===P)return e}}(t))&&(this._cache[t]=e),e||[]}getPathValue(t,e){if(!s(t))return null;const n=this.parsePath(e);if(0===n.length)return null;{const e=n.length;let s=t,r=0;for(;r<e;){const t=s[n[r]];if(void 0===t)return null;s=t,r++}return s}}}const q=/<\/?[\w\s="/.':;#-\/]+>/,G=/(?:@(?:\.[a-z]+)?:(?:[\w\-_|.]+|\([\w\-_|.]+\)))/g,X=/^@(?:\.([a-z]+))?:/,Z=/[()]/g,K={upper:t=>t.toLocaleUpperCase(),lower:t=>t.toLocaleLowerCase(),capitalize:t=>`${t.charAt(0).toLocaleUpperCase()}${t.substr(1)}`},Q=new class{constructor(){this._caches=Object.create(null)}interpolate(t,e){if(!e)return[t];let n=this._caches[t];return n||(n=function(t){const e=[];let n=0,s="";for(;n<t.length;){let r=t[n++];if("{"===r){s&&e.push({type:"text",value:s}),s="";let a="";for(r=t[n++];void 0!==r&&"}"!==r;)a+=r,r=t[n++];const i="}"===r,o=I.test(a)?"list":i&&x.test(a)?"named":"unknown";e.push({value:a,type:o})}else"%"===r?"{"!==t[n]&&(s+=r):s+=r}return s&&e.push({type:"text",value:s}),e}(t),this._caches[t]=n),function(t,e){const n=[];let r=0;const a=Array.isArray(e)?"list":s(e)?"named":"unknown";if("unknown"===a)return n;for(;r<t.length;){const s=t[r];switch(s.type){case"text":n.push(s.value);break;case"list":n.push(e[parseInt(s.value,10)]);break;case"named":"named"===a&&n.push(e[s.value])}r++}return n}(n,e)}};class Y{constructor(t={}){!L&&"undefined"!=typeof window&&window.Vue&&D(window.Vue);const e=t.locale||"en-US",n=!1!==t.fallbackLocale&&(t.fallbackLocale||"en-US"),s=t.messages||{},r=t.dateTimeFormats||{},a=t.numberFormats||{};this._vm=null,this._formatter=t.formatter||Q,this._modifiers=t.modifiers||{},this._missing=t.missing||null,this._root=t.root||null,this._sync=void 0===t.sync||!!t.sync,this._fallbackRoot=void 0===t.fallbackRoot||!!t.fallbackRoot,this._formatFallbackMessages=void 0!==t.formatFallbackMessages&&!!t.formatFallbackMessages,this._silentTranslationWarn=void 0!==t.silentTranslationWarn&&t.silentTranslationWarn,this._silentFallbackWarn=void 0!==t.silentFallbackWarn&&!!t.silentFallbackWarn,this._dateTimeFormatters={},this._numberFormatters={},this._path=new J,this._dataListeners=[],this._componentInstanceCreatedListener=t.componentInstanceCreatedListener||null,this._preserveDirectiveContent=void 0!==t.preserveDirectiveContent&&!!t.preserveDirectiveContent,this.pluralizationRules=t.pluralizationRules||{},this._warnHtmlInMessage=t.warnHtmlInMessage||"off",this._postTranslation=t.postTranslation||null,this.getChoiceIndex=((t,e)=>{const n=Object.getPrototypeOf(this);if(n&&n.getChoiceIndex){return n.getChoiceIndex.call(this,t,e)}return this.locale in this.pluralizationRules?this.pluralizationRules[this.locale].apply(this,[t,e]):((t,e)=>(t=Math.abs(t),2===e?t?t>1?1:0:1:t?Math.min(t,2):0))(t,e)}),this._exist=((t,e)=>!(!t||!e)&&(!l(this._path.getPathValue(t,e))||!!t[e])),"warn"!==this._warnHtmlInMessage&&"error"!==this._warnHtmlInMessage||Object.keys(s).forEach(t=>{this._checkLocaleMessage(t,this._warnHtmlInMessage,s[t])}),this._initVM({locale:e,fallbackLocale:n,messages:s,dateTimeFormats:r,numberFormats:a})}_checkLocaleMessage(t,n,s){const a=(t,n,s,i)=>{if(o(s))Object.keys(s).forEach(e=>{const r=s[e];o(r)?(i.push(e),i.push("."),a(t,n,r,i),i.pop(),i.pop()):(i.push(e),a(t,n,r,i),i.pop())});else if(Array.isArray(s))s.forEach((e,s)=>{o(e)?(i.push(`[${s}]`),i.push("."),a(t,n,e,i),i.pop(),i.pop()):(i.push(`[${s}]`),a(t,n,e,i),i.pop())});else if(r(s)){if(q.test(s)){const r=`Detected HTML in message '${s}' of keypath '${i.join("")}' at '${n}'. Consider component interpolation with '<i18n>' to avoid XSS. See https://bit.ly/2ZqJzkp`;"warn"===t?e(r):"error"===t&&function(t,e){"undefined"!=typeof console&&(console.error("[vue-i18n] "+t),e&&console.error(e.stack))}(r)}}};a(n,t,s,[])}_initVM(t){const e=L.config.silent;L.config.silent=!0,this._vm=new L({data:t}),L.config.silent=e}destroyVM(){this._vm.$destroy()}subscribeDataChanging(t){this._dataListeners.push(t)}unsubscribeDataChanging(t){!function(t,e){if(t.length){const n=t.indexOf(e);if(n>-1)t.splice(n,1)}}(this._dataListeners,t)}watchI18nData(){const t=this;return this._vm.$watch("$data",()=>{let e=t._dataListeners.length;for(;e--;)L.nextTick(()=>{t._dataListeners[e]&&t._dataListeners[e].$forceUpdate()})},{deep:!0})}watchLocale(){if(!this._sync||!this._root)return null;const t=this._vm;return this._root.$i18n.vm.$watch("locale",e=>{t.$set(t,"locale",e),t.$forceUpdate()},{immediate:!0})}onComponentInstanceCreated(t){this._componentInstanceCreatedListener&&this._componentInstanceCreatedListener(t,this)}get vm(){return this._vm}get messages(){return h(this._getMessages())}get dateTimeFormats(){return h(this._getDateTimeFormats())}get numberFormats(){return h(this._getNumberFormats())}get availableLocales(){return Object.keys(this.messages).sort()}get locale(){return this._vm.locale}set locale(t){this._vm.$set(this._vm,"locale",t)}get fallbackLocale(){return this._vm.fallbackLocale}set fallbackLocale(t){this._localeChainCache={},this._vm.$set(this._vm,"fallbackLocale",t)}get formatFallbackMessages(){return this._formatFallbackMessages}set formatFallbackMessages(t){this._formatFallbackMessages=t}get missing(){return this._missing}set missing(t){this._missing=t}get formatter(){return this._formatter}set formatter(t){this._formatter=t}get silentTranslationWarn(){return this._silentTranslationWarn}set silentTranslationWarn(t){this._silentTranslationWarn=t}get silentFallbackWarn(){return this._silentFallbackWarn}set silentFallbackWarn(t){this._silentFallbackWarn=t}get preserveDirectiveContent(){return this._preserveDirectiveContent}set preserveDirectiveContent(t){this._preserveDirectiveContent=t}get warnHtmlInMessage(){return this._warnHtmlInMessage}set warnHtmlInMessage(t){const e=this._warnHtmlInMessage;if(this._warnHtmlInMessage=t,e!==t&&("warn"===t||"error"===t)){const t=this._getMessages();Object.keys(t).forEach(e=>{this._checkLocaleMessage(e,this._warnHtmlInMessage,t[e])})}}get postTranslation(){return this._postTranslation}set postTranslation(t){this._postTranslation=t}_getMessages(){return this._vm.messages}_getDateTimeFormats(){return this._vm.dateTimeFormats}_getNumberFormats(){return this._vm.numberFormats}_warnDefault(t,e,n,s,a,i){if(!l(n))return n;if(this._missing){const n=this._missing.apply(null,[t,e,s,a]);if(r(n))return n}if(this._formatFallbackMessages){const t=c(...a);return this._render(e,i,t.params,e)}return e}_isFallbackRoot(t){return!t&&!l(this._root)&&this._fallbackRoot}_isSilentFallbackWarn(t){return this._silentFallbackWarn instanceof RegExp?this._silentFallbackWarn.test(t):this._silentFallbackWarn}_isSilentFallback(t,e){return this._isSilentFallbackWarn(e)&&(this._isFallbackRoot()||t!==this.fallbackLocale)}_isSilentTranslationWarn(t){return this._silentTranslationWarn instanceof RegExp?this._silentTranslationWarn.test(t):this._silentTranslationWarn}_interpolate(t,e,n,s,a,i,c){if(!e)return null;const h=this._path.getPathValue(e,n);if(Array.isArray(h)||o(h))return h;let u;if(l(h)){if(!o(e))return null;if(!r(u=e[n]))return null}else{if(!r(h))return null;u=h}return(u.indexOf("@:")>=0||u.indexOf("@.")>=0)&&(u=this._link(t,e,u,s,"raw",i,c)),this._render(u,a,i,n)}_link(t,e,n,s,r,a,i){let o=n;const l=o.match(G);for(let n in l){if(!l.hasOwnProperty(n))continue;const c=l[n],h=c.match(X),[m,_]=h,f=c.replace(m,"").replace(Z,"");if(u(i,f))return o;i.push(f);let p=this._interpolate(t,e,f,s,"raw"===r?"string":r,"raw"===r?void 0:a,i);if(this._isFallbackRoot(p)){if(!this._root)throw Error("unexpected error");const t=this._root.$i18n;p=t._translate(t._getMessages(),t.locale,t.fallbackLocale,f,s,r,a)}p=this._warnDefault(t,f,p,s,Array.isArray(a)?a:[a],r),this._modifiers.hasOwnProperty(_)?p=this._modifiers[_](p):K.hasOwnProperty(_)&&(p=K[_](p)),i.pop(),o=p?o.replace(c,p):o}return o}_render(t,e,n,s){let a=this._formatter.interpolate(t,n,s);return a||(a=Q.interpolate(t,n,s)),"string"!==e||r(a)?a:a.join("")}_appendItemToChain(t,e,n){let s=!1;return u(t,e)||(s=!0,e&&(s="!"!==e[e.length-1],e=e.replace(/!/g,""),t.push(e),n&&n[e]&&(s=n[e]))),s}_appendLocaleToChain(t,e,n){let s;const r=e.split("-");do{const e=r.join("-");s=this._appendItemToChain(t,e,n),r.splice(-1,1)}while(r.length&&!0===s);return s}_appendBlockToChain(t,e,n){let s=!0;for(let a=0;a<e.length&&"boolean"==typeof s;a++){const i=e[a];r(i)&&(s=this._appendLocaleToChain(t,i,n))}return s}_getLocaleChain(t,e){if(""===t)return[];this._localeChainCache||(this._localeChainCache={});let a=this._localeChainCache[t];if(!a){e||(e=this.fallbackLocale),a=[];let i,o=[t];for(;n(o);)o=this._appendBlockToChain(a,o,e);(o=r(i=n(e)?e:s(e)?e.default?e.default:null:e)?[i]:i)&&this._appendBlockToChain(a,o,null),this._localeChainCache[t]=a}return a}_translate(t,e,n,s,r,a,i){const o=this._getLocaleChain(e,n);let c;for(let e=0;e<o.length;e++){const n=o[e];if(!l(c=this._interpolate(n,t[n],s,r,a,i,[s])))return c}return null}_t(t,e,n,s,...r){if(!t)return"";const a=c(...r),i=a.locale||e;let o=this._translate(n,i,this.fallbackLocale,t,s,"string",a.params);if(this._isFallbackRoot(o)){if(!this._root)throw Error("unexpected error");return this._root.$t(t,...r)}return o=this._warnDefault(i,t,o,s,r,"string"),this._postTranslation&&null!=o&&(o=this._postTranslation(o,t)),o}t(t,...e){return this._t(t,this.locale,this._getMessages(),null,...e)}_i(t,e,n,s,r){const a=this._translate(n,e,this.fallbackLocale,t,s,"raw",r);if(this._isFallbackRoot(a)){if(!this._root)throw Error("unexpected error");return this._root.$i18n.i(t,e,r)}return this._warnDefault(e,t,a,s,[r],"raw")}i(t,e,n){return t?(r(e)||(e=this.locale),this._i(t,e,this._getMessages(),null,n)):""}_tc(t,e,n,s,r,...a){if(!t)return"";void 0===r&&(r=1);const i={count:r,n:r},o=c(...a);return o.params=Object.assign(i,o.params),a=null===o.locale?[o.params]:[o.locale,o.params],this.fetchChoice(this._t(t,e,n,s,...a),r)}fetchChoice(t,e){if(!t&&!r(t))return null;const n=t.split("|");return n[e=this.getChoiceIndex(e,n.length)]?n[e].trim():t}tc(t,e,...n){return this._tc(t,this.locale,this._getMessages(),null,e,...n)}_te(t,e,n,...s){const r=c(...s).locale||e;return this._exist(n[r],t)}te(t,e){return this._te(t,this.locale,this._getMessages(),e)}getLocaleMessage(t){return h(this._vm.messages[t]||{})}setLocaleMessage(t,e){"warn"!==this._warnHtmlInMessage&&"error"!==this._warnHtmlInMessage||this._checkLocaleMessage(t,this._warnHtmlInMessage,e),this._vm.$set(this._vm.messages,t,e)}mergeLocaleMessage(t,e){"warn"!==this._warnHtmlInMessage&&"error"!==this._warnHtmlInMessage||this._checkLocaleMessage(t,this._warnHtmlInMessage,e),this._vm.$set(this._vm.messages,t,f({},this._vm.messages[t]||{},e))}getDateTimeFormat(t){return h(this._vm.dateTimeFormats[t]||{})}setDateTimeFormat(t,e){this._vm.$set(this._vm.dateTimeFormats,t,e),this._clearDateTimeFormat(t,e)}mergeDateTimeFormat(t,e){this._vm.$set(this._vm.dateTimeFormats,t,f(this._vm.dateTimeFormats[t]||{},e)),this._clearDateTimeFormat(t,e)}_clearDateTimeFormat(t,e){for(let n in e){const e=`${t}__${n}`;this._dateTimeFormatters.hasOwnProperty(e)&&delete this._dateTimeFormatters[e]}}_localizeDateTime(t,e,n,s,r){let a=e,i=s[a];const o=this._getLocaleChain(e,n);for(let t=0;t<o.length;t++){const e=o[t];if(a=e,!l(i=s[e])&&!l(i[r]))break}if(l(i)||l(i[r]))return null;{const e=i[r],n=`${a}__${r}`;let s=this._dateTimeFormatters[n];return s||(s=this._dateTimeFormatters[n]=new Intl.DateTimeFormat(a,e)),s.format(t)}}_d(t,e,n){if(!n)return new Intl.DateTimeFormat(e).format(t);const s=this._localizeDateTime(t,e,this.fallbackLocale,this._getDateTimeFormats(),n);if(this._isFallbackRoot(s)){if(!this._root)throw Error("unexpected error");return this._root.$i18n.d(t,n,e)}return s||""}d(t,...e){let n=this.locale,a=null;return 1===e.length?r(e[0])?a=e[0]:s(e[0])&&(e[0].locale&&(n=e[0].locale),e[0].key&&(a=e[0].key)):2===e.length&&(r(e[0])&&(a=e[0]),r(e[1])&&(n=e[1])),this._d(t,n,a)}getNumberFormat(t){return h(this._vm.numberFormats[t]||{})}setNumberFormat(t,e){this._vm.$set(this._vm.numberFormats,t,e),this._clearNumberFormat(t,e)}mergeNumberFormat(t,e){this._vm.$set(this._vm.numberFormats,t,f(this._vm.numberFormats[t]||{},e)),this._clearNumberFormat(t,e)}_clearNumberFormat(t,e){for(let n in e){const e=`${t}__${n}`;this._numberFormatters.hasOwnProperty(e)&&delete this._numberFormatters[e]}}_getNumberFormatter(t,e,n,s,r,a){let i=e,o=s[i];const c=this._getLocaleChain(e,n);for(let t=0;t<c.length;t++){const e=c[t];if(i=e,!l(o=s[e])&&!l(o[r]))break}if(l(o)||l(o[r]))return null;{const t=o[r];let e;if(a)e=new Intl.NumberFormat(i,Object.assign({},t,a));else{const n=`${i}__${r}`;(e=this._numberFormatters[n])||(e=this._numberFormatters[n]=new Intl.NumberFormat(i,t))}return e}}_n(t,e,n,s){if(!Y.availabilities.numberFormat)return"";if(!n){return(s?new Intl.NumberFormat(e,s):new Intl.NumberFormat(e)).format(t)}const r=this._getNumberFormatter(t,e,this.fallbackLocale,this._getNumberFormats(),n,s),a=r&&r.format(t);if(this._isFallbackRoot(a)){if(!this._root)throw Error("unexpected error");return this._root.$i18n.n(t,Object.assign({},{key:n,locale:e},s))}return a||""}n(e,...n){let a=this.locale,i=null,o=null;return 1===n.length?r(n[0])?i=n[0]:s(n[0])&&(n[0].locale&&(a=n[0].locale),n[0].key&&(i=n[0].key),o=Object.keys(n[0]).reduce((e,s)=>u(t,s)?Object.assign({},e,{[s]:n[0][s]}):e,null)):2===n.length&&(r(n[0])&&(i=n[0]),r(n[1])&&(a=n[1])),this._n(e,a,i,o)}_ntp(t,e,n,s){if(!Y.availabilities.numberFormat)return[];if(!n){return(s?new Intl.NumberFormat(e,s):new Intl.NumberFormat(e)).formatToParts(t)}const r=this._getNumberFormatter(t,e,this.fallbackLocale,this._getNumberFormats(),n,s),a=r&&r.formatToParts(t);if(this._isFallbackRoot(a)){if(!this._root)throw Error("unexpected error");return this._root.$i18n._ntp(t,e,n,s)}return a||[]}}let tt;Object.defineProperty(Y,"availabilities",{get(){if(!tt){const t="undefined"!=typeof Intl;tt={dateTimeFormat:t&&void 0!==Intl.DateTimeFormat,numberFormat:t&&void 0!==Intl.NumberFormat}}return tt}}),Y.install=D,Y.version="8.18.2";export default Y;
|