imatrix-ui 2.8.97-dw-tmp2 → 2.8.97-dw-tmp4

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.
Files changed (107) hide show
  1. package/lib/super-ui.css +1 -0
  2. package/lib/super-ui.umd.min.js +36 -1
  3. package/package.json +1 -2
  4. package/src/i18n/i18n.js +1 -1
  5. package/src/i18n/langs/cn.js +1 -1
  6. package/src/i18n/langs/en.js +1 -1
  7. package/src/permission.js +1 -1
  8. package/src/plugins.js +4 -4
  9. package/src/store/modules/permission.js +5 -0
  10. package/src/styles/index.scss +2 -2
  11. package/src/utils/permissionAuth.js +6 -0
  12. package/src/utils/request.js +1 -1
  13. package/src/views/login/index.vue +1 -1
  14. package/lib/css/super-ui.common~46f24e9d.f712732a.css +0 -1
  15. package/lib/css/super-ui.common~60a56baa.e6f54088.css +0 -1
  16. package/lib/css/super-ui.common~691e02b5.3387eefb.css +0 -1
  17. package/lib/css/super-ui.common~e2e93592.e9ec19a9.css +0 -1
  18. package/lib/css/super-ui.umd.min~46f24e9d.f712732a.css +0 -1
  19. package/lib/css/super-ui.umd.min~60a56baa.e6f54088.css +0 -1
  20. package/lib/css/super-ui.umd.min~691e02b5.3387eefb.css +0 -1
  21. package/lib/css/super-ui.umd.min~e2e93592.e9ec19a9.css +0 -1
  22. package/lib/css/super-ui.umd~46f24e9d.f712732a.css +0 -1
  23. package/lib/css/super-ui.umd~60a56baa.e6f54088.css +0 -1
  24. package/lib/css/super-ui.umd~691e02b5.3387eefb.css +0 -1
  25. package/lib/css/super-ui.umd~e2e93592.e9ec19a9.css +0 -1
  26. package/lib/css/vendors~super-ui.common~253ae210.b57e4bfb.css +0 -1
  27. package/lib/css/vendors~super-ui.umd.min~253ae210.b57e4bfb.css +0 -1
  28. package/lib/css/vendors~super-ui.umd~253ae210.b57e4bfb.css +0 -1
  29. package/lib/css/yarn.tinymce~97d7b732.ea366551.css +0 -1
  30. package/lib/super-ui.common.super-ui.common~46f24e9d.js +0 -12446
  31. package/lib/super-ui.common.super-ui.common~60a56baa.js +0 -2774
  32. package/lib/super-ui.common.super-ui.common~691e02b5.js +0 -3062
  33. package/lib/super-ui.common.super-ui.common~970f9218.js +0 -3729
  34. package/lib/super-ui.common.super-ui.common~bd3594d6.js +0 -5264
  35. package/lib/super-ui.common.super-ui.common~e2e93592.js +0 -6945
  36. package/lib/super-ui.common.vendors~super-ui.common~253ae210.js +0 -3504
  37. package/lib/super-ui.common.yarn.async-validator~7864cd12.js +0 -1225
  38. package/lib/super-ui.common.yarn.core-js~2b13b260.js +0 -7542
  39. package/lib/super-ui.common.yarn.gcommon~c5c7b9b4.js +0 -11
  40. package/lib/super-ui.common.yarn.gcommon~cd278a5f.js +0 -4846
  41. package/lib/super-ui.common.yarn.resize-observer-polyfill~7370204d.js +0 -942
  42. package/lib/super-ui.common.yarn.sortablejs~f811d8fd.js +0 -3714
  43. package/lib/super-ui.common.yarn.tinymce~253ae210.js +0 -568
  44. package/lib/super-ui.common.yarn.tinymce~29bc5d46.js +0 -2125
  45. package/lib/super-ui.common.yarn.tinymce~35f50c21.js +0 -34090
  46. package/lib/super-ui.common.yarn.tinymce~8a52df3b.js +0 -30088
  47. package/lib/super-ui.common.yarn.tinymce~97d7b732.js +0 -31
  48. package/lib/super-ui.common.yarn.tinymce~b5d80f29.js +0 -7936
  49. package/lib/super-ui.common.yarn.tinymce~c1068939.js +0 -13346
  50. package/lib/super-ui.common.yarn.vue-i18n~02576867.js +0 -2179
  51. package/lib/super-ui.common.yarn.vue-virtual-scroll-list~bd67cfcd.js +0 -1069
  52. package/lib/super-ui.common.yarn.zxing~3446ce64.js +0 -11996
  53. package/lib/super-ui.common.yarn.zxing~61a1471b.js +0 -11202
  54. package/lib/super-ui.common.yarn.zxing~b49f3034.js +0 -3576
  55. package/lib/super-ui.common.yarn.zxing~fd3cc9f3.js +0 -2916
  56. package/lib/super-ui.umd.min.super-ui.umd.min~46f24e9d.js +0 -2
  57. package/lib/super-ui.umd.min.super-ui.umd.min~60a56baa.js +0 -2
  58. package/lib/super-ui.umd.min.super-ui.umd.min~691e02b5.js +0 -2
  59. package/lib/super-ui.umd.min.super-ui.umd.min~970f9218.js +0 -2
  60. package/lib/super-ui.umd.min.super-ui.umd.min~bd3594d6.js +0 -2
  61. package/lib/super-ui.umd.min.super-ui.umd.min~e2e93592.js +0 -2
  62. package/lib/super-ui.umd.min.vendors~super-ui.umd.min~253ae210.js +0 -24
  63. package/lib/super-ui.umd.min.yarn.async-validator~7864cd12.js +0 -2
  64. package/lib/super-ui.umd.min.yarn.core-js~2b13b260.js +0 -2
  65. package/lib/super-ui.umd.min.yarn.gcommon~c5c7b9b4.js +0 -2
  66. package/lib/super-ui.umd.min.yarn.gcommon~cd278a5f.js +0 -26
  67. package/lib/super-ui.umd.min.yarn.resize-observer-polyfill~7370204d.js +0 -2
  68. package/lib/super-ui.umd.min.yarn.sortablejs~f811d8fd.js +0 -8
  69. package/lib/super-ui.umd.min.yarn.tinymce~253ae210.js +0 -2
  70. package/lib/super-ui.umd.min.yarn.tinymce~29bc5d46.js +0 -2
  71. package/lib/super-ui.umd.min.yarn.tinymce~35f50c21.js +0 -2
  72. package/lib/super-ui.umd.min.yarn.tinymce~8a52df3b.js +0 -2
  73. package/lib/super-ui.umd.min.yarn.tinymce~97d7b732.js +0 -2
  74. package/lib/super-ui.umd.min.yarn.tinymce~b5d80f29.js +0 -2
  75. package/lib/super-ui.umd.min.yarn.tinymce~c1068939.js +0 -2
  76. package/lib/super-ui.umd.min.yarn.vue-i18n~02576867.js +0 -7
  77. package/lib/super-ui.umd.min.yarn.vue-virtual-scroll-list~bd67cfcd.js +0 -8
  78. package/lib/super-ui.umd.min.yarn.zxing~3446ce64.js +0 -2
  79. package/lib/super-ui.umd.min.yarn.zxing~61a1471b.js +0 -2
  80. package/lib/super-ui.umd.min.yarn.zxing~b49f3034.js +0 -2
  81. package/lib/super-ui.umd.min.yarn.zxing~fd3cc9f3.js +0 -2
  82. package/lib/super-ui.umd.super-ui.umd~46f24e9d.js +0 -12446
  83. package/lib/super-ui.umd.super-ui.umd~60a56baa.js +0 -2774
  84. package/lib/super-ui.umd.super-ui.umd~691e02b5.js +0 -3062
  85. package/lib/super-ui.umd.super-ui.umd~970f9218.js +0 -3739
  86. package/lib/super-ui.umd.super-ui.umd~bd3594d6.js +0 -5264
  87. package/lib/super-ui.umd.super-ui.umd~e2e93592.js +0 -6945
  88. package/lib/super-ui.umd.vendors~super-ui.umd~253ae210.js +0 -3504
  89. package/lib/super-ui.umd.yarn.async-validator~7864cd12.js +0 -1225
  90. package/lib/super-ui.umd.yarn.core-js~2b13b260.js +0 -7542
  91. package/lib/super-ui.umd.yarn.gcommon~c5c7b9b4.js +0 -11
  92. package/lib/super-ui.umd.yarn.gcommon~cd278a5f.js +0 -4846
  93. package/lib/super-ui.umd.yarn.resize-observer-polyfill~7370204d.js +0 -942
  94. package/lib/super-ui.umd.yarn.sortablejs~f811d8fd.js +0 -3714
  95. package/lib/super-ui.umd.yarn.tinymce~253ae210.js +0 -568
  96. package/lib/super-ui.umd.yarn.tinymce~29bc5d46.js +0 -2125
  97. package/lib/super-ui.umd.yarn.tinymce~35f50c21.js +0 -34090
  98. package/lib/super-ui.umd.yarn.tinymce~8a52df3b.js +0 -30088
  99. package/lib/super-ui.umd.yarn.tinymce~97d7b732.js +0 -31
  100. package/lib/super-ui.umd.yarn.tinymce~b5d80f29.js +0 -7936
  101. package/lib/super-ui.umd.yarn.tinymce~c1068939.js +0 -13346
  102. package/lib/super-ui.umd.yarn.vue-i18n~02576867.js +0 -2179
  103. package/lib/super-ui.umd.yarn.vue-virtual-scroll-list~bd67cfcd.js +0 -1069
  104. package/lib/super-ui.umd.yarn.zxing~3446ce64.js +0 -11996
  105. package/lib/super-ui.umd.yarn.zxing~61a1471b.js +0 -11202
  106. package/lib/super-ui.umd.yarn.zxing~b49f3034.js +0 -3576
  107. package/lib/super-ui.umd.yarn.zxing~fd3cc9f3.js +0 -2916
