vue-i18n 8.24.2 → 8.25.0
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 +52 -3
- package/README.md +22 -15
- package/decls/i18n.js +7 -1
- package/dist/vue-i18n.common.js +38 -27
- package/dist/vue-i18n.esm.browser.js +34 -26
- package/dist/vue-i18n.esm.browser.min.js +1 -1
- package/dist/vue-i18n.esm.js +38 -27
- package/dist/vue-i18n.js +38 -27
- package/dist/vue-i18n.min.js +2 -2
- package/package.json +5 -5
- package/src/index.js +27 -10
- package/src/mixin.js +0 -10
- package/src/util.js +10 -7
- package/types/index.d.ts +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
## v8.25.0 (2021-07-16)
|
|
2
|
+
|
|
3
|
+
#### :star: New Features
|
|
4
|
+
* [#1271](https://github.com/kazupon/vue-i18n/pull/1271) feat: Added linked, locale, formatter, values, path to MessageContext ([@fabis94](https://github.com/fabis94))
|
|
5
|
+
|
|
6
|
+
#### :bug: Bug Fixes
|
|
7
|
+
* [#1321](https://github.com/kazupon/vue-i18n/pull/1321) fix broken mergeLocaleMessage ([@phonezawphyo](https://github.com/phonezawphyo))
|
|
8
|
+
|
|
9
|
+
#### Committers: 3
|
|
10
|
+
- [@dependabot-preview[bot]](https://github.com/apps/dependabot-preview)
|
|
11
|
+
- [@fabis94](https://github.com/fabis94)
|
|
12
|
+
- [@phonezawphyo](https://github.com/phonezawphyo)
|
|
13
|
+
|
|
14
|
+
## v8.24.5 (2021-06-19)
|
|
15
|
+
|
|
16
|
+
#### :bug: Bug Fixes
|
|
17
|
+
* [#1278](https://github.com/kazupon/vue-i18n/pull/1278) fix: Ensure that the order at desroy is the same as before change to `Set` from `Array` ([@kazupon](https://github.com/kazupon))
|
|
18
|
+
|
|
19
|
+
#### :zap: Improved Features
|
|
20
|
+
* [#1194](https://github.com/kazupon/vue-i18n/pull/1194) fix: add locale arg type i18n.n method type signature ([@alireza4050](https://github.com/alireza4050))
|
|
21
|
+
|
|
22
|
+
#### :pencil: Documentation
|
|
23
|
+
* [#1273](https://github.com/kazupon/vue-i18n/pull/1273) docs(api:zh): update the Chinese docs of "API" ([@baboon-king](https://github.com/baboon-king))
|
|
24
|
+
* [#1267](https://github.com/kazupon/vue-i18n/pull/1267) Documentation - Update @kazupon/vue-i18n-loader to @intlify/vue-i18n-loader ([@fbigand](https://github.com/fbigand))
|
|
25
|
+
* [#1258](https://github.com/kazupon/vue-i18n/pull/1258) Grammar fix for Installing vue-i18n-loader ([@TerabyteTiger](https://github.com/TerabyteTiger))
|
|
26
|
+
|
|
27
|
+
#### Committers: 5
|
|
28
|
+
- Alireza Asgharizadeh ([@alireza4050](https://github.com/alireza4050))
|
|
29
|
+
- BaboonKing ([@baboon-king](https://github.com/baboon-king))
|
|
30
|
+
- Tyler V ([@TerabyteTiger](https://github.com/TerabyteTiger))
|
|
31
|
+
- [@fbigand](https://github.com/fbigand)
|
|
32
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
33
|
+
|
|
34
|
+
## v8.24.4 (2021-04-28)
|
|
35
|
+
|
|
36
|
+
#### :bug: Bug Fixes
|
|
37
|
+
* [#1192](https://github.com/kazupon/vue-i18n/pull/1192) Revert "fix: i18n reference to root causes memory leak (#1044)" ([@kazupon](https://github.com/kazupon))
|
|
38
|
+
|
|
39
|
+
#### Committers: 2
|
|
40
|
+
- Alexander Sokolov ([@Alex-Sokolov](https://github.com/Alex-Sokolov))
|
|
41
|
+
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
|
|
42
|
+
|
|
43
|
+
## v8.24.3 (2021-04-09)
|
|
44
|
+
|
|
45
|
+
#### :bug: Bug Fixes
|
|
46
|
+
* [#1175](https://github.com/kazupon/vue-i18n/pull/1175) [perf] Use Set so lookup of _dataListeners can be O(1) ([@exoego](https://github.com/exoego))
|
|
47
|
+
|
|
48
|
+
#### :chart_with_upwards_trend: Performance Fixes
|
|
49
|
+
* [#1175](https://github.com/kazupon/vue-i18n/pull/1175) [perf] Use Set so lookup of _dataListeners can be O(1) ([@exoego](https://github.com/exoego))
|
|
50
|
+
|
|
51
|
+
#### Committers: 1
|
|
52
|
+
- TATSUNO Yasuhiro ([@exoego](https://github.com/exoego))
|
|
4
53
|
|
|
5
54
|
## v8.24.2 (2021-03-23)
|
|
6
55
|
|
package/README.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
<h1 align="center">vue-i18n</h1>
|
|
3
3
|
<p align="center">
|
|
4
4
|
<a href="https://circleci.com/gh/kazupon/vue-i18n/tree/dev"><img src="https://circleci.com/gh/kazupon/vue-i18n/tree/dev.svg?style=shield" alt="Build Status"></a>
|
|
5
|
-
<a href="https://codecov.io/gh/kazupon/vue-i18n"><img src="https://codecov.io/gh/kazupon/vue-i18n/branch/dev/graph/badge.svg" alt="Coverage Status"></a>
|
|
6
5
|
<a href="http://badge.fury.io/js/vue-i18n"><img src="https://badge.fury.io/js/vue-i18n.svg" alt="NPM version"></a>
|
|
7
6
|
<a href="https://discord.gg/4yCnk2m"><img src="https://img.shields.io/badge/Discord-join%20chat-738bd7.svg" alt="vue-i18n channel on Discord"></a>
|
|
8
7
|
<a href="https://devtoken.rocks/package/vue-i18n"><img src="https://badge.devtoken.rocks/vue-i18n" alt="vue-i18n Dev Token"></a>
|
|
@@ -12,42 +11,50 @@
|
|
|
12
11
|
|
|
13
12
|
<br/>
|
|
14
13
|
|
|
15
|
-
<h3 align="center"
|
|
14
|
+
<h3 align="center">🏅 Platinum Sponsors</h3>
|
|
16
15
|
|
|
17
16
|
<p align="center">
|
|
18
|
-
<a href="https://
|
|
17
|
+
<a href="https://zenarchitects.co.jp/" target="_blank">
|
|
19
18
|
<img
|
|
20
|
-
src="https://raw.githubusercontent.com/kazupon/vue-i18n/v8.x/vuepress/.vuepress/public/patrons/
|
|
19
|
+
src="https://raw.githubusercontent.com/kazupon/vue-i18n/v8.x/vuepress/.vuepress/public/patrons/zenarchitects.png"
|
|
20
|
+
width="400px"
|
|
21
21
|
/>
|
|
22
22
|
</a>
|
|
23
23
|
</p>
|
|
24
24
|
|
|
25
|
-
<h3 align="center"
|
|
25
|
+
<h3 align="center">🥇 Gold Sponsors</h3>
|
|
26
26
|
|
|
27
27
|
<p align="center">
|
|
28
|
-
<a
|
|
28
|
+
<a
|
|
29
|
+
href="https://nuxtjs.org/"
|
|
30
|
+
target="_blank">
|
|
29
31
|
<img
|
|
30
|
-
src="https://raw.githubusercontent.com/kazupon/vue-i18n/v8.x/vuepress/.vuepress/public/patrons/
|
|
31
|
-
width="
|
|
32
|
+
src="https://raw.githubusercontent.com/kazupon/vue-i18n/v8.x/vuepress/.vuepress/public/patrons/nuxt.png"
|
|
33
|
+
width="240px"
|
|
32
34
|
/>
|
|
33
35
|
</a>
|
|
34
36
|
</p>
|
|
35
37
|
|
|
36
|
-
<h3 align="center">🥉 Bronze Sponsors</h3>
|
|
37
|
-
|
|
38
38
|
<p align="center">
|
|
39
|
-
<a
|
|
39
|
+
<a
|
|
40
|
+
href="https://rapidapi.com/"
|
|
41
|
+
target="_blank">
|
|
40
42
|
<img
|
|
41
|
-
src="https://raw.githubusercontent.com/kazupon/vue-i18n/v8.x/vuepress/.vuepress/public/patrons/
|
|
42
|
-
width="
|
|
43
|
+
src="https://raw.githubusercontent.com/kazupon/vue-i18n/v8.x/vuepress/.vuepress/public/patrons/RapidAPI.svg"
|
|
44
|
+
width="240px"
|
|
43
45
|
/>
|
|
44
46
|
</a>
|
|
45
47
|
</p>
|
|
48
|
+
|
|
49
|
+
<h3 align="center">🥈 Silver Sponsors</h3>
|
|
50
|
+
|
|
51
|
+
<h3 align="center">🥉 Bronze Sponsors</h3>
|
|
52
|
+
|
|
46
53
|
<p align="center">
|
|
47
54
|
<a href="https://www.sendcloud.com/" target="_blank">
|
|
48
55
|
<img
|
|
49
56
|
src="https://raw.githubusercontent.com/kazupon/vue-i18n/v8.x/vuepress/.vuepress/public/patrons/sendcloud.png"
|
|
50
|
-
width="
|
|
57
|
+
width="144px"
|
|
51
58
|
/>
|
|
52
59
|
</a>
|
|
53
60
|
</p>
|
|
@@ -55,7 +62,7 @@
|
|
|
55
62
|
<a href="https://www.vuemastery.com/" target="_blank">
|
|
56
63
|
<img
|
|
57
64
|
src="https://raw.githubusercontent.com/kazupon/vue-i18n/v8.x/vuepress/.vuepress/public/patrons/vuemastery.png"
|
|
58
|
-
width="
|
|
65
|
+
width="144px"
|
|
59
66
|
/>
|
|
60
67
|
</a>
|
|
61
68
|
</p>
|
package/decls/i18n.js
CHANGED
|
@@ -4,7 +4,13 @@ declare type Path = string;
|
|
|
4
4
|
declare type Locale = string;
|
|
5
5
|
declare type MessageContext = {
|
|
6
6
|
list: (index: number) => mixed,
|
|
7
|
-
named: (key: string) => mixed
|
|
7
|
+
named: (key: string) => mixed,
|
|
8
|
+
linked: (key: string) => TranslateResult,
|
|
9
|
+
values: any,
|
|
10
|
+
path: string,
|
|
11
|
+
formatter: Formatter,
|
|
12
|
+
messages: LocaleMessages,
|
|
13
|
+
locale: Locale
|
|
8
14
|
}
|
|
9
15
|
declare type MessageFunction = (ctx: MessageContext) => string
|
|
10
16
|
declare type FallbackLocale = string | string[] | false | { [locale: string]: string[] };
|
package/dist/vue-i18n.common.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* vue-i18n v8.
|
|
2
|
+
* vue-i18n v8.25.0
|
|
3
3
|
* (c) 2021 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -113,14 +113,17 @@ function looseClone (obj) {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
function remove (arr, item) {
|
|
116
|
-
if (arr.
|
|
117
|
-
|
|
118
|
-
if (index > -1) {
|
|
119
|
-
return arr.splice(index, 1)
|
|
120
|
-
}
|
|
116
|
+
if (arr.delete(item)) {
|
|
117
|
+
return arr
|
|
121
118
|
}
|
|
122
119
|
}
|
|
123
120
|
|
|
121
|
+
function arrayFrom (arr) {
|
|
122
|
+
var ret = [];
|
|
123
|
+
arr.forEach(function (a) { return ret.push(a); });
|
|
124
|
+
return ret
|
|
125
|
+
}
|
|
126
|
+
|
|
124
127
|
function includes (arr, item) {
|
|
125
128
|
return !!~arr.indexOf(item)
|
|
126
129
|
}
|
|
@@ -306,16 +309,6 @@ var mixin = {
|
|
|
306
309
|
options.i18n.silentFallbackWarn = rootI18n.silentFallbackWarn;
|
|
307
310
|
options.i18n.pluralizationRules = rootI18n.pluralizationRules;
|
|
308
311
|
options.i18n.preserveDirectiveContent = rootI18n.preserveDirectiveContent;
|
|
309
|
-
this.$root.$once('hook:beforeDestroy', function () {
|
|
310
|
-
options.i18n.root = null;
|
|
311
|
-
options.i18n.formatter = null;
|
|
312
|
-
options.i18n.fallbackLocale = null;
|
|
313
|
-
options.i18n.formatFallbackMessages = null;
|
|
314
|
-
options.i18n.silentTranslationWarn = null;
|
|
315
|
-
options.i18n.silentFallbackWarn = null;
|
|
316
|
-
options.i18n.pluralizationRules = null;
|
|
317
|
-
options.i18n.preserveDirectiveContent = null;
|
|
318
|
-
});
|
|
319
312
|
}
|
|
320
313
|
|
|
321
314
|
// init locale messages via custom blocks
|
|
@@ -1214,7 +1207,7 @@ var VueI18n = function VueI18n (options) {
|
|
|
1214
1207
|
this._dateTimeFormatters = {};
|
|
1215
1208
|
this._numberFormatters = {};
|
|
1216
1209
|
this._path = new I18nPath();
|
|
1217
|
-
this._dataListeners =
|
|
1210
|
+
this._dataListeners = new Set();
|
|
1218
1211
|
this._componentInstanceCreatedListener = options.componentInstanceCreatedListener || null;
|
|
1219
1212
|
this._preserveDirectiveContent = options.preserveDirectiveContent === undefined
|
|
1220
1213
|
? false
|
|
@@ -1345,7 +1338,7 @@ VueI18n.prototype.destroyVM = function destroyVM () {
|
|
|
1345
1338
|
};
|
|
1346
1339
|
|
|
1347
1340
|
VueI18n.prototype.subscribeDataChanging = function subscribeDataChanging (vm) {
|
|
1348
|
-
this._dataListeners.
|
|
1341
|
+
this._dataListeners.add(vm);
|
|
1349
1342
|
};
|
|
1350
1343
|
|
|
1351
1344
|
VueI18n.prototype.unsubscribeDataChanging = function unsubscribeDataChanging (vm) {
|
|
@@ -1353,12 +1346,13 @@ VueI18n.prototype.unsubscribeDataChanging = function unsubscribeDataChanging (vm
|
|
|
1353
1346
|
};
|
|
1354
1347
|
|
|
1355
1348
|
VueI18n.prototype.watchI18nData = function watchI18nData () {
|
|
1356
|
-
|
|
1349
|
+
var this$1 = this;
|
|
1357
1350
|
return this._vm.$watch('$data', function () {
|
|
1358
|
-
var
|
|
1359
|
-
|
|
1351
|
+
var listeners = arrayFrom(this$1._dataListeners);
|
|
1352
|
+
var i = listeners.length;
|
|
1353
|
+
while(i--) {
|
|
1360
1354
|
Vue.nextTick(function () {
|
|
1361
|
-
|
|
1355
|
+
listeners[i] && listeners[i].$forceUpdate();
|
|
1362
1356
|
});
|
|
1363
1357
|
}
|
|
1364
1358
|
}, { deep: true })
|
|
@@ -1544,6 +1538,8 @@ VueI18n.prototype._link = function _link (
|
|
|
1544
1538
|
// We are going to replace each of
|
|
1545
1539
|
// them with its translation
|
|
1546
1540
|
var matches = ret.match(linkKeyMatcher);
|
|
1541
|
+
|
|
1542
|
+
// eslint-disable-next-line no-autofix/prefer-const
|
|
1547
1543
|
for (var idx in matches) {
|
|
1548
1544
|
// ie compatible: filter custom array
|
|
1549
1545
|
// prototype method
|
|
@@ -1607,20 +1603,33 @@ VueI18n.prototype._link = function _link (
|
|
|
1607
1603
|
return ret
|
|
1608
1604
|
};
|
|
1609
1605
|
|
|
1610
|
-
VueI18n.prototype._createMessageContext = function _createMessageContext (values) {
|
|
1606
|
+
VueI18n.prototype._createMessageContext = function _createMessageContext (values, formatter, path, interpolateMode) {
|
|
1607
|
+
var this$1 = this;
|
|
1608
|
+
|
|
1611
1609
|
var _list = isArray(values) ? values : [];
|
|
1612
1610
|
var _named = isObject(values) ? values : {};
|
|
1613
1611
|
var list = function (index) { return _list[index]; };
|
|
1614
1612
|
var named = function (key) { return _named[key]; };
|
|
1613
|
+
var messages = this._getMessages();
|
|
1614
|
+
var locale = this.locale;
|
|
1615
|
+
|
|
1615
1616
|
return {
|
|
1616
1617
|
list: list,
|
|
1617
|
-
named: named
|
|
1618
|
+
named: named,
|
|
1619
|
+
values: values,
|
|
1620
|
+
formatter: formatter,
|
|
1621
|
+
path: path,
|
|
1622
|
+
messages: messages,
|
|
1623
|
+
locale: locale,
|
|
1624
|
+
linked: function (linkedKey) { return this$1._interpolate(locale, messages[locale] || {}, linkedKey, null, interpolateMode, undefined, [linkedKey]); }
|
|
1618
1625
|
}
|
|
1619
1626
|
};
|
|
1620
1627
|
|
|
1621
1628
|
VueI18n.prototype._render = function _render (message, interpolateMode, values, path) {
|
|
1622
1629
|
if (isFunction(message)) {
|
|
1623
|
-
return message(
|
|
1630
|
+
return message(
|
|
1631
|
+
this._createMessageContext(values, this._formatter || defaultFormatter, path, interpolateMode)
|
|
1632
|
+
)
|
|
1624
1633
|
}
|
|
1625
1634
|
|
|
1626
1635
|
var ret = this._formatter.interpolate(message, values, path);
|
|
@@ -1894,7 +1903,7 @@ VueI18n.prototype.mergeLocaleMessage = function mergeLocaleMessage (locale, mess
|
|
|
1894
1903
|
}
|
|
1895
1904
|
this._vm.$set(this._vm.messages, locale, merge(
|
|
1896
1905
|
typeof this._vm.messages[locale] !== 'undefined' && Object.keys(this._vm.messages[locale]).length
|
|
1897
|
-
? this._vm.messages[locale]
|
|
1906
|
+
? Object.assign({}, this._vm.messages[locale])
|
|
1898
1907
|
: {},
|
|
1899
1908
|
message
|
|
1900
1909
|
));
|
|
@@ -1915,6 +1924,7 @@ VueI18n.prototype.mergeDateTimeFormat = function mergeDateTimeFormat (locale, fo
|
|
|
1915
1924
|
};
|
|
1916
1925
|
|
|
1917
1926
|
VueI18n.prototype._clearDateTimeFormat = function _clearDateTimeFormat (locale, format) {
|
|
1927
|
+
// eslint-disable-next-line no-autofix/prefer-const
|
|
1918
1928
|
for (var key in format) {
|
|
1919
1929
|
var id = locale + "__" + key;
|
|
1920
1930
|
|
|
@@ -2035,6 +2045,7 @@ VueI18n.prototype.mergeNumberFormat = function mergeNumberFormat (locale, format
|
|
|
2035
2045
|
};
|
|
2036
2046
|
|
|
2037
2047
|
VueI18n.prototype._clearNumberFormat = function _clearNumberFormat (locale, format) {
|
|
2048
|
+
// eslint-disable-next-line no-autofix/prefer-const
|
|
2038
2049
|
for (var key in format) {
|
|
2039
2050
|
var id = locale + "__" + key;
|
|
2040
2051
|
|
|
@@ -2209,6 +2220,6 @@ Object.defineProperty(VueI18n, 'availabilities', {
|
|
|
2209
2220
|
});
|
|
2210
2221
|
|
|
2211
2222
|
VueI18n.install = install;
|
|
2212
|
-
VueI18n.version = '8.
|
|
2223
|
+
VueI18n.version = '8.25.0';
|
|
2213
2224
|
|
|
2214
2225
|
module.exports = VueI18n;
|
|
@@ -103,14 +103,17 @@ function looseClone (obj) {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
function remove (arr, item) {
|
|
106
|
-
if (arr.
|
|
107
|
-
|
|
108
|
-
if (index > -1) {
|
|
109
|
-
return arr.splice(index, 1)
|
|
110
|
-
}
|
|
106
|
+
if (arr.delete(item)) {
|
|
107
|
+
return arr
|
|
111
108
|
}
|
|
112
109
|
}
|
|
113
110
|
|
|
111
|
+
function arrayFrom (arr) {
|
|
112
|
+
const ret = [];
|
|
113
|
+
arr.forEach(a => ret.push(a));
|
|
114
|
+
return ret
|
|
115
|
+
}
|
|
116
|
+
|
|
114
117
|
function includes (arr, item) {
|
|
115
118
|
return !!~arr.indexOf(item)
|
|
116
119
|
}
|
|
@@ -280,16 +283,6 @@ var mixin = {
|
|
|
280
283
|
options.i18n.silentFallbackWarn = rootI18n.silentFallbackWarn;
|
|
281
284
|
options.i18n.pluralizationRules = rootI18n.pluralizationRules;
|
|
282
285
|
options.i18n.preserveDirectiveContent = rootI18n.preserveDirectiveContent;
|
|
283
|
-
this.$root.$once('hook:beforeDestroy', () => {
|
|
284
|
-
options.i18n.root = null;
|
|
285
|
-
options.i18n.formatter = null;
|
|
286
|
-
options.i18n.fallbackLocale = null;
|
|
287
|
-
options.i18n.formatFallbackMessages = null;
|
|
288
|
-
options.i18n.silentTranslationWarn = null;
|
|
289
|
-
options.i18n.silentFallbackWarn = null;
|
|
290
|
-
options.i18n.pluralizationRules = null;
|
|
291
|
-
options.i18n.preserveDirectiveContent = null;
|
|
292
|
-
});
|
|
293
286
|
}
|
|
294
287
|
|
|
295
288
|
// init locale messages via custom blocks
|
|
@@ -1200,7 +1193,7 @@ class VueI18n {
|
|
|
1200
1193
|
this._dateTimeFormatters = {};
|
|
1201
1194
|
this._numberFormatters = {};
|
|
1202
1195
|
this._path = new I18nPath();
|
|
1203
|
-
this._dataListeners =
|
|
1196
|
+
this._dataListeners = new Set();
|
|
1204
1197
|
this._componentInstanceCreatedListener = options.componentInstanceCreatedListener || null;
|
|
1205
1198
|
this._preserveDirectiveContent = options.preserveDirectiveContent === undefined
|
|
1206
1199
|
? false
|
|
@@ -1329,7 +1322,7 @@ class VueI18n {
|
|
|
1329
1322
|
}
|
|
1330
1323
|
|
|
1331
1324
|
subscribeDataChanging (vm) {
|
|
1332
|
-
this._dataListeners.
|
|
1325
|
+
this._dataListeners.add(vm);
|
|
1333
1326
|
}
|
|
1334
1327
|
|
|
1335
1328
|
unsubscribeDataChanging (vm) {
|
|
@@ -1337,12 +1330,12 @@ class VueI18n {
|
|
|
1337
1330
|
}
|
|
1338
1331
|
|
|
1339
1332
|
watchI18nData () {
|
|
1340
|
-
const self = this;
|
|
1341
1333
|
return this._vm.$watch('$data', () => {
|
|
1342
|
-
|
|
1343
|
-
|
|
1334
|
+
const listeners = arrayFrom(this._dataListeners);
|
|
1335
|
+
let i = listeners.length;
|
|
1336
|
+
while(i--) {
|
|
1344
1337
|
Vue.nextTick(() => {
|
|
1345
|
-
|
|
1338
|
+
listeners[i] && listeners[i].$forceUpdate();
|
|
1346
1339
|
});
|
|
1347
1340
|
}
|
|
1348
1341
|
}, { deep: true })
|
|
@@ -1526,6 +1519,8 @@ class VueI18n {
|
|
|
1526
1519
|
// We are going to replace each of
|
|
1527
1520
|
// them with its translation
|
|
1528
1521
|
const matches = ret.match(linkKeyMatcher);
|
|
1522
|
+
|
|
1523
|
+
// eslint-disable-next-line no-autofix/prefer-const
|
|
1529
1524
|
for (let idx in matches) {
|
|
1530
1525
|
// ie compatible: filter custom array
|
|
1531
1526
|
// prototype method
|
|
@@ -1588,20 +1583,31 @@ class VueI18n {
|
|
|
1588
1583
|
return ret
|
|
1589
1584
|
}
|
|
1590
1585
|
|
|
1591
|
-
_createMessageContext (values) {
|
|
1586
|
+
_createMessageContext (values, formatter, path, interpolateMode) {
|
|
1592
1587
|
const _list = isArray(values) ? values : [];
|
|
1593
1588
|
const _named = isObject(values) ? values : {};
|
|
1594
1589
|
const list = (index) => _list[index];
|
|
1595
1590
|
const named = (key) => _named[key];
|
|
1591
|
+
const messages = this._getMessages();
|
|
1592
|
+
const locale = this.locale;
|
|
1593
|
+
|
|
1596
1594
|
return {
|
|
1597
1595
|
list,
|
|
1598
|
-
named
|
|
1596
|
+
named,
|
|
1597
|
+
values,
|
|
1598
|
+
formatter,
|
|
1599
|
+
path,
|
|
1600
|
+
messages,
|
|
1601
|
+
locale,
|
|
1602
|
+
linked: (linkedKey) => this._interpolate(locale, messages[locale] || {}, linkedKey, null, interpolateMode, undefined, [linkedKey])
|
|
1599
1603
|
}
|
|
1600
1604
|
}
|
|
1601
1605
|
|
|
1602
1606
|
_render (message, interpolateMode, values, path) {
|
|
1603
1607
|
if (isFunction(message)) {
|
|
1604
|
-
return message(
|
|
1608
|
+
return message(
|
|
1609
|
+
this._createMessageContext(values, this._formatter || defaultFormatter, path, interpolateMode)
|
|
1610
|
+
)
|
|
1605
1611
|
}
|
|
1606
1612
|
|
|
1607
1613
|
let ret = this._formatter.interpolate(message, values, path);
|
|
@@ -1857,7 +1863,7 @@ class VueI18n {
|
|
|
1857
1863
|
}
|
|
1858
1864
|
this._vm.$set(this._vm.messages, locale, merge(
|
|
1859
1865
|
typeof this._vm.messages[locale] !== 'undefined' && Object.keys(this._vm.messages[locale]).length
|
|
1860
|
-
? this._vm.messages[locale]
|
|
1866
|
+
? Object.assign({}, this._vm.messages[locale])
|
|
1861
1867
|
: {},
|
|
1862
1868
|
message
|
|
1863
1869
|
));
|
|
@@ -1878,6 +1884,7 @@ class VueI18n {
|
|
|
1878
1884
|
}
|
|
1879
1885
|
|
|
1880
1886
|
_clearDateTimeFormat (locale, format) {
|
|
1887
|
+
// eslint-disable-next-line no-autofix/prefer-const
|
|
1881
1888
|
for (let key in format) {
|
|
1882
1889
|
const id = `${locale}__${key}`;
|
|
1883
1890
|
|
|
@@ -1995,6 +2002,7 @@ class VueI18n {
|
|
|
1995
2002
|
}
|
|
1996
2003
|
|
|
1997
2004
|
_clearNumberFormat (locale, format) {
|
|
2005
|
+
// eslint-disable-next-line no-autofix/prefer-const
|
|
1998
2006
|
for (let key in format) {
|
|
1999
2007
|
const id = `${locale}__${key}`;
|
|
2000
2008
|
|
|
@@ -2163,6 +2171,6 @@ Object.defineProperty(VueI18n, 'availabilities', {
|
|
|
2163
2171
|
});
|
|
2164
2172
|
|
|
2165
2173
|
VueI18n.install = install;
|
|
2166
|
-
VueI18n.version = '8.
|
|
2174
|
+
VueI18n.version = '8.25.0';
|
|
2167
2175
|
|
|
2168
2176
|
export default VueI18n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=["compactDisplay","currency","currencyDisplay","currencySign","localeMatcher","notation","numberingSystem","signDisplay","style","unit","unitDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];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){return"function"==typeof t}function h(...t){let e=null,r=null;return 1===t.length?s(t[0])||n(t[0])?r=t[0]:"string"==typeof t[0]&&(e=t[0]):2===t.length&&("string"==typeof t[0]&&(e=t[0]),(s(t[1])||n(t[1]))&&(r=t[1])),{locale:e,params:r}}function u(t){return JSON.parse(JSON.stringify(t))}function m(t,e){return!!~t.indexOf(e)}const _=Object.prototype.hasOwnProperty;function f(t,e){return _.call(t,e)}function p(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)f(n,t)&&(s(n[t])?e[t]=p(e[t],n[t]):e[t]=n[t])}}return e}function g(t,e){if(t===e)return!0;const r=s(t),i=s(e);if(!r||!i)return!r&&!i&&String(t)===String(e);try{const s=n(t),r=n(e);if(s&&r)return t.length===e.length&&t.every((t,n)=>g(t,e[n]));if(s||r)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 d={beforeCreate(){const t=this.$options;if(t.i18n=t.i18n||(t.__i18n?{}:null),t.i18n){if(t.i18n instanceof tt){if(t.__i18n)try{let e=t.i18n&&t.i18n.messages?t.i18n.messages:{};t.__i18n.forEach(t=>{e=p(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 tt?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,this.$root.$once("hook:beforeDestroy",()=>{t.i18n.root=null,t.i18n.formatter=null,t.i18n.fallbackLocale=null,t.i18n.formatFallbackMessages=null,t.i18n.silentTranslationWarn=null,t.i18n.silentFallbackWarn=null,t.i18n.pluralizationRules=null,t.i18n.preserveDirectiveContent=null})),t.__i18n)try{let e=t.i18n&&t.i18n.messages?t.i18n.messages:{};t.__i18n.forEach(t=>{e=p(e,JSON.parse(t))}),t.i18n.messages=e}catch(t){}const{sharedMessages:n}=t.i18n;n&&o(n)&&(t.i18n.messages=p(t.i18n.messages,n)),this._i18n=new tt(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 tt?this._i18n=this.$root.$i18n:t.parent&&t.parent.$i18n&&t.parent.$i18n instanceof tt&&(this._i18n=t.parent.$i18n)},beforeMount(){const t=this.$options;t.i18n=t.i18n||(t.__i18n?{}:null),t.i18n?t.i18n instanceof tt?(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 tt?(this._i18n.subscribeDataChanging(this),this._subscribing=!0):t.parent&&t.parent.$i18n&&t.parent.$i18n instanceof tt&&(this._i18n.subscribeDataChanging(this),this._subscribing=!0)},mounted(){this!==this.$root&&this.$options.__INTLIFY_META__&&this.$el&&this.$el.setAttribute("data-intlify",this.$options.__INTLIFY_META__)},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)})}},b={name:"i18n",functional:!0,props:{tag:{type:[String,Boolean,Object],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(y,{}):Object.assign({},t)}(e):{};if(!t)return n;const s=(t=t.filter(t=>t.tag||""!==t.text.trim())).every(F);return t.reduce(s?v:y,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 v(t,e){return e.data&&e.data.attrs&&e.data.attrs.place&&(t[e.data.attrs.place]=e),t}function y(t,e,n){return t[n]=e,t}function F(t){return Boolean(t.data&&t.data.attrs&&t.data.attrs.place)}var k={name:"i18n-n",functional:!0,props:{tag:{type:[String,Boolean,Object],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)=>m(t,s)?Object.assign({},e,{[s]:n.format[s]}):e,null));const h=n.locale||o.locale,u=o._ntp(n.value,h,l,c),_=u.map((t,e)=>{const n=a.scopedSlots&&a.scopedSlots[t.type];return n?n({[t.type]:t.value,index:e,parts:u}):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 $(t,e,n){C(t,n)&&T(t,e,n)}function w(t,e,n,s){if(!C(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 M(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 C(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=null!=h?u.$i18n.tc(a,h,...L(l,c)):u.$i18n.t(a,...L(l,c)),t._locale=u.$i18n.locale,t._localeMessage=u.$i18n.getLocaleMessage(u.$i18n.locale)}function L(t,e){const n=[];return t&&n.push(t),e&&(Array.isArray(e)||o(e))&&n.push(e),n}let D;function I(t){I.installed=!0;(D=t).version&&Number(D.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)}}(D),D.mixin(d),D.directive("t",{bind:$,update:w,unbind:M}),D.component(b.name,b),D.component(k.name,k),D.config.optionMergeStrategies.i18n=function(t,e){return void 0===e?t:e}}const O=/^(?:\d)+/,x=/^(?:\w)+/;const W=0,j=1,N=2,S=3,H=0,R=4,P=5,E=6,A=7,V=8,z=[];z[H]={ws:[H],ident:[3,W],"[":[R],eof:[A]},z[1]={ws:[1],".":[2],"[":[R],eof:[A]},z[2]={ws:[2],ident:[3,W],0:[3,W],number:[3,W]},z[3]={ident:[3,W],0:[3,W],number:[3,W],ws:[1,j],".":[2,j],"[":[R,j],eof:[A,j]},z[R]={"'":[P,W],'"':[E,W],"[":[R,N],"]":[1,S],eof:V,else:[R,W]},z[P]={"'":[R,W],eof:V,else:[P,W]},z[E]={'"':[R,W],eof:V,else:[E,W]};const B=/^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;function U(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 q(t){const e=t.trim();return("0"!==t.charAt(0)||!isNaN(t))&&(n=e,B.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=H,u=0;const m=[];function _(){const e=t[c+1];if(h===P&&"'"===e||h===E&&'"'===e)return c++,r="\\"+e,m[W](),!0}for(m[j]=function(){void 0!==s&&(e.push(s),s=void 0)},m[W]=function(){void 0===s?s=r:s+=r},m[N]=function(){m[W](),u++},m[S]=function(){if(u>0)u--,h=R,m[W]();else{if(u=0,void 0===s)return!1;if(!1===(s=q(s)))return!1;m[j]()}};null!==h;)if("\\"!==(n=t[++c])||!_()){if(i=U(n),(a=(l=z[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===A)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(null==t)return null;s=t,r++}return s}}}const Y=/<\/?[\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=O.test(i)?"list":a&&x.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 tt{constructor(t={}){!D&&"undefined"!=typeof window&&window.Vue&&I(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._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._escapeParameterHtml=t.escapeParameterHtml||!1,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:i})}_checkLocaleMessage(t,s,i){const a=(t,s,i,l)=>{if(o(i))Object.keys(i).forEach(e=>{const n=i[e];o(n)?(l.push(e),l.push("."),a(t,s,n,l),l.pop(),l.pop()):(l.push(e),a(t,s,n,l),l.pop())});else if(n(i))i.forEach((e,n)=>{o(e)?(l.push(`[${n}]`),l.push("."),a(t,s,e,l),l.pop(),l.pop()):(l.push(`[${n}]`),a(t,s,e,l),l.pop())});else if(r(i)){if(Y.test(i)){const n=`Detected HTML in message '${i}' of keypath '${l.join("")}' at '${s}'. Consider component interpolation with '<i18n>' to avoid XSS. See https://bit.ly/2ZqJzkp`;"warn"===t?e(n):"error"===t&&function(t,e){"undefined"!=typeof console&&(console.error("[vue-i18n] "+t),e&&console.error(e.stack))}(n)}}};a(s,t,i,[])}_initVM(t){const e=D.config.silent;D.config.silent=!0,this._vm=new D({data:t}),D.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--;)D.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 u(this._getMessages())}get dateTimeFormats(){return u(this._getDateTimeFormats())}get numberFormats(){return u(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=h(...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,s,i,a,h,u){if(!e)return null;const m=this._path.getPathValue(e,s);if(n(m)||o(m))return m;let _;if(l(m)){if(!o(e))return null;if(!r(_=e[s])&&!c(_))return null}else{if(!r(m)&&!c(m))return null;_=m}return r(_)&&(_.indexOf("@:")>=0||_.indexOf("@.")>=0)&&(_=this._link(t,e,_,i,"raw",h,u)),this._render(_,a,h,s)}_link(t,e,s,r,i,a,o){let l=s;const c=l.match(G);for(let s in c){if(!c.hasOwnProperty(s))continue;const h=c[s],u=h.match(X),[_,f]=u,p=h.replace(_,"").replace(Z,"");if(m(o,p))return l;o.push(p);let g=this._interpolate(t,e,p,r,"raw"===i?"string":i,"raw"===i?void 0:a,o);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,p,r,i,a)}g=this._warnDefault(t,p,g,r,n(a)?a:[a],i),this._modifiers.hasOwnProperty(f)?g=this._modifiers[f](g):K.hasOwnProperty(f)&&(g=K[f](g)),o.pop(),l=g?l.replace(h,g):l}return l}_createMessageContext(t){const e=n(t)?t:[],r=s(t)?t:{};return{list:t=>e[t],named:t=>r[t]}}_render(t,e,n,s){if(c(t))return t(this._createMessageContext(n));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 m(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=h(...r);var a;this._escapeParameterHtml&&(i.params=(null!=(a=i.params)&&Object.keys(a).forEach(t=>{"string"==typeof a[t]&&(a[t]=function(t){return t.replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}(a[t]))}),a));const o=i.locale||e;let l=this._translate(n,o,this.fallbackLocale,t,s,"string",i.params);if(this._isFallbackRoot(l)){if(!this._root)throw Error("unexpected error");return this._root.$t(t,...r)}return l=this._warnDefault(o,t,l,s,r,"string"),this._postTranslation&&null!=l&&(l=this._postTranslation(l,t)),l}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=h(...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}tc(t,e,...n){return this._tc(t,this.locale,this._getMessages(),null,e,...n)}_te(t,e,n,...s){const r=h(...s).locale||e;return this._exist(n[r],t)}te(t,e){return this._te(t,this.locale,this._getMessages(),e)}getLocaleMessage(t){return u(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,p(void 0!==this._vm.messages[t]&&Object.keys(this._vm.messages[t]).length?this._vm.messages[t]:{},e))}getDateTimeFormat(t){return u(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,p(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 u(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,p(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(!tt.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)=>m(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(!tt.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 et;Object.defineProperty(tt,"availabilities",{get(){if(!et){const t="undefined"!=typeof Intl;et={dateTimeFormat:t&&void 0!==Intl.DateTimeFormat,numberFormat:t&&void 0!==Intl.NumberFormat}}return et}}),tt.install=I,tt.version="8.24.2";export default tt;
|
|
1
|
+
const t=["compactDisplay","currency","currencyDisplay","currencySign","localeMatcher","notation","numberingSystem","signDisplay","style","unit","unitDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];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){return"function"==typeof t}function h(...t){let e=null,r=null;return 1===t.length?s(t[0])||n(t[0])?r=t[0]:"string"==typeof t[0]&&(e=t[0]):2===t.length&&("string"==typeof t[0]&&(e=t[0]),(s(t[1])||n(t[1]))&&(r=t[1])),{locale:e,params:r}}function u(t){return JSON.parse(JSON.stringify(t))}function m(t,e){return!!~t.indexOf(e)}const _=Object.prototype.hasOwnProperty;function f(t,e){return _.call(t,e)}function g(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)f(n,t)&&(s(n[t])?e[t]=g(e[t],n[t]):e[t]=n[t])}}return e}function p(t,e){if(t===e)return!0;const r=s(t),i=s(e);if(!r||!i)return!r&&!i&&String(t)===String(e);try{const s=n(t),r=n(e);if(s&&r)return t.length===e.length&&t.every((t,n)=>p(t,e[n]));if(s||r)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 d={beforeCreate(){const t=this.$options;if(t.i18n=t.i18n||(t.__i18n?{}:null),t.i18n){if(t.i18n instanceof tt){if(t.__i18n)try{let e=t.i18n&&t.i18n.messages?t.i18n.messages:{};t.__i18n.forEach(t=>{e=g(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 tt?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&&t.i18n.messages?t.i18n.messages:{};t.__i18n.forEach(t=>{e=g(e,JSON.parse(t))}),t.i18n.messages=e}catch(t){}const{sharedMessages:n}=t.i18n;n&&o(n)&&(t.i18n.messages=g(t.i18n.messages,n)),this._i18n=new tt(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 tt?this._i18n=this.$root.$i18n:t.parent&&t.parent.$i18n&&t.parent.$i18n instanceof tt&&(this._i18n=t.parent.$i18n)},beforeMount(){const t=this.$options;t.i18n=t.i18n||(t.__i18n?{}:null),t.i18n?t.i18n instanceof tt?(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 tt?(this._i18n.subscribeDataChanging(this),this._subscribing=!0):t.parent&&t.parent.$i18n&&t.parent.$i18n instanceof tt&&(this._i18n.subscribeDataChanging(this),this._subscribing=!0)},mounted(){this!==this.$root&&this.$options.__INTLIFY_META__&&this.$el&&this.$el.setAttribute("data-intlify",this.$options.__INTLIFY_META__)},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)})}},b={name:"i18n",functional:!0,props:{tag:{type:[String,Boolean,Object],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(y,{}):Object.assign({},t)}(e):{};if(!t)return n;const s=(t=t.filter(t=>t.tag||""!==t.text.trim())).every(F);return t.reduce(s?v:y,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 v(t,e){return e.data&&e.data.attrs&&e.data.attrs.place&&(t[e.data.attrs.place]=e),t}function y(t,e,n){return t[n]=e,t}function F(t){return Boolean(t.data&&t.data.attrs&&t.data.attrs.place)}var k={name:"i18n-n",functional:!0,props:{tag:{type:[String,Boolean,Object],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)=>m(t,s)?Object.assign({},e,{[s]:n.format[s]}):e,null));const h=n.locale||o.locale,u=o._ntp(n.value,h,l,c),_=u.map((t,e)=>{const n=a.scopedSlots&&a.scopedSlots[t.type];return n?n({[t.type]:t.value,index:e,parts:u}):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 $(t,e,n){C(t,n)&&T(t,e,n)}function w(t,e,n,s){if(!C(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))||T(t,e,n)}function M(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 C(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=null!=h?u.$i18n.tc(a,h,...L(l,c)):u.$i18n.t(a,...L(l,c)),t._locale=u.$i18n.locale,t._localeMessage=u.$i18n.getLocaleMessage(u.$i18n.locale)}function L(t,e){const n=[];return t&&n.push(t),e&&(Array.isArray(e)||o(e))&&n.push(e),n}let I;function D(t){D.installed=!0;(I=t).version&&Number(I.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)}}(I),I.mixin(d),I.directive("t",{bind:$,update:w,unbind:M}),I.component(b.name,b),I.component(k.name,k),I.config.optionMergeStrategies.i18n=function(t,e){return void 0===e?t:e}}const O=/^(?:\d)+/,x=/^(?:\w)+/;const j=0,W=1,N=2,S=3,H=0,P=4,R=5,E=6,A=7,V=8,z=[];z[H]={ws:[H],ident:[3,j],"[":[P],eof:[A]},z[1]={ws:[1],".":[2],"[":[P],eof:[A]},z[2]={ws:[2],ident:[3,j],0:[3,j],number:[3,j]},z[3]={ident:[3,j],0:[3,j],number:[3,j],ws:[1,W],".":[2,W],"[":[P,W],eof:[A,W]},z[P]={"'":[R,j],'"':[E,j],"[":[P,N],"]":[1,S],eof:V,else:[P,j]},z[R]={"'":[P,j],eof:V,else:[R,j]},z[E]={'"':[P,j],eof:V,else:[E,j]};const B=/^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;function U(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 q(t){const e=t.trim();return("0"!==t.charAt(0)||!isNaN(t))&&(n=e,B.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=H,u=0;const m=[];function _(){const e=t[c+1];if(h===R&&"'"===e||h===E&&'"'===e)return c++,r="\\"+e,m[j](),!0}for(m[W]=function(){void 0!==s&&(e.push(s),s=void 0)},m[j]=function(){void 0===s?s=r:s+=r},m[N]=function(){m[j](),u++},m[S]=function(){if(u>0)u--,h=P,m[j]();else{if(u=0,void 0===s)return!1;if(!1===(s=q(s)))return!1;m[W]()}};null!==h;)if("\\"!==(n=t[++c])||!_()){if(i=U(n),(a=(l=z[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===A)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(null==t)return null;s=t,r++}return s}}}const Y=/<\/?[\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=O.test(i)?"list":a&&x.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 tt{constructor(t={}){!I&&"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=new Set,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._escapeParameterHtml=t.escapeParameterHtml||!1,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:i})}_checkLocaleMessage(t,s,i){const a=(t,s,i,l)=>{if(o(i))Object.keys(i).forEach(e=>{const n=i[e];o(n)?(l.push(e),l.push("."),a(t,s,n,l),l.pop(),l.pop()):(l.push(e),a(t,s,n,l),l.pop())});else if(n(i))i.forEach((e,n)=>{o(e)?(l.push(`[${n}]`),l.push("."),a(t,s,e,l),l.pop(),l.pop()):(l.push(`[${n}]`),a(t,s,e,l),l.pop())});else if(r(i)){if(Y.test(i)){const n=`Detected HTML in message '${i}' of keypath '${l.join("")}' at '${s}'. Consider component interpolation with '<i18n>' to avoid XSS. See https://bit.ly/2ZqJzkp`;"warn"===t?e(n):"error"===t&&function(t,e){"undefined"!=typeof console&&(console.error("[vue-i18n] "+t),e&&console.error(e.stack))}(n)}}};a(s,t,i,[])}_initVM(t){const e=I.config.silent;I.config.silent=!0,this._vm=new I({data:t}),I.config.silent=e}destroyVM(){this._vm.$destroy()}subscribeDataChanging(t){this._dataListeners.add(t)}unsubscribeDataChanging(t){!function(t,e){if(t.delete(e));}(this._dataListeners,t)}watchI18nData(){return this._vm.$watch("$data",()=>{const t=function(t){const e=[];return t.forEach(t=>e.push(t)),e}(this._dataListeners);let e=t.length;for(;e--;)I.nextTick(()=>{t[e]&&t[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 u(this._getMessages())}get dateTimeFormats(){return u(this._getDateTimeFormats())}get numberFormats(){return u(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=h(...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,s,i,a,h,u){if(!e)return null;const m=this._path.getPathValue(e,s);if(n(m)||o(m))return m;let _;if(l(m)){if(!o(e))return null;if(!r(_=e[s])&&!c(_))return null}else{if(!r(m)&&!c(m))return null;_=m}return r(_)&&(_.indexOf("@:")>=0||_.indexOf("@.")>=0)&&(_=this._link(t,e,_,i,"raw",h,u)),this._render(_,a,h,s)}_link(t,e,s,r,i,a,o){let l=s;const c=l.match(G);for(let s in c){if(!c.hasOwnProperty(s))continue;const h=c[s],u=h.match(X),[_,f]=u,g=h.replace(_,"").replace(Z,"");if(m(o,g))return l;o.push(g);let p=this._interpolate(t,e,g,r,"raw"===i?"string":i,"raw"===i?void 0:a,o);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,g,r,i,a)}p=this._warnDefault(t,g,p,r,n(a)?a:[a],i),this._modifiers.hasOwnProperty(f)?p=this._modifiers[f](p):K.hasOwnProperty(f)&&(p=K[f](p)),o.pop(),l=p?l.replace(h,p):l}return l}_createMessageContext(t,e,r,i){const a=n(t)?t:[],o=s(t)?t:{},l=this._getMessages(),c=this.locale;return{list:t=>a[t],named:t=>o[t],values:t,formatter:e,path:r,messages:l,locale:c,linked:t=>this._interpolate(c,l[c]||{},t,null,i,void 0,[t])}}_render(t,e,n,s){if(c(t))return t(this._createMessageContext(n,this._formatter||Q,s,e));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 m(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=h(...r);var a;this._escapeParameterHtml&&(i.params=(null!=(a=i.params)&&Object.keys(a).forEach(t=>{"string"==typeof a[t]&&(a[t]=function(t){return t.replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}(a[t]))}),a));const o=i.locale||e;let l=this._translate(n,o,this.fallbackLocale,t,s,"string",i.params);if(this._isFallbackRoot(l)){if(!this._root)throw Error("unexpected error");return this._root.$t(t,...r)}return l=this._warnDefault(o,t,l,s,r,"string"),this._postTranslation&&null!=l&&(l=this._postTranslation(l,t)),l}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=h(...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}tc(t,e,...n){return this._tc(t,this.locale,this._getMessages(),null,e,...n)}_te(t,e,n,...s){const r=h(...s).locale||e;return this._exist(n[r],t)}te(t,e){return this._te(t,this.locale,this._getMessages(),e)}getLocaleMessage(t){return u(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,g(void 0!==this._vm.messages[t]&&Object.keys(this._vm.messages[t]).length?Object.assign({},this._vm.messages[t]):{},e))}getDateTimeFormat(t){return u(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,g(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 u(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,g(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(!tt.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)=>m(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(!tt.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 et;Object.defineProperty(tt,"availabilities",{get(){if(!et){const t="undefined"!=typeof Intl;et={dateTimeFormat:t&&void 0!==Intl.DateTimeFormat,numberFormat:t&&void 0!==Intl.NumberFormat}}return et}}),tt.install=D,tt.version="8.25.0";export default tt;
|
package/dist/vue-i18n.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* vue-i18n v8.
|
|
2
|
+
* vue-i18n v8.25.0
|
|
3
3
|
* (c) 2021 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -111,14 +111,17 @@ function looseClone (obj) {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
function remove (arr, item) {
|
|
114
|
-
if (arr.
|
|
115
|
-
|
|
116
|
-
if (index > -1) {
|
|
117
|
-
return arr.splice(index, 1)
|
|
118
|
-
}
|
|
114
|
+
if (arr.delete(item)) {
|
|
115
|
+
return arr
|
|
119
116
|
}
|
|
120
117
|
}
|
|
121
118
|
|
|
119
|
+
function arrayFrom (arr) {
|
|
120
|
+
var ret = [];
|
|
121
|
+
arr.forEach(function (a) { return ret.push(a); });
|
|
122
|
+
return ret
|
|
123
|
+
}
|
|
124
|
+
|
|
122
125
|
function includes (arr, item) {
|
|
123
126
|
return !!~arr.indexOf(item)
|
|
124
127
|
}
|
|
@@ -304,16 +307,6 @@ var mixin = {
|
|
|
304
307
|
options.i18n.silentFallbackWarn = rootI18n.silentFallbackWarn;
|
|
305
308
|
options.i18n.pluralizationRules = rootI18n.pluralizationRules;
|
|
306
309
|
options.i18n.preserveDirectiveContent = rootI18n.preserveDirectiveContent;
|
|
307
|
-
this.$root.$once('hook:beforeDestroy', function () {
|
|
308
|
-
options.i18n.root = null;
|
|
309
|
-
options.i18n.formatter = null;
|
|
310
|
-
options.i18n.fallbackLocale = null;
|
|
311
|
-
options.i18n.formatFallbackMessages = null;
|
|
312
|
-
options.i18n.silentTranslationWarn = null;
|
|
313
|
-
options.i18n.silentFallbackWarn = null;
|
|
314
|
-
options.i18n.pluralizationRules = null;
|
|
315
|
-
options.i18n.preserveDirectiveContent = null;
|
|
316
|
-
});
|
|
317
310
|
}
|
|
318
311
|
|
|
319
312
|
// init locale messages via custom blocks
|
|
@@ -1212,7 +1205,7 @@ var VueI18n = function VueI18n (options) {
|
|
|
1212
1205
|
this._dateTimeFormatters = {};
|
|
1213
1206
|
this._numberFormatters = {};
|
|
1214
1207
|
this._path = new I18nPath();
|
|
1215
|
-
this._dataListeners =
|
|
1208
|
+
this._dataListeners = new Set();
|
|
1216
1209
|
this._componentInstanceCreatedListener = options.componentInstanceCreatedListener || null;
|
|
1217
1210
|
this._preserveDirectiveContent = options.preserveDirectiveContent === undefined
|
|
1218
1211
|
? false
|
|
@@ -1343,7 +1336,7 @@ VueI18n.prototype.destroyVM = function destroyVM () {
|
|
|
1343
1336
|
};
|
|
1344
1337
|
|
|
1345
1338
|
VueI18n.prototype.subscribeDataChanging = function subscribeDataChanging (vm) {
|
|
1346
|
-
this._dataListeners.
|
|
1339
|
+
this._dataListeners.add(vm);
|
|
1347
1340
|
};
|
|
1348
1341
|
|
|
1349
1342
|
VueI18n.prototype.unsubscribeDataChanging = function unsubscribeDataChanging (vm) {
|
|
@@ -1351,12 +1344,13 @@ VueI18n.prototype.unsubscribeDataChanging = function unsubscribeDataChanging (vm
|
|
|
1351
1344
|
};
|
|
1352
1345
|
|
|
1353
1346
|
VueI18n.prototype.watchI18nData = function watchI18nData () {
|
|
1354
|
-
|
|
1347
|
+
var this$1 = this;
|
|
1355
1348
|
return this._vm.$watch('$data', function () {
|
|
1356
|
-
var
|
|
1357
|
-
|
|
1349
|
+
var listeners = arrayFrom(this$1._dataListeners);
|
|
1350
|
+
var i = listeners.length;
|
|
1351
|
+
while(i--) {
|
|
1358
1352
|
Vue.nextTick(function () {
|
|
1359
|
-
|
|
1353
|
+
listeners[i] && listeners[i].$forceUpdate();
|
|
1360
1354
|
});
|
|
1361
1355
|
}
|
|
1362
1356
|
}, { deep: true })
|
|
@@ -1542,6 +1536,8 @@ VueI18n.prototype._link = function _link (
|
|
|
1542
1536
|
// We are going to replace each of
|
|
1543
1537
|
// them with its translation
|
|
1544
1538
|
var matches = ret.match(linkKeyMatcher);
|
|
1539
|
+
|
|
1540
|
+
// eslint-disable-next-line no-autofix/prefer-const
|
|
1545
1541
|
for (var idx in matches) {
|
|
1546
1542
|
// ie compatible: filter custom array
|
|
1547
1543
|
// prototype method
|
|
@@ -1605,20 +1601,33 @@ VueI18n.prototype._link = function _link (
|
|
|
1605
1601
|
return ret
|
|
1606
1602
|
};
|
|
1607
1603
|
|
|
1608
|
-
VueI18n.prototype._createMessageContext = function _createMessageContext (values) {
|
|
1604
|
+
VueI18n.prototype._createMessageContext = function _createMessageContext (values, formatter, path, interpolateMode) {
|
|
1605
|
+
var this$1 = this;
|
|
1606
|
+
|
|
1609
1607
|
var _list = isArray(values) ? values : [];
|
|
1610
1608
|
var _named = isObject(values) ? values : {};
|
|
1611
1609
|
var list = function (index) { return _list[index]; };
|
|
1612
1610
|
var named = function (key) { return _named[key]; };
|
|
1611
|
+
var messages = this._getMessages();
|
|
1612
|
+
var locale = this.locale;
|
|
1613
|
+
|
|
1613
1614
|
return {
|
|
1614
1615
|
list: list,
|
|
1615
|
-
named: named
|
|
1616
|
+
named: named,
|
|
1617
|
+
values: values,
|
|
1618
|
+
formatter: formatter,
|
|
1619
|
+
path: path,
|
|
1620
|
+
messages: messages,
|
|
1621
|
+
locale: locale,
|
|
1622
|
+
linked: function (linkedKey) { return this$1._interpolate(locale, messages[locale] || {}, linkedKey, null, interpolateMode, undefined, [linkedKey]); }
|
|
1616
1623
|
}
|
|
1617
1624
|
};
|
|
1618
1625
|
|
|
1619
1626
|
VueI18n.prototype._render = function _render (message, interpolateMode, values, path) {
|
|
1620
1627
|
if (isFunction(message)) {
|
|
1621
|
-
return message(
|
|
1628
|
+
return message(
|
|
1629
|
+
this._createMessageContext(values, this._formatter || defaultFormatter, path, interpolateMode)
|
|
1630
|
+
)
|
|
1622
1631
|
}
|
|
1623
1632
|
|
|
1624
1633
|
var ret = this._formatter.interpolate(message, values, path);
|
|
@@ -1892,7 +1901,7 @@ VueI18n.prototype.mergeLocaleMessage = function mergeLocaleMessage (locale, mess
|
|
|
1892
1901
|
}
|
|
1893
1902
|
this._vm.$set(this._vm.messages, locale, merge(
|
|
1894
1903
|
typeof this._vm.messages[locale] !== 'undefined' && Object.keys(this._vm.messages[locale]).length
|
|
1895
|
-
? this._vm.messages[locale]
|
|
1904
|
+
? Object.assign({}, this._vm.messages[locale])
|
|
1896
1905
|
: {},
|
|
1897
1906
|
message
|
|
1898
1907
|
));
|
|
@@ -1913,6 +1922,7 @@ VueI18n.prototype.mergeDateTimeFormat = function mergeDateTimeFormat (locale, fo
|
|
|
1913
1922
|
};
|
|
1914
1923
|
|
|
1915
1924
|
VueI18n.prototype._clearDateTimeFormat = function _clearDateTimeFormat (locale, format) {
|
|
1925
|
+
// eslint-disable-next-line no-autofix/prefer-const
|
|
1916
1926
|
for (var key in format) {
|
|
1917
1927
|
var id = locale + "__" + key;
|
|
1918
1928
|
|
|
@@ -2033,6 +2043,7 @@ VueI18n.prototype.mergeNumberFormat = function mergeNumberFormat (locale, format
|
|
|
2033
2043
|
};
|
|
2034
2044
|
|
|
2035
2045
|
VueI18n.prototype._clearNumberFormat = function _clearNumberFormat (locale, format) {
|
|
2046
|
+
// eslint-disable-next-line no-autofix/prefer-const
|
|
2036
2047
|
for (var key in format) {
|
|
2037
2048
|
var id = locale + "__" + key;
|
|
2038
2049
|
|
|
@@ -2207,6 +2218,6 @@ Object.defineProperty(VueI18n, 'availabilities', {
|
|
|
2207
2218
|
});
|
|
2208
2219
|
|
|
2209
2220
|
VueI18n.install = install;
|
|
2210
|
-
VueI18n.version = '8.
|
|
2221
|
+
VueI18n.version = '8.25.0';
|
|
2211
2222
|
|
|
2212
2223
|
export default VueI18n;
|
package/dist/vue-i18n.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* vue-i18n v8.
|
|
2
|
+
* vue-i18n v8.25.0
|
|
3
3
|
* (c) 2021 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -117,14 +117,17 @@
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
function remove (arr, item) {
|
|
120
|
-
if (arr.
|
|
121
|
-
|
|
122
|
-
if (index > -1) {
|
|
123
|
-
return arr.splice(index, 1)
|
|
124
|
-
}
|
|
120
|
+
if (arr.delete(item)) {
|
|
121
|
+
return arr
|
|
125
122
|
}
|
|
126
123
|
}
|
|
127
124
|
|
|
125
|
+
function arrayFrom (arr) {
|
|
126
|
+
var ret = [];
|
|
127
|
+
arr.forEach(function (a) { return ret.push(a); });
|
|
128
|
+
return ret
|
|
129
|
+
}
|
|
130
|
+
|
|
128
131
|
function includes (arr, item) {
|
|
129
132
|
return !!~arr.indexOf(item)
|
|
130
133
|
}
|
|
@@ -310,16 +313,6 @@
|
|
|
310
313
|
options.i18n.silentFallbackWarn = rootI18n.silentFallbackWarn;
|
|
311
314
|
options.i18n.pluralizationRules = rootI18n.pluralizationRules;
|
|
312
315
|
options.i18n.preserveDirectiveContent = rootI18n.preserveDirectiveContent;
|
|
313
|
-
this.$root.$once('hook:beforeDestroy', function () {
|
|
314
|
-
options.i18n.root = null;
|
|
315
|
-
options.i18n.formatter = null;
|
|
316
|
-
options.i18n.fallbackLocale = null;
|
|
317
|
-
options.i18n.formatFallbackMessages = null;
|
|
318
|
-
options.i18n.silentTranslationWarn = null;
|
|
319
|
-
options.i18n.silentFallbackWarn = null;
|
|
320
|
-
options.i18n.pluralizationRules = null;
|
|
321
|
-
options.i18n.preserveDirectiveContent = null;
|
|
322
|
-
});
|
|
323
316
|
}
|
|
324
317
|
|
|
325
318
|
// init locale messages via custom blocks
|
|
@@ -1218,7 +1211,7 @@
|
|
|
1218
1211
|
this._dateTimeFormatters = {};
|
|
1219
1212
|
this._numberFormatters = {};
|
|
1220
1213
|
this._path = new I18nPath();
|
|
1221
|
-
this._dataListeners =
|
|
1214
|
+
this._dataListeners = new Set();
|
|
1222
1215
|
this._componentInstanceCreatedListener = options.componentInstanceCreatedListener || null;
|
|
1223
1216
|
this._preserveDirectiveContent = options.preserveDirectiveContent === undefined
|
|
1224
1217
|
? false
|
|
@@ -1349,7 +1342,7 @@
|
|
|
1349
1342
|
};
|
|
1350
1343
|
|
|
1351
1344
|
VueI18n.prototype.subscribeDataChanging = function subscribeDataChanging (vm) {
|
|
1352
|
-
this._dataListeners.
|
|
1345
|
+
this._dataListeners.add(vm);
|
|
1353
1346
|
};
|
|
1354
1347
|
|
|
1355
1348
|
VueI18n.prototype.unsubscribeDataChanging = function unsubscribeDataChanging (vm) {
|
|
@@ -1357,12 +1350,13 @@
|
|
|
1357
1350
|
};
|
|
1358
1351
|
|
|
1359
1352
|
VueI18n.prototype.watchI18nData = function watchI18nData () {
|
|
1360
|
-
|
|
1353
|
+
var this$1 = this;
|
|
1361
1354
|
return this._vm.$watch('$data', function () {
|
|
1362
|
-
var
|
|
1363
|
-
|
|
1355
|
+
var listeners = arrayFrom(this$1._dataListeners);
|
|
1356
|
+
var i = listeners.length;
|
|
1357
|
+
while(i--) {
|
|
1364
1358
|
Vue.nextTick(function () {
|
|
1365
|
-
|
|
1359
|
+
listeners[i] && listeners[i].$forceUpdate();
|
|
1366
1360
|
});
|
|
1367
1361
|
}
|
|
1368
1362
|
}, { deep: true })
|
|
@@ -1548,6 +1542,8 @@
|
|
|
1548
1542
|
// We are going to replace each of
|
|
1549
1543
|
// them with its translation
|
|
1550
1544
|
var matches = ret.match(linkKeyMatcher);
|
|
1545
|
+
|
|
1546
|
+
// eslint-disable-next-line no-autofix/prefer-const
|
|
1551
1547
|
for (var idx in matches) {
|
|
1552
1548
|
// ie compatible: filter custom array
|
|
1553
1549
|
// prototype method
|
|
@@ -1611,20 +1607,33 @@
|
|
|
1611
1607
|
return ret
|
|
1612
1608
|
};
|
|
1613
1609
|
|
|
1614
|
-
VueI18n.prototype._createMessageContext = function _createMessageContext (values) {
|
|
1610
|
+
VueI18n.prototype._createMessageContext = function _createMessageContext (values, formatter, path, interpolateMode) {
|
|
1611
|
+
var this$1 = this;
|
|
1612
|
+
|
|
1615
1613
|
var _list = isArray(values) ? values : [];
|
|
1616
1614
|
var _named = isObject(values) ? values : {};
|
|
1617
1615
|
var list = function (index) { return _list[index]; };
|
|
1618
1616
|
var named = function (key) { return _named[key]; };
|
|
1617
|
+
var messages = this._getMessages();
|
|
1618
|
+
var locale = this.locale;
|
|
1619
|
+
|
|
1619
1620
|
return {
|
|
1620
1621
|
list: list,
|
|
1621
|
-
named: named
|
|
1622
|
+
named: named,
|
|
1623
|
+
values: values,
|
|
1624
|
+
formatter: formatter,
|
|
1625
|
+
path: path,
|
|
1626
|
+
messages: messages,
|
|
1627
|
+
locale: locale,
|
|
1628
|
+
linked: function (linkedKey) { return this$1._interpolate(locale, messages[locale] || {}, linkedKey, null, interpolateMode, undefined, [linkedKey]); }
|
|
1622
1629
|
}
|
|
1623
1630
|
};
|
|
1624
1631
|
|
|
1625
1632
|
VueI18n.prototype._render = function _render (message, interpolateMode, values, path) {
|
|
1626
1633
|
if (isFunction(message)) {
|
|
1627
|
-
return message(
|
|
1634
|
+
return message(
|
|
1635
|
+
this._createMessageContext(values, this._formatter || defaultFormatter, path, interpolateMode)
|
|
1636
|
+
)
|
|
1628
1637
|
}
|
|
1629
1638
|
|
|
1630
1639
|
var ret = this._formatter.interpolate(message, values, path);
|
|
@@ -1898,7 +1907,7 @@
|
|
|
1898
1907
|
}
|
|
1899
1908
|
this._vm.$set(this._vm.messages, locale, merge(
|
|
1900
1909
|
typeof this._vm.messages[locale] !== 'undefined' && Object.keys(this._vm.messages[locale]).length
|
|
1901
|
-
? this._vm.messages[locale]
|
|
1910
|
+
? Object.assign({}, this._vm.messages[locale])
|
|
1902
1911
|
: {},
|
|
1903
1912
|
message
|
|
1904
1913
|
));
|
|
@@ -1919,6 +1928,7 @@
|
|
|
1919
1928
|
};
|
|
1920
1929
|
|
|
1921
1930
|
VueI18n.prototype._clearDateTimeFormat = function _clearDateTimeFormat (locale, format) {
|
|
1931
|
+
// eslint-disable-next-line no-autofix/prefer-const
|
|
1922
1932
|
for (var key in format) {
|
|
1923
1933
|
var id = locale + "__" + key;
|
|
1924
1934
|
|
|
@@ -2039,6 +2049,7 @@
|
|
|
2039
2049
|
};
|
|
2040
2050
|
|
|
2041
2051
|
VueI18n.prototype._clearNumberFormat = function _clearNumberFormat (locale, format) {
|
|
2052
|
+
// eslint-disable-next-line no-autofix/prefer-const
|
|
2042
2053
|
for (var key in format) {
|
|
2043
2054
|
var id = locale + "__" + key;
|
|
2044
2055
|
|
|
@@ -2213,7 +2224,7 @@
|
|
|
2213
2224
|
});
|
|
2214
2225
|
|
|
2215
2226
|
VueI18n.install = install;
|
|
2216
|
-
VueI18n.version = '8.
|
|
2227
|
+
VueI18n.version = '8.25.0';
|
|
2217
2228
|
|
|
2218
2229
|
return VueI18n;
|
|
2219
2230
|
|
package/dist/vue-i18n.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* vue-i18n v8.
|
|
2
|
+
* vue-i18n v8.25.0
|
|
3
3
|
* (c) 2021 kazuya kawaguchi
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
var t,e;t=this,e=function(){"use strict";var t=["compactDisplay","currency","currencyDisplay","currencySign","localeMatcher","notation","numberingSystem","signDisplay","style","unit","unitDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function e(t,e){"undefined"!=typeof console&&(console.warn("[vue-i18n] "+t),e&&console.warn(e.stack))}var n=Array.isArray;function r(t){return null!==t&&"object"==typeof t}function a(t){return"string"==typeof t}var i=Object.prototype.toString,o="[object Object]";function s(t){return i.call(t)===o}function l(t){return null==t}function c(t){return"function"==typeof t}function u(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var a=null,i=null;return 1===t.length?r(t[0])||n(t[0])?i=t[0]:"string"==typeof t[0]&&(a=t[0]):2===t.length&&("string"==typeof t[0]&&(a=t[0]),(r(t[1])||n(t[1]))&&(i=t[1])),{locale:a,params:i}}function f(t){return JSON.parse(JSON.stringify(t))}function h(t,e){return!!~t.indexOf(e)}var p=Object.prototype.hasOwnProperty;function m(t,e){return p.call(t,e)}function _(t){for(var e=arguments,n=Object(t),a=1;a<arguments.length;a++){var i=e[a];if(null!=i){var o=void 0;for(o in i)m(i,o)&&(r(i[o])?n[o]=_(n[o],i[o]):n[o]=i[o])}}return n}function g(t,e){if(t===e)return!0;var a=r(t),i=r(e);if(!a||!i)return!a&&!i&&String(t)===String(e);try{var o=n(t),s=n(e);if(o&&s)return t.length===e.length&&t.every(function(t,n){return g(t,e[n])});if(o||s)return!1;var l=Object.keys(t),c=Object.keys(e);return l.length===c.length&&l.every(function(n){return g(t[n],e[n])})}catch(t){return!1}}var v={beforeCreate:function(){var t=this.$options;if(t.i18n=t.i18n||(t.__i18n?{}:null),t.i18n){if(t.i18n instanceof nt){if(t.__i18n)try{var e=t.i18n&&t.i18n.messages?t.i18n.messages:{};t.__i18n.forEach(function(t){e=_(e,JSON.parse(t))}),Object.keys(e).forEach(function(n){t.i18n.mergeLocaleMessage(n,e[n])})}catch(t){}this._i18n=t.i18n,this._i18nWatcher=this._i18n.watchI18nData()}else if(s(t.i18n)){var n=this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof nt?this.$root.$i18n:null;if(n&&(t.i18n.root=this.$root,t.i18n.formatter=n.formatter,t.i18n.fallbackLocale=n.fallbackLocale,t.i18n.formatFallbackMessages=n.formatFallbackMessages,t.i18n.silentTranslationWarn=n.silentTranslationWarn,t.i18n.silentFallbackWarn=n.silentFallbackWarn,t.i18n.pluralizationRules=n.pluralizationRules,t.i18n.preserveDirectiveContent=n.preserveDirectiveContent,this.$root.$once("hook:beforeDestroy",function(){t.i18n.root=null,t.i18n.formatter=null,t.i18n.fallbackLocale=null,t.i18n.formatFallbackMessages=null,t.i18n.silentTranslationWarn=null,t.i18n.silentFallbackWarn=null,t.i18n.pluralizationRules=null,t.i18n.preserveDirectiveContent=null})),t.__i18n)try{var r=t.i18n&&t.i18n.messages?t.i18n.messages:{};t.__i18n.forEach(function(t){r=_(r,JSON.parse(t))}),t.i18n.messages=r}catch(t){}var a=t.i18n.sharedMessages;a&&s(a)&&(t.i18n.messages=_(t.i18n.messages,a)),this._i18n=new nt(t.i18n),this._i18nWatcher=this._i18n.watchI18nData(),(void 0===t.i18n.sync||t.i18n.sync)&&(this._localeWatcher=this.$i18n.watchLocale()),n&&n.onComponentInstanceCreated(this._i18n)}}else this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof nt?this._i18n=this.$root.$i18n:t.parent&&t.parent.$i18n&&t.parent.$i18n instanceof nt&&(this._i18n=t.parent.$i18n)},beforeMount:function(){var t=this.$options;t.i18n=t.i18n||(t.__i18n?{}:null),t.i18n?t.i18n instanceof nt?(this._i18n.subscribeDataChanging(this),this._subscribing=!0):s(t.i18n)&&(this._i18n.subscribeDataChanging(this),this._subscribing=!0):this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof nt?(this._i18n.subscribeDataChanging(this),this._subscribing=!0):t.parent&&t.parent.$i18n&&t.parent.$i18n instanceof nt&&(this._i18n.subscribeDataChanging(this),this._subscribing=!0)},mounted:function(){this!==this.$root&&this.$options.__INTLIFY_META__&&this.$el&&this.$el.setAttribute("data-intlify",this.$options.__INTLIFY_META__)},beforeDestroy:function(){if(this._i18n){var t=this;this.$nextTick(function(){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)})}}},b={name:"i18n",functional:!0,props:{tag:{type:[String,Boolean,Object],default:"span"},path:{type:String,required:!0},locale:{type:String},places:{type:[Array,Object]}},render:function(t,e){var n=e.data,r=e.parent,a=e.props,i=e.slots,o=r.$i18n;if(o){var s=a.path,l=a.locale,c=a.places,u=i(),f=o.i(s,l,function(t){var e;for(e in t)if("default"!==e)return!1;return Boolean(e)}(u)||c?function(t,e){var n=e?function(t){return Array.isArray(t)?t.reduce(y,{}):Object.assign({},t)}(e):{};if(!t)return n;var r=(t=t.filter(function(t){return t.tag||""!==t.text.trim()})).every(F);return t.reduce(r?d:y,n)}(u.default,c):u),h=a.tag&&!0!==a.tag||!1===a.tag?a.tag:"span";return h?t(h,n,f):f}}};function d(t,e){return e.data&&e.data.attrs&&e.data.attrs.place&&(t[e.data.attrs.place]=e),t}function y(t,e,n){return t[n]=e,t}function F(t){return Boolean(t.data&&t.data.attrs&&t.data.attrs.place)}var k,w={name:"i18n-n",functional:!0,props:{tag:{type:[String,Boolean,Object],default:"span"},value:{type:Number,required:!0},format:{type:[String,Object]},locale:{type:String}},render:function(e,n){var i=n.props,o=n.parent,s=n.data,l=o.$i18n;if(!l)return null;var c=null,u=null;a(i.format)?c=i.format:r(i.format)&&(i.format.key&&(c=i.format.key),u=Object.keys(i.format).reduce(function(e,n){var r;return h(t,n)?Object.assign({},e,((r={})[n]=i.format[n],r)):e},null));var f=i.locale||l.locale,p=l._ntp(i.value,f,c,u),m=p.map(function(t,e){var n,r=s.scopedSlots&&s.scopedSlots[t.type];return r?r(((n={})[t.type]=t.value,n.index=e,n.parts=p,n)):t.value}),_=i.tag&&!0!==i.tag||!1===i.tag?i.tag:"span";return _?e(_,{attrs:s.attrs,class:s.class,staticClass:s.staticClass},m):m}};function $(t,e,n){C(t,n)&&L(t,e,n)}function M(t,e,n,r){if(C(t,n)){var a=n.context.$i18n;(function(t,e){var n=e.context;return t._locale===n.$i18n.locale})(t,n)&&g(e.value,e.oldValue)&&g(t._localeMessage,a.getLocaleMessage(a.locale))||L(t,e,n)}}function T(t,n,r,a){if(r.context){var i=r.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}else e("Vue instance does not exists in VNode context")}function C(t,n){var r=n.context;return r?!!r.$i18n||(e("VueI18n instance does not exists in Vue instance"),!1):(e("Vue instance does not exists in VNode context"),!1)}function L(t,n,r){var i,o,l=function(t){var e,n,r,i;a(t)?e=t:s(t)&&(e=t.path,n=t.locale,r=t.args,i=t.choice);return{path:e,locale:n,args:r,choice:i}}(n.value),c=l.path,u=l.locale,f=l.args,h=l.choice;if(c||u||f)if(c){var p=r.context;t._vt=t.textContent=null!=h?(i=p.$i18n).tc.apply(i,[c,h].concat(D(u,f))):(o=p.$i18n).t.apply(o,[c].concat(D(u,f))),t._locale=p.$i18n.locale,t._localeMessage=p.$i18n.getLocaleMessage(p.$i18n.locale)}else e("`path` is required in v-t directive");else e("value type not supported")}function D(t,e){var n=[];return t&&n.push(t),e&&(Array.isArray(e)||s(e))&&n.push(e),n}function I(t){I.installed=!0;(k=t).version&&Number(k.version.split(".")[0]);!function(t){t.prototype.hasOwnProperty("$i18n")||Object.defineProperty(t.prototype,"$i18n",{get:function(){return this._i18n}}),t.prototype.$t=function(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];var r=this.$i18n;return r._t.apply(r,[t,r.locale,r._getMessages(),this].concat(e))},t.prototype.$tc=function(t,e){for(var n=[],r=arguments.length-2;r-- >0;)n[r]=arguments[r+2];var a=this.$i18n;return a._tc.apply(a,[t,a.locale,a._getMessages(),this,e].concat(n))},t.prototype.$te=function(t,e){var n=this.$i18n;return n._te(t,n.locale,n._getMessages(),e)},t.prototype.$d=function(t){for(var e,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return(e=this.$i18n).d.apply(e,[t].concat(n))},t.prototype.$n=function(t){for(var e,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return(e=this.$i18n).n.apply(e,[t].concat(n))}}(k),k.mixin(v),k.directive("t",{bind:$,update:M,unbind:T}),k.component(b.name,b),k.component(w.name,w),k.config.optionMergeStrategies.i18n=function(t,e){return void 0===e?t:e}}var O=function(){this._caches=Object.create(null)};O.prototype.interpolate=function(t,e){if(!e)return[t];var n=this._caches[t];return n||(n=function(t){var e=[],n=0,r="";for(;n<t.length;){var a=t[n++];if("{"===a){r&&e.push({type:"text",value:r}),r="";var i="";for(a=t[n++];void 0!==a&&"}"!==a;)i+=a,a=t[n++];var o="}"===a,s=x.test(i)?"list":o&&W.test(i)?"named":"unknown";e.push({value:i,type:s})}else"%"===a?"{"!==t[n]&&(r+=a):r+=a}return r&&e.push({type:"text",value:r}),e}(t),this._caches[t]=n),function(t,e){var n=[],a=0,i=Array.isArray(e)?"list":r(e)?"named":"unknown";if("unknown"===i)return n;for(;a<t.length;){var o=t[a];switch(o.type){case"text":n.push(o.value);break;case"list":n.push(e[parseInt(o.value,10)]);break;case"named":"named"===i&&n.push(e[o.value])}a++}return n}(n,e)};var x=/^(?:\d)+/,W=/^(?:\w)+/,j=0,N=1,S=2,H=3,P=0,R=4,E=5,A=6,V=7,z=8,B=[];B[P]={ws:[P],ident:[3,j],"[":[R],eof:[V]},B[1]={ws:[1],".":[2],"[":[R],eof:[V]},B[2]={ws:[2],ident:[3,j],0:[3,j],number:[3,j]},B[3]={ident:[3,j],0:[3,j],number:[3,j],ws:[1,N],".":[2,N],"[":[R,N],eof:[V,N]},B[R]={"'":[E,j],'"':[A,j],"[":[R,S],"]":[1,H],eof:z,else:[R,j]},B[E]={"'":[R,j],eof:z,else:[E,j]},B[A]={'"':[R,j],eof:z,else:[A,j]};var U=/^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;function q(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 J(t){var e,n,r,a=t.trim();return("0"!==t.charAt(0)||!isNaN(t))&&(r=a,U.test(r)?(n=(e=a).charCodeAt(0))!==e.charCodeAt(e.length-1)||34!==n&&39!==n?e:e.slice(1,-1):"*"+a)}var Y=function(){this._cache=Object.create(null)};Y.prototype.parsePath=function(t){var e=this._cache[t];return e||(e=function(t){var e,n,r,a,i,o,s,l=[],c=-1,u=P,f=0,h=[];function p(){var e=t[c+1];if(u===E&&"'"===e||u===A&&'"'===e)return c++,r="\\"+e,h[j](),!0}for(h[N]=function(){void 0!==n&&(l.push(n),n=void 0)},h[j]=function(){void 0===n?n=r:n+=r},h[S]=function(){h[j](),f++},h[H]=function(){if(f>0)f--,u=R,h[j]();else{if(f=0,void 0===n)return!1;if(!1===(n=J(n)))return!1;h[N]()}};null!==u;)if("\\"!==(e=t[++c])||!p()){if(a=q(e),(i=(s=B[u])[a]||s.else||z)===z)return;if(u=i[0],(o=h[i[1]])&&(r=void 0===(r=i[2])?e:r,!1===o()))return;if(u===V)return l}}(t))&&(this._cache[t]=e),e||[]},Y.prototype.getPathValue=function(t,e){if(!r(t))return null;var n=this.parsePath(e);if(0===n.length)return null;for(var a=n.length,i=t,o=0;o<a;){var s=i[n[o]];if(null==s)return null;i=s,o++}return i};var G,X=/<\/?[\w\s="/.':;#-\/]+>/,Z=/(?:@(?:\.[a-z]+)?:(?:[\w\-_|.]+|\([\w\-_|.]+\)))/g,K=/^@(?:\.([a-z]+))?:/,Q=/[()]/g,tt={upper:function(t){return t.toLocaleUpperCase()},lower:function(t){return t.toLocaleLowerCase()},capitalize:function(t){return""+t.charAt(0).toLocaleUpperCase()+t.substr(1)}},et=new O,nt=function(t){var e=this;void 0===t&&(t={}),!k&&"undefined"!=typeof window&&window.Vue&&I(window.Vue);var n=t.locale||"en-US",r=!1!==t.fallbackLocale&&(t.fallbackLocale||"en-US"),a=t.messages||{},i=t.dateTimeFormats||{},o=t.numberFormats||{};this._vm=null,this._formatter=t.formatter||et,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 Y,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._escapeParameterHtml=t.escapeParameterHtml||!1,this.getChoiceIndex=function(t,n){var r=Object.getPrototypeOf(e);if(r&&r.getChoiceIndex)return r.getChoiceIndex.call(e,t,n);var a,i;return e.locale in e.pluralizationRules?e.pluralizationRules[e.locale].apply(e,[t,n]):(a=t,i=n,a=Math.abs(a),2===i?a?a>1?1:0:1:a?Math.min(a,2):0)},this._exist=function(t,n){return!(!t||!n)&&(!l(e._path.getPathValue(t,n))||!!t[n])},"warn"!==this._warnHtmlInMessage&&"error"!==this._warnHtmlInMessage||Object.keys(a).forEach(function(t){e._checkLocaleMessage(t,e._warnHtmlInMessage,a[t])}),this._initVM({locale:n,fallbackLocale:r,messages:a,dateTimeFormats:i,numberFormats:o})},rt={vm:{configurable:!0},messages:{configurable:!0},dateTimeFormats:{configurable:!0},numberFormats:{configurable:!0},availableLocales:{configurable:!0},locale:{configurable:!0},fallbackLocale:{configurable:!0},formatFallbackMessages:{configurable:!0},missing:{configurable:!0},formatter:{configurable:!0},silentTranslationWarn:{configurable:!0},silentFallbackWarn:{configurable:!0},preserveDirectiveContent:{configurable:!0},warnHtmlInMessage:{configurable:!0},postTranslation:{configurable:!0}};return nt.prototype._checkLocaleMessage=function(t,r,i){var o=function(t,r,i,l){if(s(i))Object.keys(i).forEach(function(e){var n=i[e];s(n)?(l.push(e),l.push("."),o(t,r,n,l),l.pop(),l.pop()):(l.push(e),o(t,r,n,l),l.pop())});else if(n(i))i.forEach(function(e,n){s(e)?(l.push("["+n+"]"),l.push("."),o(t,r,e,l),l.pop(),l.pop()):(l.push("["+n+"]"),o(t,r,e,l),l.pop())});else if(a(i)){if(X.test(i)){var c="Detected HTML in message '"+i+"' of keypath '"+l.join("")+"' at '"+r+"'. Consider component interpolation with '<i18n>' to avoid XSS. See https://bit.ly/2ZqJzkp";"warn"===t?e(c):"error"===t&&function(t,e){"undefined"!=typeof console&&(console.error("[vue-i18n] "+t),e&&console.error(e.stack))}(c)}}};o(r,t,i,[])},nt.prototype._initVM=function(t){var e=k.config.silent;k.config.silent=!0,this._vm=new k({data:t}),k.config.silent=e},nt.prototype.destroyVM=function(){this._vm.$destroy()},nt.prototype.subscribeDataChanging=function(t){this._dataListeners.push(t)},nt.prototype.unsubscribeDataChanging=function(t){!function(t,e){if(t.length){var n=t.indexOf(e);if(n>-1)t.splice(n,1)}}(this._dataListeners,t)},nt.prototype.watchI18nData=function(){var t=this;return this._vm.$watch("$data",function(){for(var e=t._dataListeners.length;e--;)k.nextTick(function(){t._dataListeners[e]&&t._dataListeners[e].$forceUpdate()})},{deep:!0})},nt.prototype.watchLocale=function(){if(!this._sync||!this._root)return null;var t=this._vm;return this._root.$i18n.vm.$watch("locale",function(e){t.$set(t,"locale",e),t.$forceUpdate()},{immediate:!0})},nt.prototype.onComponentInstanceCreated=function(t){this._componentInstanceCreatedListener&&this._componentInstanceCreatedListener(t,this)},rt.vm.get=function(){return this._vm},rt.messages.get=function(){return f(this._getMessages())},rt.dateTimeFormats.get=function(){return f(this._getDateTimeFormats())},rt.numberFormats.get=function(){return f(this._getNumberFormats())},rt.availableLocales.get=function(){return Object.keys(this.messages).sort()},rt.locale.get=function(){return this._vm.locale},rt.locale.set=function(t){this._vm.$set(this._vm,"locale",t)},rt.fallbackLocale.get=function(){return this._vm.fallbackLocale},rt.fallbackLocale.set=function(t){this._localeChainCache={},this._vm.$set(this._vm,"fallbackLocale",t)},rt.formatFallbackMessages.get=function(){return this._formatFallbackMessages},rt.formatFallbackMessages.set=function(t){this._formatFallbackMessages=t},rt.missing.get=function(){return this._missing},rt.missing.set=function(t){this._missing=t},rt.formatter.get=function(){return this._formatter},rt.formatter.set=function(t){this._formatter=t},rt.silentTranslationWarn.get=function(){return this._silentTranslationWarn},rt.silentTranslationWarn.set=function(t){this._silentTranslationWarn=t},rt.silentFallbackWarn.get=function(){return this._silentFallbackWarn},rt.silentFallbackWarn.set=function(t){this._silentFallbackWarn=t},rt.preserveDirectiveContent.get=function(){return this._preserveDirectiveContent},rt.preserveDirectiveContent.set=function(t){this._preserveDirectiveContent=t},rt.warnHtmlInMessage.get=function(){return this._warnHtmlInMessage},rt.warnHtmlInMessage.set=function(t){var e=this,n=this._warnHtmlInMessage;if(this._warnHtmlInMessage=t,n!==t&&("warn"===t||"error"===t)){var r=this._getMessages();Object.keys(r).forEach(function(t){e._checkLocaleMessage(t,e._warnHtmlInMessage,r[t])})}},rt.postTranslation.get=function(){return this._postTranslation},rt.postTranslation.set=function(t){this._postTranslation=t},nt.prototype._getMessages=function(){return this._vm.messages},nt.prototype._getDateTimeFormats=function(){return this._vm.dateTimeFormats},nt.prototype._getNumberFormats=function(){return this._vm.numberFormats},nt.prototype._warnDefault=function(t,e,n,r,i,o){if(!l(n))return n;if(this._missing){var s=this._missing.apply(null,[t,e,r,i]);if(a(s))return s}if(this._formatFallbackMessages){var c=u.apply(void 0,i);return this._render(e,o,c.params,e)}return e},nt.prototype._isFallbackRoot=function(t){return!t&&!l(this._root)&&this._fallbackRoot},nt.prototype._isSilentFallbackWarn=function(t){return this._silentFallbackWarn instanceof RegExp?this._silentFallbackWarn.test(t):this._silentFallbackWarn},nt.prototype._isSilentFallback=function(t,e){return this._isSilentFallbackWarn(e)&&(this._isFallbackRoot()||t!==this.fallbackLocale)},nt.prototype._isSilentTranslationWarn=function(t){return this._silentTranslationWarn instanceof RegExp?this._silentTranslationWarn.test(t):this._silentTranslationWarn},nt.prototype._interpolate=function(t,e,r,i,o,u,f){if(!e)return null;var h,p=this._path.getPathValue(e,r);if(n(p)||s(p))return p;if(l(p)){if(!s(e))return null;if(!a(h=e[r])&&!c(h))return null}else{if(!a(p)&&!c(p))return null;h=p}return a(h)&&(h.indexOf("@:")>=0||h.indexOf("@.")>=0)&&(h=this._link(t,e,h,i,"raw",u,f)),this._render(h,o,u,r)},nt.prototype._link=function(t,e,r,a,i,o,s){var l=r,c=l.match(Z);for(var u in c)if(c.hasOwnProperty(u)){var f=c[u],p=f.match(K),m=p[0],_=p[1],g=f.replace(m,"").replace(Q,"");if(h(s,g))return l;s.push(g);var v=this._interpolate(t,e,g,a,"raw"===i?"string":i,"raw"===i?void 0:o,s);if(this._isFallbackRoot(v)){if(!this._root)throw Error("unexpected error");var b=this._root.$i18n;v=b._translate(b._getMessages(),b.locale,b.fallbackLocale,g,a,i,o)}v=this._warnDefault(t,g,v,a,n(o)?o:[o],i),this._modifiers.hasOwnProperty(_)?v=this._modifiers[_](v):tt.hasOwnProperty(_)&&(v=tt[_](v)),s.pop(),l=v?l.replace(f,v):l}return l},nt.prototype._createMessageContext=function(t){var e=n(t)?t:[],a=r(t)?t:{};return{list:function(t){return e[t]},named:function(t){return a[t]}}},nt.prototype._render=function(t,e,n,r){if(c(t))return t(this._createMessageContext(n));var i=this._formatter.interpolate(t,n,r);return i||(i=et.interpolate(t,n,r)),"string"!==e||a(i)?i:i.join("")},nt.prototype._appendItemToChain=function(t,e,n){var r=!1;return h(t,e)||(r=!0,e&&(r="!"!==e[e.length-1],e=e.replace(/!/g,""),t.push(e),n&&n[e]&&(r=n[e]))),r},nt.prototype._appendLocaleToChain=function(t,e,n){var r,a=e.split("-");do{var i=a.join("-");r=this._appendItemToChain(t,i,n),a.splice(-1,1)}while(a.length&&!0===r);return r},nt.prototype._appendBlockToChain=function(t,e,n){for(var r=!0,i=0;i<e.length&&"boolean"==typeof r;i++){var o=e[i];a(o)&&(r=this._appendLocaleToChain(t,o,n))}return r},nt.prototype._getLocaleChain=function(t,e){if(""===t)return[];this._localeChainCache||(this._localeChainCache={});var i=this._localeChainCache[t];if(!i){e||(e=this.fallbackLocale),i=[];for(var o,s=[t];n(s);)s=this._appendBlockToChain(i,s,e);(s=a(o=n(e)?e:r(e)?e.default?e.default:null:e)?[o]:o)&&this._appendBlockToChain(i,s,null),this._localeChainCache[t]=i}return i},nt.prototype._translate=function(t,e,n,r,a,i,o){for(var s,c=this._getLocaleChain(e,n),u=0;u<c.length;u++){var f=c[u];if(!l(s=this._interpolate(f,t[f],r,a,i,o,[r])))return s}return null},nt.prototype._t=function(t,e,n,r){for(var a,i=[],o=arguments.length-4;o-- >0;)i[o]=arguments[o+4];if(!t)return"";var s,l=u.apply(void 0,i);this._escapeParameterHtml&&(l.params=(null!=(s=l.params)&&Object.keys(s).forEach(function(t){"string"==typeof s[t]&&(s[t]=s[t].replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"))}),s));var c=l.locale||e,f=this._translate(n,c,this.fallbackLocale,t,r,"string",l.params);if(this._isFallbackRoot(f)){if(!this._root)throw Error("unexpected error");return(a=this._root).$t.apply(a,[t].concat(i))}return f=this._warnDefault(c,t,f,r,i,"string"),this._postTranslation&&null!=f&&(f=this._postTranslation(f,t)),f},nt.prototype.t=function(t){for(var e,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return(e=this)._t.apply(e,[t,this.locale,this._getMessages(),null].concat(n))},nt.prototype._i=function(t,e,n,r,a){var i=this._translate(n,e,this.fallbackLocale,t,r,"raw",a);if(this._isFallbackRoot(i)){if(!this._root)throw Error("unexpected error");return this._root.$i18n.i(t,e,a)}return this._warnDefault(e,t,i,r,[a],"raw")},nt.prototype.i=function(t,e,n){return t?(a(e)||(e=this.locale),this._i(t,e,this._getMessages(),null,n)):""},nt.prototype._tc=function(t,e,n,r,a){for(var i,o=[],s=arguments.length-5;s-- >0;)o[s]=arguments[s+5];if(!t)return"";void 0===a&&(a=1);var l={count:a,n:a},c=u.apply(void 0,o);return c.params=Object.assign(l,c.params),o=null===c.locale?[c.params]:[c.locale,c.params],this.fetchChoice((i=this)._t.apply(i,[t,e,n,r].concat(o)),a)},nt.prototype.fetchChoice=function(t,e){if(!t||!a(t))return null;var n=t.split("|");return n[e=this.getChoiceIndex(e,n.length)]?n[e].trim():t},nt.prototype.tc=function(t,e){for(var n,r=[],a=arguments.length-2;a-- >0;)r[a]=arguments[a+2];return(n=this)._tc.apply(n,[t,this.locale,this._getMessages(),null,e].concat(r))},nt.prototype._te=function(t,e,n){for(var r=[],a=arguments.length-3;a-- >0;)r[a]=arguments[a+3];var i=u.apply(void 0,r).locale||e;return this._exist(n[i],t)},nt.prototype.te=function(t,e){return this._te(t,this.locale,this._getMessages(),e)},nt.prototype.getLocaleMessage=function(t){return f(this._vm.messages[t]||{})},nt.prototype.setLocaleMessage=function(t,e){"warn"!==this._warnHtmlInMessage&&"error"!==this._warnHtmlInMessage||this._checkLocaleMessage(t,this._warnHtmlInMessage,e),this._vm.$set(this._vm.messages,t,e)},nt.prototype.mergeLocaleMessage=function(t,e){"warn"!==this._warnHtmlInMessage&&"error"!==this._warnHtmlInMessage||this._checkLocaleMessage(t,this._warnHtmlInMessage,e),this._vm.$set(this._vm.messages,t,_(void 0!==this._vm.messages[t]&&Object.keys(this._vm.messages[t]).length?this._vm.messages[t]:{},e))},nt.prototype.getDateTimeFormat=function(t){return f(this._vm.dateTimeFormats[t]||{})},nt.prototype.setDateTimeFormat=function(t,e){this._vm.$set(this._vm.dateTimeFormats,t,e),this._clearDateTimeFormat(t,e)},nt.prototype.mergeDateTimeFormat=function(t,e){this._vm.$set(this._vm.dateTimeFormats,t,_(this._vm.dateTimeFormats[t]||{},e)),this._clearDateTimeFormat(t,e)},nt.prototype._clearDateTimeFormat=function(t,e){for(var n in e){var r=t+"__"+n;this._dateTimeFormatters.hasOwnProperty(r)&&delete this._dateTimeFormatters[r]}},nt.prototype._localizeDateTime=function(t,e,n,r,a){for(var i=e,o=r[i],s=this._getLocaleChain(e,n),c=0;c<s.length;c++){var u=s[c];if(i=u,!l(o=r[u])&&!l(o[a]))break}if(l(o)||l(o[a]))return null;var f=o[a],h=i+"__"+a,p=this._dateTimeFormatters[h];return p||(p=this._dateTimeFormatters[h]=new Intl.DateTimeFormat(i,f)),p.format(t)},nt.prototype._d=function(t,e,n){if(!n)return new Intl.DateTimeFormat(e).format(t);var r=this._localizeDateTime(t,e,this.fallbackLocale,this._getDateTimeFormats(),n);if(this._isFallbackRoot(r)){if(!this._root)throw Error("unexpected error");return this._root.$i18n.d(t,n,e)}return r||""},nt.prototype.d=function(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];var i=this.locale,o=null;return 1===e.length?a(e[0])?o=e[0]:r(e[0])&&(e[0].locale&&(i=e[0].locale),e[0].key&&(o=e[0].key)):2===e.length&&(a(e[0])&&(o=e[0]),a(e[1])&&(i=e[1])),this._d(t,i,o)},nt.prototype.getNumberFormat=function(t){return f(this._vm.numberFormats[t]||{})},nt.prototype.setNumberFormat=function(t,e){this._vm.$set(this._vm.numberFormats,t,e),this._clearNumberFormat(t,e)},nt.prototype.mergeNumberFormat=function(t,e){this._vm.$set(this._vm.numberFormats,t,_(this._vm.numberFormats[t]||{},e)),this._clearNumberFormat(t,e)},nt.prototype._clearNumberFormat=function(t,e){for(var n in e){var r=t+"__"+n;this._numberFormatters.hasOwnProperty(r)&&delete this._numberFormatters[r]}},nt.prototype._getNumberFormatter=function(t,e,n,r,a,i){for(var o=e,s=r[o],c=this._getLocaleChain(e,n),u=0;u<c.length;u++){var f=c[u];if(o=f,!l(s=r[f])&&!l(s[a]))break}if(l(s)||l(s[a]))return null;var h,p=s[a];if(i)h=new Intl.NumberFormat(o,Object.assign({},p,i));else{var m=o+"__"+a;(h=this._numberFormatters[m])||(h=this._numberFormatters[m]=new Intl.NumberFormat(o,p))}return h},nt.prototype._n=function(t,e,n,r){if(!nt.availabilities.numberFormat)return"";if(!n)return(r?new Intl.NumberFormat(e,r):new Intl.NumberFormat(e)).format(t);var a=this._getNumberFormatter(t,e,this.fallbackLocale,this._getNumberFormats(),n,r),i=a&&a.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},r))}return i||""},nt.prototype.n=function(e){for(var n=[],i=arguments.length-1;i-- >0;)n[i]=arguments[i+1];var o=this.locale,s=null,l=null;return 1===n.length?a(n[0])?s=n[0]:r(n[0])&&(n[0].locale&&(o=n[0].locale),n[0].key&&(s=n[0].key),l=Object.keys(n[0]).reduce(function(e,r){var a;return h(t,r)?Object.assign({},e,((a={})[r]=n[0][r],a)):e},null)):2===n.length&&(a(n[0])&&(s=n[0]),a(n[1])&&(o=n[1])),this._n(e,o,s,l)},nt.prototype._ntp=function(t,e,n,r){if(!nt.availabilities.numberFormat)return[];if(!n)return(r?new Intl.NumberFormat(e,r):new Intl.NumberFormat(e)).formatToParts(t);var a=this._getNumberFormatter(t,e,this.fallbackLocale,this._getNumberFormats(),n,r),i=a&&a.formatToParts(t);if(this._isFallbackRoot(i)){if(!this._root)throw Error("unexpected error");return this._root.$i18n._ntp(t,e,n,r)}return i||[]},Object.defineProperties(nt.prototype,rt),Object.defineProperty(nt,"availabilities",{get:function(){if(!G){var t="undefined"!=typeof Intl;G={dateTimeFormat:t&&void 0!==Intl.DateTimeFormat,numberFormat:t&&void 0!==Intl.NumberFormat}}return G}}),nt.install=I,nt.version="8.24.2",nt},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueI18n=e();
|
|
6
|
+
var t,e;t=this,e=function(){"use strict";var t=["compactDisplay","currency","currencyDisplay","currencySign","localeMatcher","notation","numberingSystem","signDisplay","style","unit","unitDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function e(t,e){"undefined"!=typeof console&&(console.warn("[vue-i18n] "+t),e&&console.warn(e.stack))}var n=Array.isArray;function r(t){return null!==t&&"object"==typeof t}function a(t){return"string"==typeof t}var i=Object.prototype.toString,o="[object Object]";function s(t){return i.call(t)===o}function l(t){return null==t}function c(t){return"function"==typeof t}function u(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];var a=null,i=null;return 1===t.length?r(t[0])||n(t[0])?i=t[0]:"string"==typeof t[0]&&(a=t[0]):2===t.length&&("string"==typeof t[0]&&(a=t[0]),(r(t[1])||n(t[1]))&&(i=t[1])),{locale:a,params:i}}function h(t){return JSON.parse(JSON.stringify(t))}function f(t,e){return!!~t.indexOf(e)}var p=Object.prototype.hasOwnProperty;function m(t,e){return p.call(t,e)}function _(t){for(var e=arguments,n=Object(t),a=1;a<arguments.length;a++){var i=e[a];if(null!=i){var o=void 0;for(o in i)m(i,o)&&(r(i[o])?n[o]=_(n[o],i[o]):n[o]=i[o])}}return n}function g(t,e){if(t===e)return!0;var a=r(t),i=r(e);if(!a||!i)return!a&&!i&&String(t)===String(e);try{var o=n(t),s=n(e);if(o&&s)return t.length===e.length&&t.every(function(t,n){return g(t,e[n])});if(o||s)return!1;var l=Object.keys(t),c=Object.keys(e);return l.length===c.length&&l.every(function(n){return g(t[n],e[n])})}catch(t){return!1}}var v={beforeCreate:function(){var t=this.$options;if(t.i18n=t.i18n||(t.__i18n?{}:null),t.i18n){if(t.i18n instanceof nt){if(t.__i18n)try{var e=t.i18n&&t.i18n.messages?t.i18n.messages:{};t.__i18n.forEach(function(t){e=_(e,JSON.parse(t))}),Object.keys(e).forEach(function(n){t.i18n.mergeLocaleMessage(n,e[n])})}catch(t){}this._i18n=t.i18n,this._i18nWatcher=this._i18n.watchI18nData()}else if(s(t.i18n)){var n=this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof nt?this.$root.$i18n:null;if(n&&(t.i18n.root=this.$root,t.i18n.formatter=n.formatter,t.i18n.fallbackLocale=n.fallbackLocale,t.i18n.formatFallbackMessages=n.formatFallbackMessages,t.i18n.silentTranslationWarn=n.silentTranslationWarn,t.i18n.silentFallbackWarn=n.silentFallbackWarn,t.i18n.pluralizationRules=n.pluralizationRules,t.i18n.preserveDirectiveContent=n.preserveDirectiveContent),t.__i18n)try{var r=t.i18n&&t.i18n.messages?t.i18n.messages:{};t.__i18n.forEach(function(t){r=_(r,JSON.parse(t))}),t.i18n.messages=r}catch(t){}var a=t.i18n.sharedMessages;a&&s(a)&&(t.i18n.messages=_(t.i18n.messages,a)),this._i18n=new nt(t.i18n),this._i18nWatcher=this._i18n.watchI18nData(),(void 0===t.i18n.sync||t.i18n.sync)&&(this._localeWatcher=this.$i18n.watchLocale()),n&&n.onComponentInstanceCreated(this._i18n)}}else this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof nt?this._i18n=this.$root.$i18n:t.parent&&t.parent.$i18n&&t.parent.$i18n instanceof nt&&(this._i18n=t.parent.$i18n)},beforeMount:function(){var t=this.$options;t.i18n=t.i18n||(t.__i18n?{}:null),t.i18n?t.i18n instanceof nt?(this._i18n.subscribeDataChanging(this),this._subscribing=!0):s(t.i18n)&&(this._i18n.subscribeDataChanging(this),this._subscribing=!0):this.$root&&this.$root.$i18n&&this.$root.$i18n instanceof nt?(this._i18n.subscribeDataChanging(this),this._subscribing=!0):t.parent&&t.parent.$i18n&&t.parent.$i18n instanceof nt&&(this._i18n.subscribeDataChanging(this),this._subscribing=!0)},mounted:function(){this!==this.$root&&this.$options.__INTLIFY_META__&&this.$el&&this.$el.setAttribute("data-intlify",this.$options.__INTLIFY_META__)},beforeDestroy:function(){if(this._i18n){var t=this;this.$nextTick(function(){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)})}}},b={name:"i18n",functional:!0,props:{tag:{type:[String,Boolean,Object],default:"span"},path:{type:String,required:!0},locale:{type:String},places:{type:[Array,Object]}},render:function(t,e){var n=e.data,r=e.parent,a=e.props,i=e.slots,o=r.$i18n;if(o){var s=a.path,l=a.locale,c=a.places,u=i(),h=o.i(s,l,function(t){var e;for(e in t)if("default"!==e)return!1;return Boolean(e)}(u)||c?function(t,e){var n=e?function(t){return Array.isArray(t)?t.reduce(y,{}):Object.assign({},t)}(e):{};if(!t)return n;var r=(t=t.filter(function(t){return t.tag||""!==t.text.trim()})).every(F);return t.reduce(r?d:y,n)}(u.default,c):u),f=a.tag&&!0!==a.tag||!1===a.tag?a.tag:"span";return f?t(f,n,h):h}}};function d(t,e){return e.data&&e.data.attrs&&e.data.attrs.place&&(t[e.data.attrs.place]=e),t}function y(t,e,n){return t[n]=e,t}function F(t){return Boolean(t.data&&t.data.attrs&&t.data.attrs.place)}var k,w={name:"i18n-n",functional:!0,props:{tag:{type:[String,Boolean,Object],default:"span"},value:{type:Number,required:!0},format:{type:[String,Object]},locale:{type:String}},render:function(e,n){var i=n.props,o=n.parent,s=n.data,l=o.$i18n;if(!l)return null;var c=null,u=null;a(i.format)?c=i.format:r(i.format)&&(i.format.key&&(c=i.format.key),u=Object.keys(i.format).reduce(function(e,n){var r;return f(t,n)?Object.assign({},e,((r={})[n]=i.format[n],r)):e},null));var h=i.locale||l.locale,p=l._ntp(i.value,h,c,u),m=p.map(function(t,e){var n,r=s.scopedSlots&&s.scopedSlots[t.type];return r?r(((n={})[t.type]=t.value,n.index=e,n.parts=p,n)):t.value}),_=i.tag&&!0!==i.tag||!1===i.tag?i.tag:"span";return _?e(_,{attrs:s.attrs,class:s.class,staticClass:s.staticClass},m):m}};function $(t,e,n){C(t,n)&&L(t,e,n)}function M(t,e,n,r){if(C(t,n)){var a=n.context.$i18n;(function(t,e){var n=e.context;return t._locale===n.$i18n.locale})(t,n)&&g(e.value,e.oldValue)&&g(t._localeMessage,a.getLocaleMessage(a.locale))||L(t,e,n)}}function T(t,n,r,a){if(r.context){var i=r.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}else e("Vue instance does not exists in VNode context")}function C(t,n){var r=n.context;return r?!!r.$i18n||(e("VueI18n instance does not exists in Vue instance"),!1):(e("Vue instance does not exists in VNode context"),!1)}function L(t,n,r){var i,o,l=function(t){var e,n,r,i;a(t)?e=t:s(t)&&(e=t.path,n=t.locale,r=t.args,i=t.choice);return{path:e,locale:n,args:r,choice:i}}(n.value),c=l.path,u=l.locale,h=l.args,f=l.choice;if(c||u||h)if(c){var p=r.context;t._vt=t.textContent=null!=f?(i=p.$i18n).tc.apply(i,[c,f].concat(I(u,h))):(o=p.$i18n).t.apply(o,[c].concat(I(u,h))),t._locale=p.$i18n.locale,t._localeMessage=p.$i18n.getLocaleMessage(p.$i18n.locale)}else e("`path` is required in v-t directive");else e("value type not supported")}function I(t,e){var n=[];return t&&n.push(t),e&&(Array.isArray(e)||s(e))&&n.push(e),n}function D(t){D.installed=!0;(k=t).version&&Number(k.version.split(".")[0]);!function(t){t.prototype.hasOwnProperty("$i18n")||Object.defineProperty(t.prototype,"$i18n",{get:function(){return this._i18n}}),t.prototype.$t=function(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];var r=this.$i18n;return r._t.apply(r,[t,r.locale,r._getMessages(),this].concat(e))},t.prototype.$tc=function(t,e){for(var n=[],r=arguments.length-2;r-- >0;)n[r]=arguments[r+2];var a=this.$i18n;return a._tc.apply(a,[t,a.locale,a._getMessages(),this,e].concat(n))},t.prototype.$te=function(t,e){var n=this.$i18n;return n._te(t,n.locale,n._getMessages(),e)},t.prototype.$d=function(t){for(var e,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return(e=this.$i18n).d.apply(e,[t].concat(n))},t.prototype.$n=function(t){for(var e,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return(e=this.$i18n).n.apply(e,[t].concat(n))}}(k),k.mixin(v),k.directive("t",{bind:$,update:M,unbind:T}),k.component(b.name,b),k.component(w.name,w),k.config.optionMergeStrategies.i18n=function(t,e){return void 0===e?t:e}}var O=function(){this._caches=Object.create(null)};O.prototype.interpolate=function(t,e){if(!e)return[t];var n=this._caches[t];return n||(n=function(t){var e=[],n=0,r="";for(;n<t.length;){var a=t[n++];if("{"===a){r&&e.push({type:"text",value:r}),r="";var i="";for(a=t[n++];void 0!==a&&"}"!==a;)i+=a,a=t[n++];var o="}"===a,s=x.test(i)?"list":o&&j.test(i)?"named":"unknown";e.push({value:i,type:s})}else"%"===a?"{"!==t[n]&&(r+=a):r+=a}return r&&e.push({type:"text",value:r}),e}(t),this._caches[t]=n),function(t,e){var n=[],a=0,i=Array.isArray(e)?"list":r(e)?"named":"unknown";if("unknown"===i)return n;for(;a<t.length;){var o=t[a];switch(o.type){case"text":n.push(o.value);break;case"list":n.push(e[parseInt(o.value,10)]);break;case"named":"named"===i&&n.push(e[o.value])}a++}return n}(n,e)};var x=/^(?:\d)+/,j=/^(?:\w)+/,W=0,N=1,S=2,H=3,P=0,R=4,E=5,A=6,V=7,z=8,B=[];B[P]={ws:[P],ident:[3,W],"[":[R],eof:[V]},B[1]={ws:[1],".":[2],"[":[R],eof:[V]},B[2]={ws:[2],ident:[3,W],0:[3,W],number:[3,W]},B[3]={ident:[3,W],0:[3,W],number:[3,W],ws:[1,N],".":[2,N],"[":[R,N],eof:[V,N]},B[R]={"'":[E,W],'"':[A,W],"[":[R,S],"]":[1,H],eof:z,else:[R,W]},B[E]={"'":[R,W],eof:z,else:[E,W]},B[A]={'"':[R,W],eof:z,else:[A,W]};var U=/^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;function q(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 J(t){var e,n,r,a=t.trim();return("0"!==t.charAt(0)||!isNaN(t))&&(r=a,U.test(r)?(n=(e=a).charCodeAt(0))!==e.charCodeAt(e.length-1)||34!==n&&39!==n?e:e.slice(1,-1):"*"+a)}var Y=function(){this._cache=Object.create(null)};Y.prototype.parsePath=function(t){var e=this._cache[t];return e||(e=function(t){var e,n,r,a,i,o,s,l=[],c=-1,u=P,h=0,f=[];function p(){var e=t[c+1];if(u===E&&"'"===e||u===A&&'"'===e)return c++,r="\\"+e,f[W](),!0}for(f[N]=function(){void 0!==n&&(l.push(n),n=void 0)},f[W]=function(){void 0===n?n=r:n+=r},f[S]=function(){f[W](),h++},f[H]=function(){if(h>0)h--,u=R,f[W]();else{if(h=0,void 0===n)return!1;if(!1===(n=J(n)))return!1;f[N]()}};null!==u;)if("\\"!==(e=t[++c])||!p()){if(a=q(e),(i=(s=B[u])[a]||s.else||z)===z)return;if(u=i[0],(o=f[i[1]])&&(r=void 0===(r=i[2])?e:r,!1===o()))return;if(u===V)return l}}(t))&&(this._cache[t]=e),e||[]},Y.prototype.getPathValue=function(t,e){if(!r(t))return null;var n=this.parsePath(e);if(0===n.length)return null;for(var a=n.length,i=t,o=0;o<a;){var s=i[n[o]];if(null==s)return null;i=s,o++}return i};var G,X=/<\/?[\w\s="/.':;#-\/]+>/,Z=/(?:@(?:\.[a-z]+)?:(?:[\w\-_|.]+|\([\w\-_|.]+\)))/g,K=/^@(?:\.([a-z]+))?:/,Q=/[()]/g,tt={upper:function(t){return t.toLocaleUpperCase()},lower:function(t){return t.toLocaleLowerCase()},capitalize:function(t){return""+t.charAt(0).toLocaleUpperCase()+t.substr(1)}},et=new O,nt=function(t){var e=this;void 0===t&&(t={}),!k&&"undefined"!=typeof window&&window.Vue&&D(window.Vue);var n=t.locale||"en-US",r=!1!==t.fallbackLocale&&(t.fallbackLocale||"en-US"),a=t.messages||{},i=t.dateTimeFormats||{},o=t.numberFormats||{};this._vm=null,this._formatter=t.formatter||et,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 Y,this._dataListeners=new Set,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._escapeParameterHtml=t.escapeParameterHtml||!1,this.getChoiceIndex=function(t,n){var r=Object.getPrototypeOf(e);if(r&&r.getChoiceIndex)return r.getChoiceIndex.call(e,t,n);var a,i;return e.locale in e.pluralizationRules?e.pluralizationRules[e.locale].apply(e,[t,n]):(a=t,i=n,a=Math.abs(a),2===i?a?a>1?1:0:1:a?Math.min(a,2):0)},this._exist=function(t,n){return!(!t||!n)&&(!l(e._path.getPathValue(t,n))||!!t[n])},"warn"!==this._warnHtmlInMessage&&"error"!==this._warnHtmlInMessage||Object.keys(a).forEach(function(t){e._checkLocaleMessage(t,e._warnHtmlInMessage,a[t])}),this._initVM({locale:n,fallbackLocale:r,messages:a,dateTimeFormats:i,numberFormats:o})},rt={vm:{configurable:!0},messages:{configurable:!0},dateTimeFormats:{configurable:!0},numberFormats:{configurable:!0},availableLocales:{configurable:!0},locale:{configurable:!0},fallbackLocale:{configurable:!0},formatFallbackMessages:{configurable:!0},missing:{configurable:!0},formatter:{configurable:!0},silentTranslationWarn:{configurable:!0},silentFallbackWarn:{configurable:!0},preserveDirectiveContent:{configurable:!0},warnHtmlInMessage:{configurable:!0},postTranslation:{configurable:!0}};return nt.prototype._checkLocaleMessage=function(t,r,i){var o=function(t,r,i,l){if(s(i))Object.keys(i).forEach(function(e){var n=i[e];s(n)?(l.push(e),l.push("."),o(t,r,n,l),l.pop(),l.pop()):(l.push(e),o(t,r,n,l),l.pop())});else if(n(i))i.forEach(function(e,n){s(e)?(l.push("["+n+"]"),l.push("."),o(t,r,e,l),l.pop(),l.pop()):(l.push("["+n+"]"),o(t,r,e,l),l.pop())});else if(a(i)){if(X.test(i)){var c="Detected HTML in message '"+i+"' of keypath '"+l.join("")+"' at '"+r+"'. Consider component interpolation with '<i18n>' to avoid XSS. See https://bit.ly/2ZqJzkp";"warn"===t?e(c):"error"===t&&function(t,e){"undefined"!=typeof console&&(console.error("[vue-i18n] "+t),e&&console.error(e.stack))}(c)}}};o(r,t,i,[])},nt.prototype._initVM=function(t){var e=k.config.silent;k.config.silent=!0,this._vm=new k({data:t}),k.config.silent=e},nt.prototype.destroyVM=function(){this._vm.$destroy()},nt.prototype.subscribeDataChanging=function(t){this._dataListeners.add(t)},nt.prototype.unsubscribeDataChanging=function(t){!function(t,e){if(t.delete(e));}(this._dataListeners,t)},nt.prototype.watchI18nData=function(){var t=this;return this._vm.$watch("$data",function(){for(var e,n,r=(e=t._dataListeners,n=[],e.forEach(function(t){return n.push(t)}),n),a=r.length;a--;)k.nextTick(function(){r[a]&&r[a].$forceUpdate()})},{deep:!0})},nt.prototype.watchLocale=function(){if(!this._sync||!this._root)return null;var t=this._vm;return this._root.$i18n.vm.$watch("locale",function(e){t.$set(t,"locale",e),t.$forceUpdate()},{immediate:!0})},nt.prototype.onComponentInstanceCreated=function(t){this._componentInstanceCreatedListener&&this._componentInstanceCreatedListener(t,this)},rt.vm.get=function(){return this._vm},rt.messages.get=function(){return h(this._getMessages())},rt.dateTimeFormats.get=function(){return h(this._getDateTimeFormats())},rt.numberFormats.get=function(){return h(this._getNumberFormats())},rt.availableLocales.get=function(){return Object.keys(this.messages).sort()},rt.locale.get=function(){return this._vm.locale},rt.locale.set=function(t){this._vm.$set(this._vm,"locale",t)},rt.fallbackLocale.get=function(){return this._vm.fallbackLocale},rt.fallbackLocale.set=function(t){this._localeChainCache={},this._vm.$set(this._vm,"fallbackLocale",t)},rt.formatFallbackMessages.get=function(){return this._formatFallbackMessages},rt.formatFallbackMessages.set=function(t){this._formatFallbackMessages=t},rt.missing.get=function(){return this._missing},rt.missing.set=function(t){this._missing=t},rt.formatter.get=function(){return this._formatter},rt.formatter.set=function(t){this._formatter=t},rt.silentTranslationWarn.get=function(){return this._silentTranslationWarn},rt.silentTranslationWarn.set=function(t){this._silentTranslationWarn=t},rt.silentFallbackWarn.get=function(){return this._silentFallbackWarn},rt.silentFallbackWarn.set=function(t){this._silentFallbackWarn=t},rt.preserveDirectiveContent.get=function(){return this._preserveDirectiveContent},rt.preserveDirectiveContent.set=function(t){this._preserveDirectiveContent=t},rt.warnHtmlInMessage.get=function(){return this._warnHtmlInMessage},rt.warnHtmlInMessage.set=function(t){var e=this,n=this._warnHtmlInMessage;if(this._warnHtmlInMessage=t,n!==t&&("warn"===t||"error"===t)){var r=this._getMessages();Object.keys(r).forEach(function(t){e._checkLocaleMessage(t,e._warnHtmlInMessage,r[t])})}},rt.postTranslation.get=function(){return this._postTranslation},rt.postTranslation.set=function(t){this._postTranslation=t},nt.prototype._getMessages=function(){return this._vm.messages},nt.prototype._getDateTimeFormats=function(){return this._vm.dateTimeFormats},nt.prototype._getNumberFormats=function(){return this._vm.numberFormats},nt.prototype._warnDefault=function(t,e,n,r,i,o){if(!l(n))return n;if(this._missing){var s=this._missing.apply(null,[t,e,r,i]);if(a(s))return s}if(this._formatFallbackMessages){var c=u.apply(void 0,i);return this._render(e,o,c.params,e)}return e},nt.prototype._isFallbackRoot=function(t){return!t&&!l(this._root)&&this._fallbackRoot},nt.prototype._isSilentFallbackWarn=function(t){return this._silentFallbackWarn instanceof RegExp?this._silentFallbackWarn.test(t):this._silentFallbackWarn},nt.prototype._isSilentFallback=function(t,e){return this._isSilentFallbackWarn(e)&&(this._isFallbackRoot()||t!==this.fallbackLocale)},nt.prototype._isSilentTranslationWarn=function(t){return this._silentTranslationWarn instanceof RegExp?this._silentTranslationWarn.test(t):this._silentTranslationWarn},nt.prototype._interpolate=function(t,e,r,i,o,u,h){if(!e)return null;var f,p=this._path.getPathValue(e,r);if(n(p)||s(p))return p;if(l(p)){if(!s(e))return null;if(!a(f=e[r])&&!c(f))return null}else{if(!a(p)&&!c(p))return null;f=p}return a(f)&&(f.indexOf("@:")>=0||f.indexOf("@.")>=0)&&(f=this._link(t,e,f,i,"raw",u,h)),this._render(f,o,u,r)},nt.prototype._link=function(t,e,r,a,i,o,s){var l=r,c=l.match(Z);for(var u in c)if(c.hasOwnProperty(u)){var h=c[u],p=h.match(K),m=p[0],_=p[1],g=h.replace(m,"").replace(Q,"");if(f(s,g))return l;s.push(g);var v=this._interpolate(t,e,g,a,"raw"===i?"string":i,"raw"===i?void 0:o,s);if(this._isFallbackRoot(v)){if(!this._root)throw Error("unexpected error");var b=this._root.$i18n;v=b._translate(b._getMessages(),b.locale,b.fallbackLocale,g,a,i,o)}v=this._warnDefault(t,g,v,a,n(o)?o:[o],i),this._modifiers.hasOwnProperty(_)?v=this._modifiers[_](v):tt.hasOwnProperty(_)&&(v=tt[_](v)),s.pop(),l=v?l.replace(h,v):l}return l},nt.prototype._createMessageContext=function(t,e,a,i){var o=this,s=n(t)?t:[],l=r(t)?t:{},c=this._getMessages(),u=this.locale;return{list:function(t){return s[t]},named:function(t){return l[t]},values:t,formatter:e,path:a,messages:c,locale:u,linked:function(t){return o._interpolate(u,c[u]||{},t,null,i,void 0,[t])}}},nt.prototype._render=function(t,e,n,r){if(c(t))return t(this._createMessageContext(n,this._formatter||et,r,e));var i=this._formatter.interpolate(t,n,r);return i||(i=et.interpolate(t,n,r)),"string"!==e||a(i)?i:i.join("")},nt.prototype._appendItemToChain=function(t,e,n){var r=!1;return f(t,e)||(r=!0,e&&(r="!"!==e[e.length-1],e=e.replace(/!/g,""),t.push(e),n&&n[e]&&(r=n[e]))),r},nt.prototype._appendLocaleToChain=function(t,e,n){var r,a=e.split("-");do{var i=a.join("-");r=this._appendItemToChain(t,i,n),a.splice(-1,1)}while(a.length&&!0===r);return r},nt.prototype._appendBlockToChain=function(t,e,n){for(var r=!0,i=0;i<e.length&&"boolean"==typeof r;i++){var o=e[i];a(o)&&(r=this._appendLocaleToChain(t,o,n))}return r},nt.prototype._getLocaleChain=function(t,e){if(""===t)return[];this._localeChainCache||(this._localeChainCache={});var i=this._localeChainCache[t];if(!i){e||(e=this.fallbackLocale),i=[];for(var o,s=[t];n(s);)s=this._appendBlockToChain(i,s,e);(s=a(o=n(e)?e:r(e)?e.default?e.default:null:e)?[o]:o)&&this._appendBlockToChain(i,s,null),this._localeChainCache[t]=i}return i},nt.prototype._translate=function(t,e,n,r,a,i,o){for(var s,c=this._getLocaleChain(e,n),u=0;u<c.length;u++){var h=c[u];if(!l(s=this._interpolate(h,t[h],r,a,i,o,[r])))return s}return null},nt.prototype._t=function(t,e,n,r){for(var a,i=[],o=arguments.length-4;o-- >0;)i[o]=arguments[o+4];if(!t)return"";var s,l=u.apply(void 0,i);this._escapeParameterHtml&&(l.params=(null!=(s=l.params)&&Object.keys(s).forEach(function(t){"string"==typeof s[t]&&(s[t]=s[t].replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"))}),s));var c=l.locale||e,h=this._translate(n,c,this.fallbackLocale,t,r,"string",l.params);if(this._isFallbackRoot(h)){if(!this._root)throw Error("unexpected error");return(a=this._root).$t.apply(a,[t].concat(i))}return h=this._warnDefault(c,t,h,r,i,"string"),this._postTranslation&&null!=h&&(h=this._postTranslation(h,t)),h},nt.prototype.t=function(t){for(var e,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return(e=this)._t.apply(e,[t,this.locale,this._getMessages(),null].concat(n))},nt.prototype._i=function(t,e,n,r,a){var i=this._translate(n,e,this.fallbackLocale,t,r,"raw",a);if(this._isFallbackRoot(i)){if(!this._root)throw Error("unexpected error");return this._root.$i18n.i(t,e,a)}return this._warnDefault(e,t,i,r,[a],"raw")},nt.prototype.i=function(t,e,n){return t?(a(e)||(e=this.locale),this._i(t,e,this._getMessages(),null,n)):""},nt.prototype._tc=function(t,e,n,r,a){for(var i,o=[],s=arguments.length-5;s-- >0;)o[s]=arguments[s+5];if(!t)return"";void 0===a&&(a=1);var l={count:a,n:a},c=u.apply(void 0,o);return c.params=Object.assign(l,c.params),o=null===c.locale?[c.params]:[c.locale,c.params],this.fetchChoice((i=this)._t.apply(i,[t,e,n,r].concat(o)),a)},nt.prototype.fetchChoice=function(t,e){if(!t||!a(t))return null;var n=t.split("|");return n[e=this.getChoiceIndex(e,n.length)]?n[e].trim():t},nt.prototype.tc=function(t,e){for(var n,r=[],a=arguments.length-2;a-- >0;)r[a]=arguments[a+2];return(n=this)._tc.apply(n,[t,this.locale,this._getMessages(),null,e].concat(r))},nt.prototype._te=function(t,e,n){for(var r=[],a=arguments.length-3;a-- >0;)r[a]=arguments[a+3];var i=u.apply(void 0,r).locale||e;return this._exist(n[i],t)},nt.prototype.te=function(t,e){return this._te(t,this.locale,this._getMessages(),e)},nt.prototype.getLocaleMessage=function(t){return h(this._vm.messages[t]||{})},nt.prototype.setLocaleMessage=function(t,e){"warn"!==this._warnHtmlInMessage&&"error"!==this._warnHtmlInMessage||this._checkLocaleMessage(t,this._warnHtmlInMessage,e),this._vm.$set(this._vm.messages,t,e)},nt.prototype.mergeLocaleMessage=function(t,e){"warn"!==this._warnHtmlInMessage&&"error"!==this._warnHtmlInMessage||this._checkLocaleMessage(t,this._warnHtmlInMessage,e),this._vm.$set(this._vm.messages,t,_(void 0!==this._vm.messages[t]&&Object.keys(this._vm.messages[t]).length?Object.assign({},this._vm.messages[t]):{},e))},nt.prototype.getDateTimeFormat=function(t){return h(this._vm.dateTimeFormats[t]||{})},nt.prototype.setDateTimeFormat=function(t,e){this._vm.$set(this._vm.dateTimeFormats,t,e),this._clearDateTimeFormat(t,e)},nt.prototype.mergeDateTimeFormat=function(t,e){this._vm.$set(this._vm.dateTimeFormats,t,_(this._vm.dateTimeFormats[t]||{},e)),this._clearDateTimeFormat(t,e)},nt.prototype._clearDateTimeFormat=function(t,e){for(var n in e){var r=t+"__"+n;this._dateTimeFormatters.hasOwnProperty(r)&&delete this._dateTimeFormatters[r]}},nt.prototype._localizeDateTime=function(t,e,n,r,a){for(var i=e,o=r[i],s=this._getLocaleChain(e,n),c=0;c<s.length;c++){var u=s[c];if(i=u,!l(o=r[u])&&!l(o[a]))break}if(l(o)||l(o[a]))return null;var h=o[a],f=i+"__"+a,p=this._dateTimeFormatters[f];return p||(p=this._dateTimeFormatters[f]=new Intl.DateTimeFormat(i,h)),p.format(t)},nt.prototype._d=function(t,e,n){if(!n)return new Intl.DateTimeFormat(e).format(t);var r=this._localizeDateTime(t,e,this.fallbackLocale,this._getDateTimeFormats(),n);if(this._isFallbackRoot(r)){if(!this._root)throw Error("unexpected error");return this._root.$i18n.d(t,n,e)}return r||""},nt.prototype.d=function(t){for(var e=[],n=arguments.length-1;n-- >0;)e[n]=arguments[n+1];var i=this.locale,o=null;return 1===e.length?a(e[0])?o=e[0]:r(e[0])&&(e[0].locale&&(i=e[0].locale),e[0].key&&(o=e[0].key)):2===e.length&&(a(e[0])&&(o=e[0]),a(e[1])&&(i=e[1])),this._d(t,i,o)},nt.prototype.getNumberFormat=function(t){return h(this._vm.numberFormats[t]||{})},nt.prototype.setNumberFormat=function(t,e){this._vm.$set(this._vm.numberFormats,t,e),this._clearNumberFormat(t,e)},nt.prototype.mergeNumberFormat=function(t,e){this._vm.$set(this._vm.numberFormats,t,_(this._vm.numberFormats[t]||{},e)),this._clearNumberFormat(t,e)},nt.prototype._clearNumberFormat=function(t,e){for(var n in e){var r=t+"__"+n;this._numberFormatters.hasOwnProperty(r)&&delete this._numberFormatters[r]}},nt.prototype._getNumberFormatter=function(t,e,n,r,a,i){for(var o=e,s=r[o],c=this._getLocaleChain(e,n),u=0;u<c.length;u++){var h=c[u];if(o=h,!l(s=r[h])&&!l(s[a]))break}if(l(s)||l(s[a]))return null;var f,p=s[a];if(i)f=new Intl.NumberFormat(o,Object.assign({},p,i));else{var m=o+"__"+a;(f=this._numberFormatters[m])||(f=this._numberFormatters[m]=new Intl.NumberFormat(o,p))}return f},nt.prototype._n=function(t,e,n,r){if(!nt.availabilities.numberFormat)return"";if(!n)return(r?new Intl.NumberFormat(e,r):new Intl.NumberFormat(e)).format(t);var a=this._getNumberFormatter(t,e,this.fallbackLocale,this._getNumberFormats(),n,r),i=a&&a.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},r))}return i||""},nt.prototype.n=function(e){for(var n=[],i=arguments.length-1;i-- >0;)n[i]=arguments[i+1];var o=this.locale,s=null,l=null;return 1===n.length?a(n[0])?s=n[0]:r(n[0])&&(n[0].locale&&(o=n[0].locale),n[0].key&&(s=n[0].key),l=Object.keys(n[0]).reduce(function(e,r){var a;return f(t,r)?Object.assign({},e,((a={})[r]=n[0][r],a)):e},null)):2===n.length&&(a(n[0])&&(s=n[0]),a(n[1])&&(o=n[1])),this._n(e,o,s,l)},nt.prototype._ntp=function(t,e,n,r){if(!nt.availabilities.numberFormat)return[];if(!n)return(r?new Intl.NumberFormat(e,r):new Intl.NumberFormat(e)).formatToParts(t);var a=this._getNumberFormatter(t,e,this.fallbackLocale,this._getNumberFormats(),n,r),i=a&&a.formatToParts(t);if(this._isFallbackRoot(i)){if(!this._root)throw Error("unexpected error");return this._root.$i18n._ntp(t,e,n,r)}return i||[]},Object.defineProperties(nt.prototype,rt),Object.defineProperty(nt,"availabilities",{get:function(){if(!G){var t="undefined"!=typeof Intl;G={dateTimeFormat:t&&void 0!==Intl.DateTimeFormat,numberFormat:t&&void 0!==Intl.NumberFormat}}return G}}),nt.install=D,nt.version="8.25.0",nt},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.VueI18n=e();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-i18n",
|
|
3
3
|
"description": "Internationalization plugin for Vue.js",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.25.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"babel-plugin-istanbul": "^6.0.0",
|
|
37
37
|
"babel-preset-power-assert": "^3.0.0",
|
|
38
38
|
"buble": "^0.19.3",
|
|
39
|
-
"chromedriver": "^
|
|
39
|
+
"chromedriver": "^90.0.0",
|
|
40
40
|
"core-js": "^3.6.5",
|
|
41
41
|
"cross-env": "^7.0.2",
|
|
42
42
|
"cross-spawn": "^7.0.3",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"karma": "^5.0.9",
|
|
54
54
|
"karma-chrome-launcher": "^3.1.0",
|
|
55
55
|
"karma-coverage": "^2.0.2",
|
|
56
|
-
"karma-firefox-launcher": "^1.1
|
|
56
|
+
"karma-firefox-launcher": "^2.1.1",
|
|
57
57
|
"karma-mocha": "^2.0.1",
|
|
58
58
|
"karma-mocha-reporter": "^2.2.5",
|
|
59
59
|
"karma-safari-launcher": "^1.0.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"rollup-plugin-node-resolve": "^3.4.0",
|
|
75
75
|
"rollup-plugin-replace": "^2.0.0",
|
|
76
76
|
"selenium-server": "^3.141.59",
|
|
77
|
-
"shipjs": "^0.
|
|
77
|
+
"shipjs": "^0.23.3",
|
|
78
78
|
"sinon": "^9.0.2",
|
|
79
79
|
"terser": "^3.17.0",
|
|
80
80
|
"typescript": "^3.9.3",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"vue-template-compiler": "^2.5.17",
|
|
84
84
|
"vuepress": "^1.5.0",
|
|
85
85
|
"webpack": "^4.43.0",
|
|
86
|
-
"webpack-cli": "^
|
|
86
|
+
"webpack-cli": "^4.7.2",
|
|
87
87
|
"webpack-dev-middleware": "^3.7.2",
|
|
88
88
|
"webpack-dev-server": "^3.11.0"
|
|
89
89
|
},
|
package/src/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
isFunction,
|
|
15
15
|
looseClone,
|
|
16
16
|
remove,
|
|
17
|
+
arrayFrom,
|
|
17
18
|
includes,
|
|
18
19
|
merge,
|
|
19
20
|
numberFormatKeys,
|
|
@@ -56,7 +57,7 @@ export default class VueI18n {
|
|
|
56
57
|
_dateTimeFormatters: Object
|
|
57
58
|
_numberFormatters: Object
|
|
58
59
|
_path: I18nPath
|
|
59
|
-
_dataListeners:
|
|
60
|
+
_dataListeners: Set<any>
|
|
60
61
|
_componentInstanceCreatedListener: ?ComponentInstanceCreatedListener
|
|
61
62
|
_preserveDirectiveContent: boolean
|
|
62
63
|
_warnHtmlInMessage: WarnHtmlInMessageLevel
|
|
@@ -105,7 +106,7 @@ export default class VueI18n {
|
|
|
105
106
|
this._dateTimeFormatters = {}
|
|
106
107
|
this._numberFormatters = {}
|
|
107
108
|
this._path = new I18nPath()
|
|
108
|
-
this._dataListeners =
|
|
109
|
+
this._dataListeners = new Set()
|
|
109
110
|
this._componentInstanceCreatedListener = options.componentInstanceCreatedListener || null
|
|
110
111
|
this._preserveDirectiveContent = options.preserveDirectiveContent === undefined
|
|
111
112
|
? false
|
|
@@ -240,7 +241,7 @@ export default class VueI18n {
|
|
|
240
241
|
}
|
|
241
242
|
|
|
242
243
|
subscribeDataChanging (vm: any): void {
|
|
243
|
-
this._dataListeners.
|
|
244
|
+
this._dataListeners.add(vm)
|
|
244
245
|
}
|
|
245
246
|
|
|
246
247
|
unsubscribeDataChanging (vm: any): void {
|
|
@@ -250,10 +251,11 @@ export default class VueI18n {
|
|
|
250
251
|
watchI18nData (): Function {
|
|
251
252
|
const self = this
|
|
252
253
|
return this._vm.$watch('$data', () => {
|
|
253
|
-
|
|
254
|
-
|
|
254
|
+
const listeners = arrayFrom(this._dataListeners)
|
|
255
|
+
let i = listeners.length
|
|
256
|
+
while(i--) {
|
|
255
257
|
Vue.nextTick(() => {
|
|
256
|
-
|
|
258
|
+
listeners[i] && listeners[i].$forceUpdate()
|
|
257
259
|
})
|
|
258
260
|
}
|
|
259
261
|
}, { deep: true })
|
|
@@ -437,6 +439,8 @@ export default class VueI18n {
|
|
|
437
439
|
// We are going to replace each of
|
|
438
440
|
// them with its translation
|
|
439
441
|
const matches: any = ret.match(linkKeyMatcher)
|
|
442
|
+
|
|
443
|
+
// eslint-disable-next-line no-autofix/prefer-const
|
|
440
444
|
for (let idx in matches) {
|
|
441
445
|
// ie compatible: filter custom array
|
|
442
446
|
// prototype method
|
|
@@ -499,20 +503,31 @@ export default class VueI18n {
|
|
|
499
503
|
return ret
|
|
500
504
|
}
|
|
501
505
|
|
|
502
|
-
_createMessageContext (values: any): MessageContext {
|
|
506
|
+
_createMessageContext (values: any, formatter: Formatter, path: string, interpolateMode: string): MessageContext {
|
|
503
507
|
const _list = isArray(values) ? values : []
|
|
504
508
|
const _named = isObject(values) ? values : {}
|
|
505
509
|
const list = (index: number): mixed => _list[index]
|
|
506
510
|
const named = (key: string): mixed => _named[key]
|
|
511
|
+
const messages = this._getMessages()
|
|
512
|
+
const locale = this.locale
|
|
513
|
+
|
|
507
514
|
return {
|
|
508
515
|
list,
|
|
509
|
-
named
|
|
516
|
+
named,
|
|
517
|
+
values,
|
|
518
|
+
formatter,
|
|
519
|
+
path,
|
|
520
|
+
messages,
|
|
521
|
+
locale,
|
|
522
|
+
linked: (linkedKey: string) => this._interpolate(locale, messages[locale] || {}, linkedKey, null, interpolateMode, undefined, [linkedKey])
|
|
510
523
|
}
|
|
511
524
|
}
|
|
512
525
|
|
|
513
526
|
_render (message: string | MessageFunction, interpolateMode: string, values: any, path: string): any {
|
|
514
527
|
if (isFunction(message)) {
|
|
515
|
-
return message(
|
|
528
|
+
return message(
|
|
529
|
+
this._createMessageContext(values, this._formatter || defaultFormatter, path, interpolateMode)
|
|
530
|
+
)
|
|
516
531
|
}
|
|
517
532
|
|
|
518
533
|
let ret = this._formatter.interpolate(message, values, path)
|
|
@@ -768,7 +783,7 @@ export default class VueI18n {
|
|
|
768
783
|
}
|
|
769
784
|
this._vm.$set(this._vm.messages, locale, merge(
|
|
770
785
|
typeof this._vm.messages[locale] !== 'undefined' && Object.keys(this._vm.messages[locale]).length
|
|
771
|
-
? this._vm.messages[locale]
|
|
786
|
+
? Object.assign({}, this._vm.messages[locale])
|
|
772
787
|
: {},
|
|
773
788
|
message
|
|
774
789
|
))
|
|
@@ -789,6 +804,7 @@ export default class VueI18n {
|
|
|
789
804
|
}
|
|
790
805
|
|
|
791
806
|
_clearDateTimeFormat (locale: Locale, format: DateTimeFormat): void {
|
|
807
|
+
// eslint-disable-next-line no-autofix/prefer-const
|
|
792
808
|
for (let key in format) {
|
|
793
809
|
const id = `${locale}__${key}`
|
|
794
810
|
|
|
@@ -906,6 +922,7 @@ export default class VueI18n {
|
|
|
906
922
|
}
|
|
907
923
|
|
|
908
924
|
_clearNumberFormat (locale: Locale, format: NumberFormat): void {
|
|
925
|
+
// eslint-disable-next-line no-autofix/prefer-const
|
|
909
926
|
for (let key in format) {
|
|
910
927
|
const id = `${locale}__${key}`
|
|
911
928
|
|
package/src/mixin.js
CHANGED
|
@@ -42,16 +42,6 @@ export default {
|
|
|
42
42
|
options.i18n.silentFallbackWarn = rootI18n.silentFallbackWarn
|
|
43
43
|
options.i18n.pluralizationRules = rootI18n.pluralizationRules
|
|
44
44
|
options.i18n.preserveDirectiveContent = rootI18n.preserveDirectiveContent
|
|
45
|
-
this.$root.$once('hook:beforeDestroy', () => {
|
|
46
|
-
options.i18n.root = null;
|
|
47
|
-
options.i18n.formatter = null;
|
|
48
|
-
options.i18n.fallbackLocale = null;
|
|
49
|
-
options.i18n.formatFallbackMessages = null;
|
|
50
|
-
options.i18n.silentTranslationWarn = null;
|
|
51
|
-
options.i18n.silentFallbackWarn = null;
|
|
52
|
-
options.i18n.pluralizationRules = null;
|
|
53
|
-
options.i18n.preserveDirectiveContent = null;
|
|
54
|
-
});
|
|
55
45
|
}
|
|
56
46
|
|
|
57
47
|
// init locale messages via custom blocks
|
package/src/util.js
CHANGED
|
@@ -102,15 +102,18 @@ export function looseClone (obj: Object): Object {
|
|
|
102
102
|
return JSON.parse(JSON.stringify(obj))
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
export function remove (arr:
|
|
106
|
-
if (arr.
|
|
107
|
-
|
|
108
|
-
if (index > -1) {
|
|
109
|
-
return arr.splice(index, 1)
|
|
110
|
-
}
|
|
105
|
+
export function remove (arr: Set<any>, item: any): Set<any> | void {
|
|
106
|
+
if (arr.delete(item)) {
|
|
107
|
+
return arr
|
|
111
108
|
}
|
|
112
109
|
}
|
|
113
110
|
|
|
111
|
+
export function arrayFrom (arr: Set<any>): Array<any> {
|
|
112
|
+
const ret = []
|
|
113
|
+
arr.forEach(a => ret.push(a))
|
|
114
|
+
return ret
|
|
115
|
+
}
|
|
116
|
+
|
|
114
117
|
export function includes (arr: Array<any>, item: any): boolean {
|
|
115
118
|
return !!~arr.indexOf(item)
|
|
116
119
|
}
|
|
@@ -203,4 +206,4 @@ export function escapeParams(params: any): any {
|
|
|
203
206
|
})
|
|
204
207
|
}
|
|
205
208
|
return params
|
|
206
|
-
}
|
|
209
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -9,6 +9,12 @@ declare namespace VueI18n {
|
|
|
9
9
|
interface MessageContext {
|
|
10
10
|
list(index: number): unknown
|
|
11
11
|
named(key: string): unknown
|
|
12
|
+
linked(key: string): VueI18n.TranslateResult
|
|
13
|
+
values: any
|
|
14
|
+
path: string
|
|
15
|
+
formatter: Formatter
|
|
16
|
+
messages: LocaleMessages
|
|
17
|
+
locale: Locale
|
|
12
18
|
}
|
|
13
19
|
type MessageFunction = (ctx: MessageContext) => string;
|
|
14
20
|
type LocaleMessage = string | MessageFunction | LocaleMessageObject | LocaleMessageArray;
|
|
@@ -187,7 +193,7 @@ export declare interface IVueI18n {
|
|
|
187
193
|
d(value: number | Date, options?: VueI18n.DateTimeFormatOptions): VueI18n.DateTimeFormatResult;
|
|
188
194
|
n(value: number, key?: VueI18n.Path, locale?: VueI18n.Locale): VueI18n.NumberFormatResult;
|
|
189
195
|
n(value: number, args?: { [key: string]: string }): VueI18n.NumberFormatResult;
|
|
190
|
-
n(value: number, options?: VueI18n.NumberFormatOptions): VueI18n.NumberFormatResult;
|
|
196
|
+
n(value: number, options?: VueI18n.NumberFormatOptions, locale?: VueI18n.Locale): VueI18n.NumberFormatResult;
|
|
191
197
|
getLocaleMessage(locale: VueI18n.Locale): VueI18n.LocaleMessageObject;
|
|
192
198
|
setLocaleMessage(locale: VueI18n.Locale, message: VueI18n.LocaleMessageObject): void;
|
|
193
199
|
mergeLocaleMessage(locale: VueI18n.Locale, message: VueI18n.LocaleMessageObject): void;
|
|
@@ -230,7 +236,7 @@ declare class VueI18n {
|
|
|
230
236
|
d(value: number | Date, options?: VueI18n.DateTimeFormatOptions): VueI18n.DateTimeFormatResult;
|
|
231
237
|
n(value: number, key?: VueI18n.Path, locale?: VueI18n.Locale): VueI18n.NumberFormatResult;
|
|
232
238
|
n(value: number, args?: { [key: string]: string }): VueI18n.NumberFormatResult;
|
|
233
|
-
n(value: number, options?: VueI18n.NumberFormatOptions): VueI18n.NumberFormatResult;
|
|
239
|
+
n(value: number, options?: VueI18n.NumberFormatOptions, locale?: VueI18n.Locale): VueI18n.NumberFormatResult;
|
|
234
240
|
|
|
235
241
|
getLocaleMessage(locale: VueI18n.Locale): VueI18n.LocaleMessageObject;
|
|
236
242
|
setLocaleMessage(locale: VueI18n.Locale, message: VueI18n.LocaleMessageObject): void;
|