@@ -1,2179 +0,0 @@
1
- ((typeof self !== 'undefined' ? self : this)["webpackJsonpsuper_ui"] = (typeof self !== 'undefined' ? self : this)["webpackJsonpsuper_ui"] || []).push([[21],{
2
-
3
- /***/ "a925":
4
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
5
-
6
- "use strict";
7
- /*!
8
- * vue-i18n v8.25.0
9
- * (c) 2021 kazuya kawaguchi
10
- * Released under the MIT License.
11
- */
12
- /* */
13
-
14
- /**
15
- * constants
16
- */
17
-
18
- var numberFormatKeys = [
19
- 'compactDisplay',
20
- 'currency',
21
- 'currencyDisplay',
22
- 'currencySign',
23
- 'localeMatcher',
24
- 'notation',
25
- 'numberingSystem',
26
- 'signDisplay',
27
- 'style',
28
- 'unit',
29
- 'unitDisplay',
30
- 'useGrouping',
31
- 'minimumIntegerDigits',
32
- 'minimumFractionDigits',
33
- 'maximumFractionDigits',
34
- 'minimumSignificantDigits',
35
- 'maximumSignificantDigits'
36
- ];
37
-
38
- /**
39
- * utilities
40
- */
41
-
42
- function warn (msg, err) {
43
- if (typeof console !== 'undefined') {
44
- console.warn('[vue-i18n] ' + msg);
45
- /* istanbul ignore if */
46
- if (err) {
47
- console.warn(err.stack);
48
- }
49
- }
50
- }
51
-
52
- function error (msg, err) {
53
- if (typeof console !== 'undefined') {
54
- console.error('[vue-i18n] ' + msg);
55
- /* istanbul ignore if */
56
- if (err) {
57
- console.error(err.stack);
58
- }
59
- }
60
- }
61
-
62
- var isArray = Array.isArray;
63
-
64
- function isObject (obj) {
65
- return obj !== null && typeof obj === 'object'
66
- }
67
-
68
- function isBoolean (val) {
69
- return typeof val === 'boolean'
70
- }
71
-
72
- function isString (val) {
73
- return typeof val === 'string'
74
- }
75
-
76
- var toString = Object.prototype.toString;
77
- var OBJECT_STRING = '[object Object]';
78
- function isPlainObject (obj) {
79
- return toString.call(obj) === OBJECT_STRING
80
- }
81
-
82
- function isNull (val) {
83
- return val === null || val === undefined
84
- }
85
-
86
- function isFunction (val) {
87
- return typeof val === 'function'
88
- }
89
-
90
- function parseArgs () {
91
- var args = [], len = arguments.length;
92
- while ( len-- ) args[ len ] = arguments[ len ];
93
-
94
- var locale = null;
95
- var params = null;
96
- if (args.length === 1) {
97
- if (isObject(args[0]) || isArray(args[0])) {
98
- params = args[0];
99
- } else if (typeof args[0] === 'string') {
100
- locale = args[0];
101
- }
102
- } else if (args.length === 2) {
103
- if (typeof args[0] === 'string') {
104
- locale = args[0];
105
- }
106
- /* istanbul ignore if */
107
- if (isObject(args[1]) || isArray(args[1])) {
108
- params = args[1];
109
- }
110
- }
111
-
112
- return { locale: locale, params: params }
113
- }
114
-
115
- function looseClone (obj) {
116
- return JSON.parse(JSON.stringify(obj))
117
- }
118
-
119
- function remove (arr, item) {
120
- if (arr.delete(item)) {
121
- return arr
122
- }
123
- }
124
-
125
- function arrayFrom (arr) {
126
- var ret = [];
127
- arr.forEach(function (a) { return ret.push(a); });
128
- return ret
129
- }
130
-
131
- function includes (arr, item) {
132
- return !!~arr.indexOf(item)
133
- }
134
-
135
- var hasOwnProperty = Object.prototype.hasOwnProperty;
136
- function hasOwn (obj, key) {
137
- return hasOwnProperty.call(obj, key)
138
- }
139
-
140
- function merge (target) {
141
- var arguments$1 = arguments;
142
-
143
- var output = Object(target);
144
- for (var i = 1; i < arguments.length; i++) {
145
- var source = arguments$1[i];
146
- if (source !== undefined && source !== null) {
147
- var key = (void 0);
148
- for (key in source) {
149
- if (hasOwn(source, key)) {
150
- if (isObject(source[key])) {
151
- output[key] = merge(output[key], source[key]);
152
- } else {
153
- output[key] = source[key];
154
- }
155
- }
156
- }
157
- }
158
- }
159
- return output
160
- }
161
-
162
- function looseEqual (a, b) {
163
- if (a === b) { return true }
164
- var isObjectA = isObject(a);
165
- var isObjectB = isObject(b);
166
- if (isObjectA && isObjectB) {
167
- try {
168
- var isArrayA = isArray(a);
169
- var isArrayB = isArray(b);
170
- if (isArrayA && isArrayB) {
171
- return a.length === b.length && a.every(function (e, i) {
172
- return looseEqual(e, b[i])
173
- })
174
- } else if (!isArrayA && !isArrayB) {
175
- var keysA = Object.keys(a);
176
- var keysB = Object.keys(b);
177
- return keysA.length === keysB.length && keysA.every(function (key) {
178
- return looseEqual(a[key], b[key])
179
- })
180
- } else {
181
- /* istanbul ignore next */
182
- return false
183
- }
184
- } catch (e) {
185
- /* istanbul ignore next */
186
- return false
187
- }
188
- } else if (!isObjectA && !isObjectB) {
189
- return String(a) === String(b)
190
- } else {
191
- return false
192
- }
193
- }
194
-
195
- /**
196
- * Sanitizes html special characters from input strings. For mitigating risk of XSS attacks.
197
- * @param rawText The raw input from the user that should be escaped.
198
- */
199
- function escapeHtml(rawText) {
200
- return rawText
201
- .replace(/</g, '&lt;')
202
- .replace(/>/g, '&gt;')
203
- .replace(/"/g, '&quot;')
204
- .replace(/'/g, '&apos;')
205
- }
206
-
207
- /**
208
- * Escapes html tags and special symbols from all provided params which were returned from parseArgs().params.
209
- * This method performs an in-place operation on the params object.
210
- *
211
- * @param {any} params Parameters as provided from `parseArgs().params`.
212
- * May be either an array of strings or a string->any map.
213
- *
214
- * @returns The manipulated `params` object.
215
- */
216
- function escapeParams(params) {
217
- if(params != null) {
218
- Object.keys(params).forEach(function (key) {
219
- if(typeof(params[key]) == 'string') {
220
- params[key] = escapeHtml(params[key]);
221
- }
222
- });
223
- }
224
- return params
225
- }
226
-
227
- /* */
228
-
229
- function extend (Vue) {
230
- if (!Vue.prototype.hasOwnProperty('$i18n')) {
231
- // $FlowFixMe
232
- Object.defineProperty(Vue.prototype, '$i18n', {
233
- get: function get () { return this._i18n }
234
- });
235
- }
236
-
237
- Vue.prototype.$t = function (key) {
238
- var values = [], len = arguments.length - 1;
239
- while ( len-- > 0 ) values[ len ] = arguments[ len + 1 ];
240
-
241
- var i18n = this.$i18n;
242
- return i18n._t.apply(i18n, [ key, i18n.locale, i18n._getMessages(), this ].concat( values ))
243
- };
244
-
245
- Vue.prototype.$tc = function (key, choice) {
246
- var values = [], len = arguments.length - 2;
247
- while ( len-- > 0 ) values[ len ] = arguments[ len + 2 ];
248
-
249
- var i18n = this.$i18n;
250
- return i18n._tc.apply(i18n, [ key, i18n.locale, i18n._getMessages(), this, choice ].concat( values ))
251
- };
252
-
253
- Vue.prototype.$te = function (key, locale) {
254
- var i18n = this.$i18n;
255
- return i18n._te(key, i18n.locale, i18n._getMessages(), locale)
256
- };
257
-
258
- Vue.prototype.$d = function (value) {
259
- var ref;
260
-
261
- var args = [], len = arguments.length - 1;
262
- while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
263
- return (ref = this.$i18n).d.apply(ref, [ value ].concat( args ))
264
- };
265
-
266
- Vue.prototype.$n = function (value) {
267
- var ref;
268
-
269
- var args = [], len = arguments.length - 1;
270
- while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
271
- return (ref = this.$i18n).n.apply(ref, [ value ].concat( args ))
272
- };
273
- }
274
-
275
- /* */
276
-
277
- var mixin = {
278
- beforeCreate: function beforeCreate () {
279
- var options = this.$options;
280
- options.i18n = options.i18n || (options.__i18n ? {} : null);
281
-
282
- if (options.i18n) {
283
- if (options.i18n instanceof VueI18n) {
284
- // init locale messages via custom blocks
285
- if (options.__i18n) {
286
- try {
287
- var localeMessages = options.i18n && options.i18n.messages ? options.i18n.messages : {};
288
- options.__i18n.forEach(function (resource) {
289
- localeMessages = merge(localeMessages, JSON.parse(resource));
290
- });
291
- Object.keys(localeMessages).forEach(function (locale) {
292
- options.i18n.mergeLocaleMessage(locale, localeMessages[locale]);
293
- });
294
- } catch (e) {
295
- if (false) {}
296
- }
297
- }
298
- this._i18n = options.i18n;
299
- this._i18nWatcher = this._i18n.watchI18nData();
300
- } else if (isPlainObject(options.i18n)) {
301
- var rootI18n = this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n
302
- ? this.$root.$i18n
303
- : null;
304
- // component local i18n
305
- if (rootI18n) {
306
- options.i18n.root = this.$root;
307
- options.i18n.formatter = rootI18n.formatter;
308
- options.i18n.fallbackLocale = rootI18n.fallbackLocale;
309
- options.i18n.formatFallbackMessages = rootI18n.formatFallbackMessages;
310
- options.i18n.silentTranslationWarn = rootI18n.silentTranslationWarn;
311
- options.i18n.silentFallbackWarn = rootI18n.silentFallbackWarn;
312
- options.i18n.pluralizationRules = rootI18n.pluralizationRules;
313
- options.i18n.preserveDirectiveContent = rootI18n.preserveDirectiveContent;
314
- }
315
-
316
- // init locale messages via custom blocks
317
- if (options.__i18n) {
318
- try {
319
- var localeMessages$1 = options.i18n && options.i18n.messages ? options.i18n.messages : {};
320
- options.__i18n.forEach(function (resource) {
321
- localeMessages$1 = merge(localeMessages$1, JSON.parse(resource));
322
- });
323
- options.i18n.messages = localeMessages$1;
324
- } catch (e) {
325
- if (false) {}
326
- }
327
- }
328
-
329
- var ref = options.i18n;
330
- var sharedMessages = ref.sharedMessages;
331
- if (sharedMessages && isPlainObject(sharedMessages)) {
332
- options.i18n.messages = merge(options.i18n.messages, sharedMessages);
333
- }
334
-
335
- this._i18n = new VueI18n(options.i18n);
336
- this._i18nWatcher = this._i18n.watchI18nData();
337
-
338
- if (options.i18n.sync === undefined || !!options.i18n.sync) {
339
- this._localeWatcher = this.$i18n.watchLocale();
340
- }
341
-
342
- if (rootI18n) {
343
- rootI18n.onComponentInstanceCreated(this._i18n);
344
- }
345
- } else {
346
- if (false) {}
347
- }
348
- } else if (this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n) {
349
- // root i18n
350
- this._i18n = this.$root.$i18n;
351
- } else if (options.parent && options.parent.$i18n && options.parent.$i18n instanceof VueI18n) {
352
- // parent i18n
353
- this._i18n = options.parent.$i18n;
354
- }
355
- },
356
-
357
- beforeMount: function beforeMount () {
358
- var options = this.$options;
359
- options.i18n = options.i18n || (options.__i18n ? {} : null);
360
-
361
- if (options.i18n) {
362
- if (options.i18n instanceof VueI18n) {
363
- // init locale messages via custom blocks
364
- this._i18n.subscribeDataChanging(this);
365
- this._subscribing = true;
366
- } else if (isPlainObject(options.i18n)) {
367
- this._i18n.subscribeDataChanging(this);
368
- this._subscribing = true;
369
- } else {
370
- if (false) {}
371
- }
372
- } else if (this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n) {
373
- this._i18n.subscribeDataChanging(this);
374
- this._subscribing = true;
375
- } else if (options.parent && options.parent.$i18n && options.parent.$i18n instanceof VueI18n) {
376
- this._i18n.subscribeDataChanging(this);
377
- this._subscribing = true;
378
- }
379
- },
380
-
381
- mounted: function mounted () {
382
- if (this !== this.$root && this.$options.__INTLIFY_META__ && this.$el) {
383
- this.$el.setAttribute('data-intlify', this.$options.__INTLIFY_META__);
384
- }
385
- },
386
-
387
- beforeDestroy: function beforeDestroy () {
388
- if (!this._i18n) { return }
389
-
390
- var self = this;
391
- this.$nextTick(function () {
392
- if (self._subscribing) {
393
- self._i18n.unsubscribeDataChanging(self);
394
- delete self._subscribing;
395
- }
396
-
397
- if (self._i18nWatcher) {
398
- self._i18nWatcher();
399
- self._i18n.destroyVM();
400
- delete self._i18nWatcher;
401
- }
402
-
403
- if (self._localeWatcher) {
404
- self._localeWatcher();
405
- delete self._localeWatcher;
406
- }
407
- });
408
- }
409
- };
410
-
411
- /* */
412
-
413
- var interpolationComponent = {
414
- name: 'i18n',
415
- functional: true,
416
- props: {
417
- tag: {
418
- type: [String, Boolean, Object],
419
- default: 'span'
420
- },
421
- path: {
422
- type: String,
423
- required: true
424
- },
425
- locale: {
426
- type: String
427
- },
428
- places: {
429
- type: [Array, Object]
430
- }
431
- },
432
- render: function render (h, ref) {
433
- var data = ref.data;
434
- var parent = ref.parent;
435
- var props = ref.props;
436
- var slots = ref.slots;
437
-
438
- var $i18n = parent.$i18n;
439
- if (!$i18n) {
440
- if (false) {}
441
- return
442
- }
443
-
444
- var path = props.path;
445
- var locale = props.locale;
446
- var places = props.places;
447
- var params = slots();
448
- var children = $i18n.i(
449
- path,
450
- locale,
451
- onlyHasDefaultPlace(params) || places
452
- ? useLegacyPlaces(params.default, places)
453
- : params
454
- );
455
-
456
- var tag = (!!props.tag && props.tag !== true) || props.tag === false ? props.tag : 'span';
457
- return tag ? h(tag, data, children) : children
458
- }
459
- };
460
-
461
- function onlyHasDefaultPlace (params) {
462
- var prop;
463
- for (prop in params) {
464
- if (prop !== 'default') { return false }
465
- }
466
- return Boolean(prop)
467
- }
468
-
469
- function useLegacyPlaces (children, places) {
470
- var params = places ? createParamsFromPlaces(places) : {};
471
-
472
- if (!children) { return params }
473
-
474
- // Filter empty text nodes
475
- children = children.filter(function (child) {
476
- return child.tag || child.text.trim() !== ''
477
- });
478
-
479
- var everyPlace = children.every(vnodeHasPlaceAttribute);
480
- if (false) {}
481
-
482
- return children.reduce(
483
- everyPlace ? assignChildPlace : assignChildIndex,
484
- params
485
- )
486
- }
487
-
488
- function createParamsFromPlaces (places) {
489
- if (false) {}
490
-
491
- return Array.isArray(places)
492
- ? places.reduce(assignChildIndex, {})
493
- : Object.assign({}, places)
494
- }
495
-
496
- function assignChildPlace (params, child) {
497
- if (child.data && child.data.attrs && child.data.attrs.place) {
498
- params[child.data.attrs.place] = child;
499
- }
500
- return params
501
- }
502
-
503
- function assignChildIndex (params, child, index) {
504
- params[index] = child;
505
- return params
506
- }
507
-
508
- function vnodeHasPlaceAttribute (vnode) {
509
- return Boolean(vnode.data && vnode.data.attrs && vnode.data.attrs.place)
510
- }
511
-
512
- /* */
513
-
514
- var numberComponent = {
515
- name: 'i18n-n',
516
- functional: true,
517
- props: {
518
- tag: {
519
- type: [String, Boolean, Object],
520
- default: 'span'
521
- },
522
- value: {
523
- type: Number,
524
- required: true
525
- },
526
- format: {
527
- type: [String, Object]
528
- },
529
- locale: {
530
- type: String
531
- }
532
- },
533
- render: function render (h, ref) {
534
- var props = ref.props;
535
- var parent = ref.parent;
536
- var data = ref.data;
537
-
538
- var i18n = parent.$i18n;
539
-
540
- if (!i18n) {
541
- if (false) {}
542
- return null
543
- }
544
-
545
- var key = null;
546
- var options = null;
547
-
548
- if (isString(props.format)) {
549
- key = props.format;
550
- } else if (isObject(props.format)) {
551
- if (props.format.key) {
552
- key = props.format.key;
553
- }
554
-
555
- // Filter out number format options only
556
- options = Object.keys(props.format).reduce(function (acc, prop) {
557
- var obj;
558
-
559
- if (includes(numberFormatKeys, prop)) {
560
- return Object.assign({}, acc, ( obj = {}, obj[prop] = props.format[prop], obj ))
561
- }
562
- return acc
563
- }, null);
564
- }
565
-
566
- var locale = props.locale || i18n.locale;
567
- var parts = i18n._ntp(props.value, locale, key, options);
568
-
569
- var values = parts.map(function (part, index) {
570
- var obj;
571
-
572
- var slot = data.scopedSlots && data.scopedSlots[part.type];
573
- return slot ? slot(( obj = {}, obj[part.type] = part.value, obj.index = index, obj.parts = parts, obj )) : part.value
574
- });
575
-
576
- var tag = (!!props.tag && props.tag !== true) || props.tag === false ? props.tag : 'span';
577
- return tag
578
- ? h(tag, {
579
- attrs: data.attrs,
580
- 'class': data['class'],
581
- staticClass: data.staticClass
582
- }, values)
583
- : values
584
- }
585
- };
586
-
587
- /* */
588
-
589
- function bind (el, binding, vnode) {
590
- if (!assert(el, vnode)) { return }
591
-
592
- t(el, binding, vnode);
593
- }
594
-
595
- function update (el, binding, vnode, oldVNode) {
596
- if (!assert(el, vnode)) { return }
597
-
598
- var i18n = vnode.context.$i18n;
599
- if (localeEqual(el, vnode) &&
600
- (looseEqual(binding.value, binding.oldValue) &&
601
- looseEqual(el._localeMessage, i18n.getLocaleMessage(i18n.locale)))) { return }
602
-
603
- t(el, binding, vnode);
604
- }
605
-
606
- function unbind (el, binding, vnode, oldVNode) {
607
- var vm = vnode.context;
608
- if (!vm) {
609
- warn('Vue instance does not exists in VNode context');
610
- return
611
- }
612
-
613
- var i18n = vnode.context.$i18n || {};
614
- if (!binding.modifiers.preserve && !i18n.preserveDirectiveContent) {
615
- el.textContent = '';
616
- }
617
- el._vt = undefined;
618
- delete el['_vt'];
619
- el._locale = undefined;
620
- delete el['_locale'];
621
- el._localeMessage = undefined;
622
- delete el['_localeMessage'];
623
- }
624
-
625
- function assert (el, vnode) {
626
- var vm = vnode.context;
627
- if (!vm) {
628
- warn('Vue instance does not exists in VNode context');
629
- return false
630
- }
631
-
632
- if (!vm.$i18n) {
633
- warn('VueI18n instance does not exists in Vue instance');
634
- return false
635
- }
636
-
637
- return true
638
- }
639
-
640
- function localeEqual (el, vnode) {
641
- var vm = vnode.context;
642
- return el._locale === vm.$i18n.locale
643
- }
644
-
645
- function t (el, binding, vnode) {
646
- var ref$1, ref$2;
647
-
648
- var value = binding.value;
649
-
650
- var ref = parseValue(value);
651
- var path = ref.path;
652
- var locale = ref.locale;
653
- var args = ref.args;
654
- var choice = ref.choice;
655
- if (!path && !locale && !args) {
656
- warn('value type not supported');
657
- return
658
- }
659
-
660
- if (!path) {
661
- warn('`path` is required in v-t directive');
662
- return
663
- }
664
-
665
- var vm = vnode.context;
666
- if (choice != null) {
667
- el._vt = el.textContent = (ref$1 = vm.$i18n).tc.apply(ref$1, [ path, choice ].concat( makeParams(locale, args) ));
668
- } else {
669
- el._vt = el.textContent = (ref$2 = vm.$i18n).t.apply(ref$2, [ path ].concat( makeParams(locale, args) ));
670
- }
671
- el._locale = vm.$i18n.locale;
672
- el._localeMessage = vm.$i18n.getLocaleMessage(vm.$i18n.locale);
673
- }
674
-
675
- function parseValue (value) {
676
- var path;
677
- var locale;
678
- var args;
679
- var choice;
680
-
681
- if (isString(value)) {
682
- path = value;
683
- } else if (isPlainObject(value)) {
684
- path = value.path;
685
- locale = value.locale;
686
- args = value.args;
687
- choice = value.choice;
688
- }
689
-
690
- return { path: path, locale: locale, args: args, choice: choice }
691
- }
692
-
693
- function makeParams (locale, args) {
694
- var params = [];
695
-
696
- locale && params.push(locale);
697
- if (args && (Array.isArray(args) || isPlainObject(args))) {
698
- params.push(args);
699
- }
700
-
701
- return params
702
- }
703
-
704
- var Vue;
705
-
706
- function install (_Vue) {
707
- /* istanbul ignore if */
708
- if (false) {}
709
- install.installed = true;
710
-
711
- Vue = _Vue;
712
-
713
- var version = (Vue.version && Number(Vue.version.split('.')[0])) || -1;
714
- /* istanbul ignore if */
715
- if (false) {}
716
-
717
- extend(Vue);
718
- Vue.mixin(mixin);
719
- Vue.directive('t', { bind: bind, update: update, unbind: unbind });
720
- Vue.component(interpolationComponent.name, interpolationComponent);
721
- Vue.component(numberComponent.name, numberComponent);
722
-
723
- // use simple mergeStrategies to prevent i18n instance lose '__proto__'
724
- var strats = Vue.config.optionMergeStrategies;
725
- strats.i18n = function (parentVal, childVal) {
726
- return childVal === undefined
727
- ? parentVal
728
- : childVal
729
- };
730
- }
731
-
732
- /* */
733
-
734
- var BaseFormatter = function BaseFormatter () {
735
- this._caches = Object.create(null);
736
- };
737
-
738
- BaseFormatter.prototype.interpolate = function interpolate (message, values) {
739
- if (!values) {
740
- return [message]
741
- }
742
- var tokens = this._caches[message];
743
- if (!tokens) {
744
- tokens = parse(message);
745
- this._caches[message] = tokens;
746
- }
747
- return compile(tokens, values)
748
- };
749
-
750
-
751
-
752
- var RE_TOKEN_LIST_VALUE = /^(?:\d)+/;
753
- var RE_TOKEN_NAMED_VALUE = /^(?:\w)+/;
754
-
755
- function parse (format) {
756
- var tokens = [];
757
- var position = 0;
758
-
759
- var text = '';
760
- while (position < format.length) {
761
- var char = format[position++];
762
- if (char === '{') {
763
- if (text) {
764
- tokens.push({ type: 'text', value: text });
765
- }
766
-
767
- text = '';
768
- var sub = '';
769
- char = format[position++];
770
- while (char !== undefined && char !== '}') {
771
- sub += char;
772
- char = format[position++];
773
- }
774
- var isClosed = char === '}';
775
-
776
- var type = RE_TOKEN_LIST_VALUE.test(sub)
777
- ? 'list'
778
- : isClosed && RE_TOKEN_NAMED_VALUE.test(sub)
779
- ? 'named'
780
- : 'unknown';
781
- tokens.push({ value: sub, type: type });
782
- } else if (char === '%') {
783
- // when found rails i18n syntax, skip text capture
784
- if (format[(position)] !== '{') {
785
- text += char;
786
- }
787
- } else {
788
- text += char;
789
- }
790
- }
791
-
792
- text && tokens.push({ type: 'text', value: text });
793
-
794
- return tokens
795
- }
796
-
797
- function compile (tokens, values) {
798
- var compiled = [];
799
- var index = 0;
800
-
801
- var mode = Array.isArray(values)
802
- ? 'list'
803
- : isObject(values)
804
- ? 'named'
805
- : 'unknown';
806
- if (mode === 'unknown') { return compiled }
807
-
808
- while (index < tokens.length) {
809
- var token = tokens[index];
810
- switch (token.type) {
811
- case 'text':
812
- compiled.push(token.value);
813
- break
814
- case 'list':
815
- compiled.push(values[parseInt(token.value, 10)]);
816
- break
817
- case 'named':
818
- if (mode === 'named') {
819
- compiled.push((values)[token.value]);
820
- } else {
821
- if (false) {}
822
- }
823
- break
824
- case 'unknown':
825
- if (false) {}
826
- break
827
- }
828
- index++;
829
- }
830
-
831
- return compiled
832
- }
833
-
834
- /* */
835
-
836
- /**
837
- * Path parser
838
- * - Inspired:
839
- * Vue.js Path parser
840
- */
841
-
842
- // actions
843
- var APPEND = 0;
844
- var PUSH = 1;
845
- var INC_SUB_PATH_DEPTH = 2;
846
- var PUSH_SUB_PATH = 3;
847
-
848
- // states
849
- var BEFORE_PATH = 0;
850
- var IN_PATH = 1;
851
- var BEFORE_IDENT = 2;
852
- var IN_IDENT = 3;
853
- var IN_SUB_PATH = 4;
854
- var IN_SINGLE_QUOTE = 5;
855
- var IN_DOUBLE_QUOTE = 6;
856
- var AFTER_PATH = 7;
857
- var ERROR = 8;
858
-
859
- var pathStateMachine = [];
860
-
861
- pathStateMachine[BEFORE_PATH] = {
862
- 'ws': [BEFORE_PATH],
863
- 'ident': [IN_IDENT, APPEND],
864
- '[': [IN_SUB_PATH],
865
- 'eof': [AFTER_PATH]
866
- };
867
-
868
- pathStateMachine[IN_PATH] = {
869
- 'ws': [IN_PATH],
870
- '.': [BEFORE_IDENT],
871
- '[': [IN_SUB_PATH],
872
- 'eof': [AFTER_PATH]
873
- };
874
-
875
- pathStateMachine[BEFORE_IDENT] = {
876
- 'ws': [BEFORE_IDENT],
877
- 'ident': [IN_IDENT, APPEND],
878
- '0': [IN_IDENT, APPEND],
879
- 'number': [IN_IDENT, APPEND]
880
- };
881
-
882
- pathStateMachine[IN_IDENT] = {
883
- 'ident': [IN_IDENT, APPEND],
884
- '0': [IN_IDENT, APPEND],
885
- 'number': [IN_IDENT, APPEND],
886
- 'ws': [IN_PATH, PUSH],
887
- '.': [BEFORE_IDENT, PUSH],
888
- '[': [IN_SUB_PATH, PUSH],
889
- 'eof': [AFTER_PATH, PUSH]
890
- };
891
-
892
- pathStateMachine[IN_SUB_PATH] = {
893
- "'": [IN_SINGLE_QUOTE, APPEND],
894
- '"': [IN_DOUBLE_QUOTE, APPEND],
895
- '[': [IN_SUB_PATH, INC_SUB_PATH_DEPTH],
896
- ']': [IN_PATH, PUSH_SUB_PATH],
897
- 'eof': ERROR,
898
- 'else': [IN_SUB_PATH, APPEND]
899
- };
900
-
901
- pathStateMachine[IN_SINGLE_QUOTE] = {
902
- "'": [IN_SUB_PATH, APPEND],
903
- 'eof': ERROR,
904
- 'else': [IN_SINGLE_QUOTE, APPEND]
905
- };
906
-
907
- pathStateMachine[IN_DOUBLE_QUOTE] = {
908
- '"': [IN_SUB_PATH, APPEND],
909
- 'eof': ERROR,
910
- 'else': [IN_DOUBLE_QUOTE, APPEND]
911
- };
912
-
913
- /**
914
- * Check if an expression is a literal value.
915
- */
916
-
917
- var literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;
918
- function isLiteral (exp) {
919
- return literalValueRE.test(exp)
920
- }
921
-
922
- /**
923
- * Strip quotes from a string
924
- */
925
-
926
- function stripQuotes (str) {
927
- var a = str.charCodeAt(0);
928
- var b = str.charCodeAt(str.length - 1);
929
- return a === b && (a === 0x22 || a === 0x27)
930
- ? str.slice(1, -1)
931
- : str
932
- }
933
-
934
- /**
935
- * Determine the type of a character in a keypath.
936
- */
937
-
938
- function getPathCharType (ch) {
939
- if (ch === undefined || ch === null) { return 'eof' }
940
-
941
- var code = ch.charCodeAt(0);
942
-
943
- switch (code) {
944
- case 0x5B: // [
945
- case 0x5D: // ]
946
- case 0x2E: // .
947
- case 0x22: // "
948
- case 0x27: // '
949
- return ch
950
-
951
- case 0x5F: // _
952
- case 0x24: // $
953
- case 0x2D: // -
954
- return 'ident'
955
-
956
- case 0x09: // Tab
957
- case 0x0A: // Newline
958
- case 0x0D: // Return
959
- case 0xA0: // No-break space
960
- case 0xFEFF: // Byte Order Mark
961
- case 0x2028: // Line Separator
962
- case 0x2029: // Paragraph Separator
963
- return 'ws'
964
- }
965
-
966
- return 'ident'
967
- }
968
-
969
- /**
970
- * Format a subPath, return its plain form if it is
971
- * a literal string or number. Otherwise prepend the
972
- * dynamic indicator (*).
973
- */
974
-
975
- function formatSubPath (path) {
976
- var trimmed = path.trim();
977
- // invalid leading 0
978
- if (path.charAt(0) === '0' && isNaN(path)) { return false }
979
-
980
- return isLiteral(trimmed) ? stripQuotes(trimmed) : '*' + trimmed
981
- }
982
-
983
- /**
984
- * Parse a string path into an array of segments
985
- */
986
-
987
- function parse$1 (path) {
988
- var keys = [];
989
- var index = -1;
990
- var mode = BEFORE_PATH;
991
- var subPathDepth = 0;
992
- var c;
993
- var key;
994
- var newChar;
995
- var type;
996
- var transition;
997
- var action;
998
- var typeMap;
999
- var actions = [];
1000
-
1001
- actions[PUSH] = function () {
1002
- if (key !== undefined) {
1003
- keys.push(key);
1004
- key = undefined;
1005
- }
1006
- };
1007
-
1008
- actions[APPEND] = function () {
1009
- if (key === undefined) {
1010
- key = newChar;
1011
- } else {
1012
- key += newChar;
1013
- }
1014
- };
1015
-
1016
- actions[INC_SUB_PATH_DEPTH] = function () {
1017
- actions[APPEND]();
1018
- subPathDepth++;
1019
- };
1020
-
1021
- actions[PUSH_SUB_PATH] = function () {
1022
- if (subPathDepth > 0) {
1023
- subPathDepth--;
1024
- mode = IN_SUB_PATH;
1025
- actions[APPEND]();
1026
- } else {
1027
- subPathDepth = 0;
1028
- if (key === undefined) { return false }
1029
- key = formatSubPath(key);
1030
- if (key === false) {
1031
- return false
1032
- } else {
1033
- actions[PUSH]();
1034
- }
1035
- }
1036
- };
1037
-
1038
- function maybeUnescapeQuote () {
1039
- var nextChar = path[index + 1];
1040
- if ((mode === IN_SINGLE_QUOTE && nextChar === "'") ||
1041
- (mode === IN_DOUBLE_QUOTE && nextChar === '"')) {
1042
- index++;
1043
- newChar = '\\' + nextChar;
1044
- actions[APPEND]();
1045
- return true
1046
- }
1047
- }
1048
-
1049
- while (mode !== null) {
1050
- index++;
1051
- c = path[index];
1052
-
1053
- if (c === '\\' && maybeUnescapeQuote()) {
1054
- continue
1055
- }
1056
-
1057
- type = getPathCharType(c);
1058
- typeMap = pathStateMachine[mode];
1059
- transition = typeMap[type] || typeMap['else'] || ERROR;
1060
-
1061
- if (transition === ERROR) {
1062
- return // parse error
1063
- }
1064
-
1065
- mode = transition[0];
1066
- action = actions[transition[1]];
1067
- if (action) {
1068
- newChar = transition[2];
1069
- newChar = newChar === undefined
1070
- ? c
1071
- : newChar;
1072
- if (action() === false) {
1073
- return
1074
- }
1075
- }
1076
-
1077
- if (mode === AFTER_PATH) {
1078
- return keys
1079
- }
1080
- }
1081
- }
1082
-
1083
-
1084
-
1085
-
1086
-
1087
- var I18nPath = function I18nPath () {
1088
- this._cache = Object.create(null);
1089
- };
1090
-
1091
- /**
1092
- * External parse that check for a cache hit first
1093
- */
1094
- I18nPath.prototype.parsePath = function parsePath (path) {
1095
- var hit = this._cache[path];
1096
- if (!hit) {
1097
- hit = parse$1(path);
1098
- if (hit) {
1099
- this._cache[path] = hit;
1100
- }
1101
- }
1102
- return hit || []
1103
- };
1104
-
1105
- /**
1106
- * Get path value from path string
1107
- */
1108
- I18nPath.prototype.getPathValue = function getPathValue (obj, path) {
1109
- if (!isObject(obj)) { return null }
1110
-
1111
- var paths = this.parsePath(path);
1112
- if (paths.length === 0) {
1113
- return null
1114
- } else {
1115
- var length = paths.length;
1116
- var last = obj;
1117
- var i = 0;
1118
- while (i < length) {
1119
- var value = last[paths[i]];
1120
- if (value === undefined || value === null) {
1121
- return null
1122
- }
1123
- last = value;
1124
- i++;
1125
- }
1126
-
1127
- return last
1128
- }
1129
- };
1130
-
1131
- /* */
1132
-
1133
-
1134
-
1135
- var htmlTagMatcher = /<\/?[\w\s="/.':;#-\/]+>/;
1136
- var linkKeyMatcher = /(?:@(?:\.[a-z]+)?:(?:[\w\-_|.]+|\([\w\-_|.]+\)))/g;
1137
- var linkKeyPrefixMatcher = /^@(?:\.([a-z]+))?:/;
1138
- var bracketsMatcher = /[()]/g;
1139
- var defaultModifiers = {
1140
- 'upper': function (str) { return str.toLocaleUpperCase(); },
1141
- 'lower': function (str) { return str.toLocaleLowerCase(); },
1142
- 'capitalize': function (str) { return ("" + (str.charAt(0).toLocaleUpperCase()) + (str.substr(1))); }
1143
- };
1144
-
1145
- var defaultFormatter = new BaseFormatter();
1146
-
1147
- var VueI18n = function VueI18n (options) {
1148
- var this$1 = this;
1149
- if ( options === void 0 ) options = {};
1150
-
1151
- // Auto install if it is not done yet and `window` has `Vue`.
1152
- // To allow users to avoid auto-installation in some cases,
1153
- // this code should be placed here. See #290
1154
- /* istanbul ignore if */
1155
- if (!Vue && typeof window !== 'undefined' && window.Vue) {
1156
- install(window.Vue);
1157
- }
1158
-
1159
- var locale = options.locale || 'en-US';
1160
- var fallbackLocale = options.fallbackLocale === false
1161
- ? false
1162
- : options.fallbackLocale || 'en-US';
1163
- var messages = options.messages || {};
1164
- var dateTimeFormats = options.dateTimeFormats || {};
1165
- var numberFormats = options.numberFormats || {};
1166
-
1167
- this._vm = null;
1168
- this._formatter = options.formatter || defaultFormatter;
1169
- this._modifiers = options.modifiers || {};
1170
- this._missing = options.missing || null;
1171
- this._root = options.root || null;
1172
- this._sync = options.sync === undefined ? true : !!options.sync;
1173
- this._fallbackRoot = options.fallbackRoot === undefined
1174
- ? true
1175
- : !!options.fallbackRoot;
1176
- this._formatFallbackMessages = options.formatFallbackMessages === undefined
1177
- ? false
1178
- : !!options.formatFallbackMessages;
1179
- this._silentTranslationWarn = options.silentTranslationWarn === undefined
1180
- ? false
1181
- : options.silentTranslationWarn;
1182
- this._silentFallbackWarn = options.silentFallbackWarn === undefined
1183
- ? false
1184
- : !!options.silentFallbackWarn;
1185
- this._dateTimeFormatters = {};
1186
- this._numberFormatters = {};
1187
- this._path = new I18nPath();
1188
- this._dataListeners = new Set();
1189
- this._componentInstanceCreatedListener = options.componentInstanceCreatedListener || null;
1190
- this._preserveDirectiveContent = options.preserveDirectiveContent === undefined
1191
- ? false
1192
- : !!options.preserveDirectiveContent;
1193
- this.pluralizationRules = options.pluralizationRules || {};
1194
- this._warnHtmlInMessage = options.warnHtmlInMessage || 'off';
1195
- this._postTranslation = options.postTranslation || null;
1196
- this._escapeParameterHtml = options.escapeParameterHtml || false;
1197
-
1198
- /**
1199
- * @param choice {number} a choice index given by the input to $tc: `$tc('path.to.rule', choiceIndex)`
1200
- * @param choicesLength {number} an overall amount of available choices
1201
- * @returns a final choice index
1202
- */
1203
- this.getChoiceIndex = function (choice, choicesLength) {
1204
- var thisPrototype = Object.getPrototypeOf(this$1);
1205
- if (thisPrototype && thisPrototype.getChoiceIndex) {
1206
- var prototypeGetChoiceIndex = (thisPrototype.getChoiceIndex);
1207
- return (prototypeGetChoiceIndex).call(this$1, choice, choicesLength)
1208
- }
1209
-
1210
- // Default (old) getChoiceIndex implementation - english-compatible
1211
- var defaultImpl = function (_choice, _choicesLength) {
1212
- _choice = Math.abs(_choice);
1213
-
1214
- if (_choicesLength === 2) {
1215
- return _choice
1216
- ? _choice > 1
1217
- ? 1
1218
- : 0
1219
- : 1
1220
- }
1221
-
1222
- return _choice ? Math.min(_choice, 2) : 0
1223
- };
1224
-
1225
- if (this$1.locale in this$1.pluralizationRules) {
1226
- return this$1.pluralizationRules[this$1.locale].apply(this$1, [choice, choicesLength])
1227
- } else {
1228
- return defaultImpl(choice, choicesLength)
1229
- }
1230
- };
1231
-
1232
-
1233
- this._exist = function (message, key) {
1234
- if (!message || !key) { return false }
1235
- if (!isNull(this$1._path.getPathValue(message, key))) { return true }
1236
- // fallback for flat key
1237
- if (message[key]) { return true }
1238
- return false
1239
- };
1240
-
1241
- if (this._warnHtmlInMessage === 'warn' || this._warnHtmlInMessage === 'error') {
1242
- Object.keys(messages).forEach(function (locale) {
1243
- this$1._checkLocaleMessage(locale, this$1._warnHtmlInMessage, messages[locale]);
1244
- });
1245
- }
1246
-
1247
- this._initVM({
1248
- locale: locale,
1249
- fallbackLocale: fallbackLocale,
1250
- messages: messages,
1251
- dateTimeFormats: dateTimeFormats,
1252
- numberFormats: numberFormats
1253
- });
1254
- };
1255
-
1256
- var prototypeAccessors = { vm: { configurable: true },messages: { configurable: true },dateTimeFormats: { configurable: true },numberFormats: { configurable: true },availableLocales: { configurable: true },locale: { configurable: true },fallbackLocale: { configurable: true },formatFallbackMessages: { configurable: true },missing: { configurable: true },formatter: { configurable: true },silentTranslationWarn: { configurable: true },silentFallbackWarn: { configurable: true },preserveDirectiveContent: { configurable: true },warnHtmlInMessage: { configurable: true },postTranslation: { configurable: true } };
1257
-
1258
- VueI18n.prototype._checkLocaleMessage = function _checkLocaleMessage (locale, level, message) {
1259
- var paths = [];
1260
-
1261
- var fn = function (level, locale, message, paths) {
1262
- if (isPlainObject(message)) {
1263
- Object.keys(message).forEach(function (key) {
1264
- var val = message[key];
1265
- if (isPlainObject(val)) {
1266
- paths.push(key);
1267
- paths.push('.');
1268
- fn(level, locale, val, paths);
1269
- paths.pop();
1270
- paths.pop();
1271
- } else {
1272
- paths.push(key);
1273
- fn(level, locale, val, paths);
1274
- paths.pop();
1275
- }
1276
- });
1277
- } else if (isArray(message)) {
1278
- message.forEach(function (item, index) {
1279
- if (isPlainObject(item)) {
1280
- paths.push(("[" + index + "]"));
1281
- paths.push('.');
1282
- fn(level, locale, item, paths);
1283
- paths.pop();
1284
- paths.pop();
1285
- } else {
1286
- paths.push(("[" + index + "]"));
1287
- fn(level, locale, item, paths);
1288
- paths.pop();
1289
- }
1290
- });
1291
- } else if (isString(message)) {
1292
- var ret = htmlTagMatcher.test(message);
1293
- if (ret) {
1294
- var msg = "Detected HTML in message '" + message + "' of keypath '" + (paths.join('')) + "' at '" + locale + "'. Consider component interpolation with '<i18n>' to avoid XSS. See https://bit.ly/2ZqJzkp";
1295
- if (level === 'warn') {
1296
- warn(msg);
1297
- } else if (level === 'error') {
1298
- error(msg);
1299
- }
1300
- }
1301
- }
1302
- };
1303
-
1304
- fn(level, locale, message, paths);
1305
- };
1306
-
1307
- VueI18n.prototype._initVM = function _initVM (data) {
1308
- var silent = Vue.config.silent;
1309
- Vue.config.silent = true;
1310
- this._vm = new Vue({ data: data });
1311
- Vue.config.silent = silent;
1312
- };
1313
-
1314
- VueI18n.prototype.destroyVM = function destroyVM () {
1315
- this._vm.$destroy();
1316
- };
1317
-
1318
- VueI18n.prototype.subscribeDataChanging = function subscribeDataChanging (vm) {
1319
- this._dataListeners.add(vm);
1320
- };
1321
-
1322
- VueI18n.prototype.unsubscribeDataChanging = function unsubscribeDataChanging (vm) {
1323
- remove(this._dataListeners, vm);
1324
- };
1325
-
1326
- VueI18n.prototype.watchI18nData = function watchI18nData () {
1327
- var this$1 = this;
1328
- return this._vm.$watch('$data', function () {
1329
- var listeners = arrayFrom(this$1._dataListeners);
1330
- var i = listeners.length;
1331
- while(i--) {
1332
- Vue.nextTick(function () {
1333
- listeners[i] && listeners[i].$forceUpdate();
1334
- });
1335
- }
1336
- }, { deep: true })
1337
- };
1338
-
1339
- VueI18n.prototype.watchLocale = function watchLocale () {
1340
- /* istanbul ignore if */
1341
- if (!this._sync || !this._root) { return null }
1342
- var target = this._vm;
1343
- return this._root.$i18n.vm.$watch('locale', function (val) {
1344
- target.$set(target, 'locale', val);
1345
- target.$forceUpdate();
1346
- }, { immediate: true })
1347
- };
1348
-
1349
- VueI18n.prototype.onComponentInstanceCreated = function onComponentInstanceCreated (newI18n) {
1350
- if (this._componentInstanceCreatedListener) {
1351
- this._componentInstanceCreatedListener(newI18n, this);
1352
- }
1353
- };
1354
-
1355
- prototypeAccessors.vm.get = function () { return this._vm };
1356
-
1357
- prototypeAccessors.messages.get = function () { return looseClone(this._getMessages()) };
1358
- prototypeAccessors.dateTimeFormats.get = function () { return looseClone(this._getDateTimeFormats()) };
1359
- prototypeAccessors.numberFormats.get = function () { return looseClone(this._getNumberFormats()) };
1360
- prototypeAccessors.availableLocales.get = function () { return Object.keys(this.messages).sort() };
1361
-
1362
- prototypeAccessors.locale.get = function () { return this._vm.locale };
1363
- prototypeAccessors.locale.set = function (locale) {
1364
- this._vm.$set(this._vm, 'locale', locale);
1365
- };
1366
-
1367
- prototypeAccessors.fallbackLocale.get = function () { return this._vm.fallbackLocale };
1368
- prototypeAccessors.fallbackLocale.set = function (locale) {
1369
- this._localeChainCache = {};
1370
- this._vm.$set(this._vm, 'fallbackLocale', locale);
1371
- };
1372
-
1373
- prototypeAccessors.formatFallbackMessages.get = function () { return this._formatFallbackMessages };
1374
- prototypeAccessors.formatFallbackMessages.set = function (fallback) { this._formatFallbackMessages = fallback; };
1375
-
1376
- prototypeAccessors.missing.get = function () { return this._missing };
1377
- prototypeAccessors.missing.set = function (handler) { this._missing = handler; };
1378
-
1379
- prototypeAccessors.formatter.get = function () { return this._formatter };
1380
- prototypeAccessors.formatter.set = function (formatter) { this._formatter = formatter; };
1381
-
1382
- prototypeAccessors.silentTranslationWarn.get = function () { return this._silentTranslationWarn };
1383
- prototypeAccessors.silentTranslationWarn.set = function (silent) { this._silentTranslationWarn = silent; };
1384
-
1385
- prototypeAccessors.silentFallbackWarn.get = function () { return this._silentFallbackWarn };
1386
- prototypeAccessors.silentFallbackWarn.set = function (silent) { this._silentFallbackWarn = silent; };
1387
-
1388
- prototypeAccessors.preserveDirectiveContent.get = function () { return this._preserveDirectiveContent };
1389
- prototypeAccessors.preserveDirectiveContent.set = function (preserve) { this._preserveDirectiveContent = preserve; };
1390
-
1391
- prototypeAccessors.warnHtmlInMessage.get = function () { return this._warnHtmlInMessage };
1392
- prototypeAccessors.warnHtmlInMessage.set = function (level) {
1393
- var this$1 = this;
1394
-
1395
- var orgLevel = this._warnHtmlInMessage;
1396
- this._warnHtmlInMessage = level;
1397
- if (orgLevel !== level && (level === 'warn' || level === 'error')) {
1398
- var messages = this._getMessages();
1399
- Object.keys(messages).forEach(function (locale) {
1400
- this$1._checkLocaleMessage(locale, this$1._warnHtmlInMessage, messages[locale]);
1401
- });
1402
- }
1403
- };
1404
-
1405
- prototypeAccessors.postTranslation.get = function () { return this._postTranslation };
1406
- prototypeAccessors.postTranslation.set = function (handler) { this._postTranslation = handler; };
1407
-
1408
- VueI18n.prototype._getMessages = function _getMessages () { return this._vm.messages };
1409
- VueI18n.prototype._getDateTimeFormats = function _getDateTimeFormats () { return this._vm.dateTimeFormats };
1410
- VueI18n.prototype._getNumberFormats = function _getNumberFormats () { return this._vm.numberFormats };
1411
-
1412
- VueI18n.prototype._warnDefault = function _warnDefault (locale, key, result, vm, values, interpolateMode) {
1413
- if (!isNull(result)) { return result }
1414
- if (this._missing) {
1415
- var missingRet = this._missing.apply(null, [locale, key, vm, values]);
1416
- if (isString(missingRet)) {
1417
- return missingRet
1418
- }
1419
- } else {
1420
- if (false) {}
1421
- }
1422
-
1423
- if (this._formatFallbackMessages) {
1424
- var parsedArgs = parseArgs.apply(void 0, values);
1425
- return this._render(key, interpolateMode, parsedArgs.params, key)
1426
- } else {
1427
- return key
1428
- }
1429
- };
1430
-
1431
- VueI18n.prototype._isFallbackRoot = function _isFallbackRoot (val) {
1432
- return !val && !isNull(this._root) && this._fallbackRoot
1433
- };
1434
-
1435
- VueI18n.prototype._isSilentFallbackWarn = function _isSilentFallbackWarn (key) {
1436
- return this._silentFallbackWarn instanceof RegExp
1437
- ? this._silentFallbackWarn.test(key)
1438
- : this._silentFallbackWarn
1439
- };
1440
-
1441
- VueI18n.prototype._isSilentFallback = function _isSilentFallback (locale, key) {
1442
- return this._isSilentFallbackWarn(key) && (this._isFallbackRoot() || locale !== this.fallbackLocale)
1443
- };
1444
-
1445
- VueI18n.prototype._isSilentTranslationWarn = function _isSilentTranslationWarn (key) {
1446
- return this._silentTranslationWarn instanceof RegExp
1447
- ? this._silentTranslationWarn.test(key)
1448
- : this._silentTranslationWarn
1449
- };
1450
-
1451
- VueI18n.prototype._interpolate = function _interpolate (
1452
- locale,
1453
- message,
1454
- key,
1455
- host,
1456
- interpolateMode,
1457
- values,
1458
- visitedLinkStack
1459
- ) {
1460
- if (!message) { return null }
1461
-
1462
- var pathRet = this._path.getPathValue(message, key);
1463
- if (isArray(pathRet) || isPlainObject(pathRet)) { return pathRet }
1464
-
1465
- var ret;
1466
- if (isNull(pathRet)) {
1467
- /* istanbul ignore else */
1468
- if (isPlainObject(message)) {
1469
- ret = message[key];
1470
- if (!(isString(ret) || isFunction(ret))) {
1471
- if (false) {}
1472
- return null
1473
- }
1474
- } else {
1475
- return null
1476
- }
1477
- } else {
1478
- /* istanbul ignore else */
1479
- if (isString(pathRet) || isFunction(pathRet)) {
1480
- ret = pathRet;
1481
- } else {
1482
- if (false) {}
1483
- return null
1484
- }
1485
- }
1486
-
1487
- // Check for the existence of links within the translated string
1488
- if (isString(ret) && (ret.indexOf('@:') >= 0 || ret.indexOf('@.') >= 0)) {
1489
- ret = this._link(locale, message, ret, host, 'raw', values, visitedLinkStack);
1490
- }
1491
-
1492
- return this._render(ret, interpolateMode, values, key)
1493
- };
1494
-
1495
- VueI18n.prototype._link = function _link (
1496
- locale,
1497
- message,
1498
- str,
1499
- host,
1500
- interpolateMode,
1501
- values,
1502
- visitedLinkStack
1503
- ) {
1504
- var ret = str;
1505
-
1506
- // Match all the links within the local
1507
- // We are going to replace each of
1508
- // them with its translation
1509
- var matches = ret.match(linkKeyMatcher);
1510
-
1511
- // eslint-disable-next-line no-autofix/prefer-const
1512
- for (var idx in matches) {
1513
- // ie compatible: filter custom array
1514
- // prototype method
1515
- if (!matches.hasOwnProperty(idx)) {
1516
- continue
1517
- }
1518
- var link = matches[idx];
1519
- var linkKeyPrefixMatches = link.match(linkKeyPrefixMatcher);
1520
- var linkPrefix = linkKeyPrefixMatches[0];
1521
- var formatterName = linkKeyPrefixMatches[1];
1522
-
1523
- // Remove the leading @:, @.case: and the brackets
1524
- var linkPlaceholder = link.replace(linkPrefix, '').replace(bracketsMatcher, '');
1525
-
1526
- if (includes(visitedLinkStack, linkPlaceholder)) {
1527
- if (false) {}
1528
- return ret
1529
- }
1530
- visitedLinkStack.push(linkPlaceholder);
1531
-
1532
- // Translate the link
1533
- var translated = this._interpolate(
1534
- locale, message, linkPlaceholder, host,
1535
- interpolateMode === 'raw' ? 'string' : interpolateMode,
1536
- interpolateMode === 'raw' ? undefined : values,
1537
- visitedLinkStack
1538
- );
1539
-
1540
- if (this._isFallbackRoot(translated)) {
1541
- if (false) {}
1542
- /* istanbul ignore if */
1543
- if (!this._root) { throw Error('unexpected error') }
1544
- var root = this._root.$i18n;
1545
- translated = root._translate(
1546
- root._getMessages(), root.locale, root.fallbackLocale,
1547
- linkPlaceholder, host, interpolateMode, values
1548
- );
1549
- }
1550
- translated = this._warnDefault(
1551
- locale, linkPlaceholder, translated, host,
1552
- isArray(values) ? values : [values],
1553
- interpolateMode
1554
- );
1555
-
1556
- if (this._modifiers.hasOwnProperty(formatterName)) {
1557
- translated = this._modifiers[formatterName](translated);
1558
- } else if (defaultModifiers.hasOwnProperty(formatterName)) {
1559
- translated = defaultModifiers[formatterName](translated);
1560
- }
1561
-
1562
- visitedLinkStack.pop();
1563
-
1564
- // Replace the link with the translated
1565
- ret = !translated ? ret : ret.replace(link, translated);
1566
- }
1567
-
1568
- return ret
1569
- };
1570
-
1571
- VueI18n.prototype._createMessageContext = function _createMessageContext (values, formatter, path, interpolateMode) {
1572
- var this$1 = this;
1573
-
1574
- var _list = isArray(values) ? values : [];
1575
- var _named = isObject(values) ? values : {};
1576
- var list = function (index) { return _list[index]; };
1577
- var named = function (key) { return _named[key]; };
1578
- var messages = this._getMessages();
1579
- var locale = this.locale;
1580
-
1581
- return {
1582
- list: list,
1583
- named: named,
1584
- values: values,
1585
- formatter: formatter,
1586
- path: path,
1587
- messages: messages,
1588
- locale: locale,
1589
- linked: function (linkedKey) { return this$1._interpolate(locale, messages[locale] || {}, linkedKey, null, interpolateMode, undefined, [linkedKey]); }
1590
- }
1591
- };
1592
-
1593
- VueI18n.prototype._render = function _render (message, interpolateMode, values, path) {
1594
- if (isFunction(message)) {
1595
- return message(
1596
- this._createMessageContext(values, this._formatter || defaultFormatter, path, interpolateMode)
1597
- )
1598
- }
1599
-
1600
- var ret = this._formatter.interpolate(message, values, path);
1601
-
1602
- // If the custom formatter refuses to work - apply the default one
1603
- if (!ret) {
1604
- ret = defaultFormatter.interpolate(message, values, path);
1605
- }
1606
-
1607
- // if interpolateMode is **not** 'string' ('row'),
1608
- // return the compiled data (e.g. ['foo', VNode, 'bar']) with formatter
1609
- return interpolateMode === 'string' && !isString(ret) ? ret.join('') : ret
1610
- };
1611
-
1612
- VueI18n.prototype._appendItemToChain = function _appendItemToChain (chain, item, blocks) {
1613
- var follow = false;
1614
- if (!includes(chain, item)) {
1615
- follow = true;
1616
- if (item) {
1617
- follow = item[item.length - 1] !== '!';
1618
- item = item.replace(/!/g, '');
1619
- chain.push(item);
1620
- if (blocks && blocks[item]) {
1621
- follow = blocks[item];
1622
- }
1623
- }
1624
- }
1625
- return follow
1626
- };
1627
-
1628
- VueI18n.prototype._appendLocaleToChain = function _appendLocaleToChain (chain, locale, blocks) {
1629
- var follow;
1630
- var tokens = locale.split('-');
1631
- do {
1632
- var item = tokens.join('-');
1633
- follow = this._appendItemToChain(chain, item, blocks);
1634
- tokens.splice(-1, 1);
1635
- } while (tokens.length && (follow === true))
1636
- return follow
1637
- };
1638
-
1639
- VueI18n.prototype._appendBlockToChain = function _appendBlockToChain (chain, block, blocks) {
1640
- var follow = true;
1641
- for (var i = 0; (i < block.length) && (isBoolean(follow)); i++) {
1642
- var locale = block[i];
1643
- if (isString(locale)) {
1644
- follow = this._appendLocaleToChain(chain, locale, blocks);
1645
- }
1646
- }
1647
- return follow
1648
- };
1649
-
1650
- VueI18n.prototype._getLocaleChain = function _getLocaleChain (start, fallbackLocale) {
1651
- if (start === '') { return [] }
1652
-
1653
- if (!this._localeChainCache) {
1654
- this._localeChainCache = {};
1655
- }
1656
-
1657
- var chain = this._localeChainCache[start];
1658
- if (!chain) {
1659
- if (!fallbackLocale) {
1660
- fallbackLocale = this.fallbackLocale;
1661
- }
1662
- chain = [];
1663
-
1664
- // first block defined by start
1665
- var block = [start];
1666
-
1667
- // while any intervening block found
1668
- while (isArray(block)) {
1669
- block = this._appendBlockToChain(
1670
- chain,
1671
- block,
1672
- fallbackLocale
1673
- );
1674
- }
1675
-
1676
- // last block defined by default
1677
- var defaults;
1678
- if (isArray(fallbackLocale)) {
1679
- defaults = fallbackLocale;
1680
- } else if (isObject(fallbackLocale)) {
1681
- /* $FlowFixMe */
1682
- if (fallbackLocale['default']) {
1683
- defaults = fallbackLocale['default'];
1684
- } else {
1685
- defaults = null;
1686
- }
1687
- } else {
1688
- defaults = fallbackLocale;
1689
- }
1690
-
1691
- // convert defaults to array
1692
- if (isString(defaults)) {
1693
- block = [defaults];
1694
- } else {
1695
- block = defaults;
1696
- }
1697
- if (block) {
1698
- this._appendBlockToChain(
1699
- chain,
1700
- block,
1701
- null
1702
- );
1703
- }
1704
- this._localeChainCache[start] = chain;
1705
- }
1706
- return chain
1707
- };
1708
-
1709
- VueI18n.prototype._translate = function _translate (
1710
- messages,
1711
- locale,
1712
- fallback,
1713
- key,
1714
- host,
1715
- interpolateMode,
1716
- args
1717
- ) {
1718
- var chain = this._getLocaleChain(locale, fallback);
1719
- var res;
1720
- for (var i = 0; i < chain.length; i++) {
1721
- var step = chain[i];
1722
- res =
1723
- this._interpolate(step, messages[step], key, host, interpolateMode, args, [key]);
1724
- if (!isNull(res)) {
1725
- if (step !== locale && "production" !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {
1726
- warn(("Fall back to translate the keypath '" + key + "' with '" + step + "' locale."));
1727
- }
1728
- return res
1729
- }
1730
- }
1731
- return null
1732
- };
1733
-
1734
- VueI18n.prototype._t = function _t (key, _locale, messages, host) {
1735
- var ref;
1736
-
1737
- var values = [], len = arguments.length - 4;
1738
- while ( len-- > 0 ) values[ len ] = arguments[ len + 4 ];
1739
- if (!key) { return '' }
1740
-
1741
- var parsedArgs = parseArgs.apply(void 0, values);
1742
- if(this._escapeParameterHtml) {
1743
- parsedArgs.params = escapeParams(parsedArgs.params);
1744
- }
1745
-
1746
- var locale = parsedArgs.locale || _locale;
1747
-
1748
- var ret = this._translate(
1749
- messages, locale, this.fallbackLocale, key,
1750
- host, 'string', parsedArgs.params
1751
- );
1752
- if (this._isFallbackRoot(ret)) {
1753
- if (false) {}
1754
- /* istanbul ignore if */
1755
- if (!this._root) { throw Error('unexpected error') }
1756
- return (ref = this._root).$t.apply(ref, [ key ].concat( values ))
1757
- } else {
1758
- ret = this._warnDefault(locale, key, ret, host, values, 'string');
1759
- if (this._postTranslation && ret !== null && ret !== undefined) {
1760
- ret = this._postTranslation(ret, key);
1761
- }
1762
- return ret
1763
- }
1764
- };
1765
-
1766
- VueI18n.prototype.t = function t (key) {
1767
- var ref;
1768
-
1769
- var values = [], len = arguments.length - 1;
1770
- while ( len-- > 0 ) values[ len ] = arguments[ len + 1 ];
1771
- return (ref = this)._t.apply(ref, [ key, this.locale, this._getMessages(), null ].concat( values ))
1772
- };
1773
-
1774
- VueI18n.prototype._i = function _i (key, locale, messages, host, values) {
1775
- var ret =
1776
- this._translate(messages, locale, this.fallbackLocale, key, host, 'raw', values);
1777
- if (this._isFallbackRoot(ret)) {
1778
- if (false) {}
1779
- if (!this._root) { throw Error('unexpected error') }
1780
- return this._root.$i18n.i(key, locale, values)
1781
- } else {
1782
- return this._warnDefault(locale, key, ret, host, [values], 'raw')
1783
- }
1784
- };
1785
-
1786
- VueI18n.prototype.i = function i (key, locale, values) {
1787
- /* istanbul ignore if */
1788
- if (!key) { return '' }
1789
-
1790
- if (!isString(locale)) {
1791
- locale = this.locale;
1792
- }
1793
-
1794
- return this._i(key, locale, this._getMessages(), null, values)
1795
- };
1796
-
1797
- VueI18n.prototype._tc = function _tc (
1798
- key,
1799
- _locale,
1800
- messages,
1801
- host,
1802
- choice
1803
- ) {
1804
- var ref;
1805
-
1806
- var values = [], len = arguments.length - 5;
1807
- while ( len-- > 0 ) values[ len ] = arguments[ len + 5 ];
1808
- if (!key) { return '' }
1809
- if (choice === undefined) {
1810
- choice = 1;
1811
- }
1812
-
1813
- var predefined = { 'count': choice, 'n': choice };
1814
- var parsedArgs = parseArgs.apply(void 0, values);
1815
- parsedArgs.params = Object.assign(predefined, parsedArgs.params);
1816
- values = parsedArgs.locale === null ? [parsedArgs.params] : [parsedArgs.locale, parsedArgs.params];
1817
- return this.fetchChoice((ref = this)._t.apply(ref, [ key, _locale, messages, host ].concat( values )), choice)
1818
- };
1819
-
1820
- VueI18n.prototype.fetchChoice = function fetchChoice (message, choice) {
1821
- /* istanbul ignore if */
1822
- if (!message || !isString(message)) { return null }
1823
- var choices = message.split('|');
1824
-
1825
- choice = this.getChoiceIndex(choice, choices.length);
1826
- if (!choices[choice]) { return message }
1827
- return choices[choice].trim()
1828
- };
1829
-
1830
- VueI18n.prototype.tc = function tc (key, choice) {
1831
- var ref;
1832
-
1833
- var values = [], len = arguments.length - 2;
1834
- while ( len-- > 0 ) values[ len ] = arguments[ len + 2 ];
1835
- return (ref = this)._tc.apply(ref, [ key, this.locale, this._getMessages(), null, choice ].concat( values ))
1836
- };
1837
-
1838
- VueI18n.prototype._te = function _te (key, locale, messages) {
1839
- var args = [], len = arguments.length - 3;
1840
- while ( len-- > 0 ) args[ len ] = arguments[ len + 3 ];
1841
-
1842
- var _locale = parseArgs.apply(void 0, args).locale || locale;
1843
- return this._exist(messages[_locale], key)
1844
- };
1845
-
1846
- VueI18n.prototype.te = function te (key, locale) {
1847
- return this._te(key, this.locale, this._getMessages(), locale)
1848
- };
1849
-
1850
- VueI18n.prototype.getLocaleMessage = function getLocaleMessage (locale) {
1851
- return looseClone(this._vm.messages[locale] || {})
1852
- };
1853
-
1854
- VueI18n.prototype.setLocaleMessage = function setLocaleMessage (locale, message) {
1855
- if (this._warnHtmlInMessage === 'warn' || this._warnHtmlInMessage === 'error') {
1856
- this._checkLocaleMessage(locale, this._warnHtmlInMessage, message);
1857
- }
1858
- this._vm.$set(this._vm.messages, locale, message);
1859
- };
1860
-
1861
- VueI18n.prototype.mergeLocaleMessage = function mergeLocaleMessage (locale, message) {
1862
- if (this._warnHtmlInMessage === 'warn' || this._warnHtmlInMessage === 'error') {
1863
- this._checkLocaleMessage(locale, this._warnHtmlInMessage, message);
1864
- }
1865
- this._vm.$set(this._vm.messages, locale, merge(
1866
- typeof this._vm.messages[locale] !== 'undefined' && Object.keys(this._vm.messages[locale]).length
1867
- ? Object.assign({}, this._vm.messages[locale])
1868
- : {},
1869
- message
1870
- ));
1871
- };
1872
-
1873
- VueI18n.prototype.getDateTimeFormat = function getDateTimeFormat (locale) {
1874
- return looseClone(this._vm.dateTimeFormats[locale] || {})
1875
- };
1876
-
1877
- VueI18n.prototype.setDateTimeFormat = function setDateTimeFormat (locale, format) {
1878
- this._vm.$set(this._vm.dateTimeFormats, locale, format);
1879
- this._clearDateTimeFormat(locale, format);
1880
- };
1881
-
1882
- VueI18n.prototype.mergeDateTimeFormat = function mergeDateTimeFormat (locale, format) {
1883
- this._vm.$set(this._vm.dateTimeFormats, locale, merge(this._vm.dateTimeFormats[locale] || {}, format));
1884
- this._clearDateTimeFormat(locale, format);
1885
- };
1886
-
1887
- VueI18n.prototype._clearDateTimeFormat = function _clearDateTimeFormat (locale, format) {
1888
- // eslint-disable-next-line no-autofix/prefer-const
1889
- for (var key in format) {
1890
- var id = locale + "__" + key;
1891
-
1892
- if (!this._dateTimeFormatters.hasOwnProperty(id)) {
1893
- continue
1894
- }
1895
-
1896
- delete this._dateTimeFormatters[id];
1897
- }
1898
- };
1899
-
1900
- VueI18n.prototype._localizeDateTime = function _localizeDateTime (
1901
- value,
1902
- locale,
1903
- fallback,
1904
- dateTimeFormats,
1905
- key
1906
- ) {
1907
- var _locale = locale;
1908
- var formats = dateTimeFormats[_locale];
1909
-
1910
- var chain = this._getLocaleChain(locale, fallback);
1911
- for (var i = 0; i < chain.length; i++) {
1912
- var current = _locale;
1913
- var step = chain[i];
1914
- formats = dateTimeFormats[step];
1915
- _locale = step;
1916
- // fallback locale
1917
- if (isNull(formats) || isNull(formats[key])) {
1918
- if (step !== locale && "production" !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {
1919
- warn(("Fall back to '" + step + "' datetime formats from '" + current + "' datetime formats."));
1920
- }
1921
- } else {
1922
- break
1923
- }
1924
- }
1925
-
1926
- if (isNull(formats) || isNull(formats[key])) {
1927
- return null
1928
- } else {
1929
- var format = formats[key];
1930
- var id = _locale + "__" + key;
1931
- var formatter = this._dateTimeFormatters[id];
1932
- if (!formatter) {
1933
- formatter = this._dateTimeFormatters[id] = new Intl.DateTimeFormat(_locale, format);
1934
- }
1935
- return formatter.format(value)
1936
- }
1937
- };
1938
-
1939
- VueI18n.prototype._d = function _d (value, locale, key) {
1940
- /* istanbul ignore if */
1941
- if (false) {}
1942
-
1943
- if (!key) {
1944
- return new Intl.DateTimeFormat(locale).format(value)
1945
- }
1946
-
1947
- var ret =
1948
- this._localizeDateTime(value, locale, this.fallbackLocale, this._getDateTimeFormats(), key);
1949
- if (this._isFallbackRoot(ret)) {
1950
- if (false) {}
1951
- /* istanbul ignore if */
1952
- if (!this._root) { throw Error('unexpected error') }
1953
- return this._root.$i18n.d(value, key, locale)
1954
- } else {
1955
- return ret || ''
1956
- }
1957
- };
1958
-
1959
- VueI18n.prototype.d = function d (value) {
1960
- var args = [], len = arguments.length - 1;
1961
- while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
1962
-
1963
- var locale = this.locale;
1964
- var key = null;
1965
-
1966
- if (args.length === 1) {
1967
- if (isString(args[0])) {
1968
- key = args[0];
1969
- } else if (isObject(args[0])) {
1970
- if (args[0].locale) {
1971
- locale = args[0].locale;
1972
- }
1973
- if (args[0].key) {
1974
- key = args[0].key;
1975
- }
1976
- }
1977
- } else if (args.length === 2) {
1978
- if (isString(args[0])) {
1979
- key = args[0];
1980
- }
1981
- if (isString(args[1])) {
1982
- locale = args[1];
1983
- }
1984
- }
1985
-
1986
- return this._d(value, locale, key)
1987
- };
1988
-
1989
- VueI18n.prototype.getNumberFormat = function getNumberFormat (locale) {
1990
- return looseClone(this._vm.numberFormats[locale] || {})
1991
- };
1992
-
1993
- VueI18n.prototype.setNumberFormat = function setNumberFormat (locale, format) {
1994
- this._vm.$set(this._vm.numberFormats, locale, format);
1995
- this._clearNumberFormat(locale, format);
1996
- };
1997
-
1998
- VueI18n.prototype.mergeNumberFormat = function mergeNumberFormat (locale, format) {
1999
- this._vm.$set(this._vm.numberFormats, locale, merge(this._vm.numberFormats[locale] || {}, format));
2000
- this._clearNumberFormat(locale, format);
2001
- };
2002
-
2003
- VueI18n.prototype._clearNumberFormat = function _clearNumberFormat (locale, format) {
2004
- // eslint-disable-next-line no-autofix/prefer-const
2005
- for (var key in format) {
2006
- var id = locale + "__" + key;
2007
-
2008
- if (!this._numberFormatters.hasOwnProperty(id)) {
2009
- continue
2010
- }
2011
-
2012
- delete this._numberFormatters[id];
2013
- }
2014
- };
2015
-
2016
- VueI18n.prototype._getNumberFormatter = function _getNumberFormatter (
2017
- value,
2018
- locale,
2019
- fallback,
2020
- numberFormats,
2021
- key,
2022
- options
2023
- ) {
2024
- var _locale = locale;
2025
- var formats = numberFormats[_locale];
2026
-
2027
- var chain = this._getLocaleChain(locale, fallback);
2028
- for (var i = 0; i < chain.length; i++) {
2029
- var current = _locale;
2030
- var step = chain[i];
2031
- formats = numberFormats[step];
2032
- _locale = step;
2033
- // fallback locale
2034
- if (isNull(formats) || isNull(formats[key])) {
2035
- if (step !== locale && "production" !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {
2036
- warn(("Fall back to '" + step + "' number formats from '" + current + "' number formats."));
2037
- }
2038
- } else {
2039
- break
2040
- }
2041
- }
2042
-
2043
- if (isNull(formats) || isNull(formats[key])) {
2044
- return null
2045
- } else {
2046
- var format = formats[key];
2047
-
2048
- var formatter;
2049
- if (options) {
2050
- // If options specified - create one time number formatter
2051
- formatter = new Intl.NumberFormat(_locale, Object.assign({}, format, options));
2052
- } else {
2053
- var id = _locale + "__" + key;
2054
- formatter = this._numberFormatters[id];
2055
- if (!formatter) {
2056
- formatter = this._numberFormatters[id] = new Intl.NumberFormat(_locale, format);
2057
- }
2058
- }
2059
- return formatter
2060
- }
2061
- };
2062
-
2063
- VueI18n.prototype._n = function _n (value, locale, key, options) {
2064
- /* istanbul ignore if */
2065
- if (!VueI18n.availabilities.numberFormat) {
2066
- if (false) {}
2067
- return ''
2068
- }
2069
-
2070
- if (!key) {
2071
- var nf = !options ? new Intl.NumberFormat(locale) : new Intl.NumberFormat(locale, options);
2072
- return nf.format(value)
2073
- }
2074
-
2075
- var formatter = this._getNumberFormatter(value, locale, this.fallbackLocale, this._getNumberFormats(), key, options);
2076
- var ret = formatter && formatter.format(value);
2077
- if (this._isFallbackRoot(ret)) {
2078
- if (false) {}
2079
- /* istanbul ignore if */
2080
- if (!this._root) { throw Error('unexpected error') }
2081
- return this._root.$i18n.n(value, Object.assign({}, { key: key, locale: locale }, options))
2082
- } else {
2083
- return ret || ''
2084
- }
2085
- };
2086
-
2087
- VueI18n.prototype.n = function n (value) {
2088
- var args = [], len = arguments.length - 1;
2089
- while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
2090
-
2091
- var locale = this.locale;
2092
- var key = null;
2093
- var options = null;
2094
-
2095
- if (args.length === 1) {
2096
- if (isString(args[0])) {
2097
- key = args[0];
2098
- } else if (isObject(args[0])) {
2099
- if (args[0].locale) {
2100
- locale = args[0].locale;
2101
- }
2102
- if (args[0].key) {
2103
- key = args[0].key;
2104
- }
2105
-
2106
- // Filter out number format options only
2107
- options = Object.keys(args[0]).reduce(function (acc, key) {
2108
- var obj;
2109
-
2110
- if (includes(numberFormatKeys, key)) {
2111
- return Object.assign({}, acc, ( obj = {}, obj[key] = args[0][key], obj ))
2112
- }
2113
- return acc
2114
- }, null);
2115
- }
2116
- } else if (args.length === 2) {
2117
- if (isString(args[0])) {
2118
- key = args[0];
2119
- }
2120
- if (isString(args[1])) {
2121
- locale = args[1];
2122
- }
2123
- }
2124
-
2125
- return this._n(value, locale, key, options)
2126
- };
2127
-
2128
- VueI18n.prototype._ntp = function _ntp (value, locale, key, options) {
2129
- /* istanbul ignore if */
2130
- if (!VueI18n.availabilities.numberFormat) {
2131
- if (false) {}
2132
- return []
2133
- }
2134
-
2135
- if (!key) {
2136
- var nf = !options ? new Intl.NumberFormat(locale) : new Intl.NumberFormat(locale, options);
2137
- return nf.formatToParts(value)
2138
- }
2139
-
2140
- var formatter = this._getNumberFormatter(value, locale, this.fallbackLocale, this._getNumberFormats(), key, options);
2141
- var ret = formatter && formatter.formatToParts(value);
2142
- if (this._isFallbackRoot(ret)) {
2143
- if (false) {}
2144
- /* istanbul ignore if */
2145
- if (!this._root) { throw Error('unexpected error') }
2146
- return this._root.$i18n._ntp(value, locale, key, options)
2147
- } else {
2148
- return ret || []
2149
- }
2150
- };
2151
-
2152
- Object.defineProperties( VueI18n.prototype, prototypeAccessors );
2153
-
2154
- var availabilities;
2155
- // $FlowFixMe
2156
- Object.defineProperty(VueI18n, 'availabilities', {
2157
- get: function get () {
2158
- if (!availabilities) {
2159
- var intlDefined = typeof Intl !== 'undefined';
2160
- availabilities = {
2161
- dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== 'undefined',
2162
- numberFormat: intlDefined && typeof Intl.NumberFormat !== 'undefined'
2163
- };
2164
- }
2165
-
2166
- return availabilities
2167
- }
2168
- });
2169
-
2170
- VueI18n.install = install;
2171
- VueI18n.version = '8.25.0';
2172
-
2173
- /* harmony default export */ __webpack_exports__["a"] = (VueI18n);
2174
-
2175
-
2176
- /***/ })
2177
-
2178
- }]);
2179
- //# sourceMappingURL=super-ui.umd.yarn.vue-i18n~02576867.js.map