vue-i18n 8.25.0 → 8.26.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,43 @@
1
+ ## v8.26.2 (2021-09-28)
2
+
3
+ #### :zap: Improved Features
4
+ * [#1390](https://github.com/kazupon/vue-i18n/pull/1390) improvement: add flags for vue-i18n-bridge ([@kazupon](https://github.com/kazupon))
5
+
6
+ #### Committers: 1
7
+ - kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
8
+
9
+ ## v8.26.1 (2021-09-23)
10
+
11
+ #### :zap: Improved Features
12
+ * [#1388](https://github.com/kazupon/vue-i18n/pull/1388) feat: add sync property ([@kazupon](https://github.com/kazupon))
13
+
14
+ #### Committers: 1
15
+ - kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
16
+
17
+ ## v8.26.0 (2021-09-22)
18
+
19
+ #### :star: New Features
20
+ * [#1385](https://github.com/kazupon/vue-i18n/pull/1385) feat: support for vue-i18n-bridge ([@kazupon](https://github.com/kazupon))
21
+
22
+ #### Committers: 1
23
+ - kazuya kawaguchi ([@kazupon](https://github.com/kazupon))
24
+
25
+ ## v8.25.1 (2021-09-13)
26
+
27
+ #### :bug: Bug Fixes
28
+ * [#1381](https://github.com/kazupon/vue-i18n/pull/1381) fix: linked messages containing slash symbol ([@Lamberthassel](https://github.com/Lamberthassel))
29
+
30
+ #### :lock: Security Fixes
31
+ * [#1353](https://github.com/kazupon/vue-i18n/pull/1353) build(deps): [security] bump tar from 6.0.2 to 6.1.3 ([@dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
32
+
33
+ #### :pencil: Documentation
34
+ * [#1323](https://github.com/kazupon/vue-i18n/pull/1323) Added version notice for custom pluralizations ([@ingria](https://github.com/ingria))
35
+
36
+ #### Committers: 3
37
+ - Igor Nabebin ([@Lamberthassel](https://github.com/Lamberthassel))
38
+ - Ingria ([@ingria](https://github.com/ingria))
39
+ - [@dependabot-preview[bot]](https://github.com/apps/dependabot-preview)
40
+
1
41
  ## v8.25.0 (2021-07-16)
2
42
 
3
43
  #### :star: New Features
package/README.md CHANGED
@@ -66,6 +66,14 @@
66
66
  />
67
67
  </a>
68
68
  </p>
69
+ <p align="center">
70
+ <a href="https://www.deci-bel.com/" target="_blank">
71
+ <img
72
+ src="https://raw.githubusercontent.com/kazupon/vue-i18n/v8.x/vuepress/.vuepress/public/patrons/decibel.png"
73
+ width="144px"
74
+ />
75
+ </a>
76
+ </p>
69
77
 
70
78
  <br/>
71
79
 
package/decls/i18n.js CHANGED
@@ -82,6 +82,7 @@ declare type I18nOptions = {
82
82
  fallbackLocale?: FallbackLocale,
83
83
  messages?: LocaleMessages,
84
84
  dateTimeFormats?: DateTimeFormats,
85
+ datetimeFormats?: DateTimeFormats,
85
86
  numberFormats?: NumberFormats,
86
87
  formatter?: Formatter,
87
88
  missing?: MissingHandler,
@@ -99,6 +100,7 @@ declare type I18nOptions = {
99
100
  postTranslation?: PostTranslationHandler,
100
101
  componentInstanceCreatedListener?: ComponentInstanceCreatedListener,
101
102
  escapeParameterHtml?: boolean,
103
+ __VUE_I18N_BRIDGE__?: string,
102
104
  };
103
105
 
104
106
  declare type IntlAvailability = {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vue-i18n v8.25.0
2
+ * vue-i18n v8.26.2
3
3
  * (c) 2021 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
@@ -270,147 +270,161 @@ function extend (Vue) {
270
270
 
271
271
  /* */
272
272
 
273
- var mixin = {
274
- beforeCreate: function beforeCreate () {
275
- var options = this.$options;
276
- options.i18n = options.i18n || (options.__i18n ? {} : null);
277
-
278
- if (options.i18n) {
279
- if (options.i18n instanceof VueI18n) {
280
- // init locale messages via custom blocks
281
- if (options.__i18n) {
282
- try {
283
- var localeMessages = options.i18n && options.i18n.messages ? options.i18n.messages : {};
284
- options.__i18n.forEach(function (resource) {
285
- localeMessages = merge(localeMessages, JSON.parse(resource));
286
- });
287
- Object.keys(localeMessages).forEach(function (locale) {
288
- options.i18n.mergeLocaleMessage(locale, localeMessages[locale]);
289
- });
290
- } catch (e) {
291
- if (process.env.NODE_ENV !== 'production') {
292
- error("Cannot parse locale messages via custom blocks.", e);
273
+ /**
274
+ * Mixin
275
+ *
276
+ * If `bridge` mode, empty mixin is returned,
277
+ * else regulary mixin implementation is returned.
278
+ */
279
+ function defineMixin (bridge) {
280
+ if ( bridge === void 0 ) bridge = false;
281
+
282
+ function mounted () {
283
+ if (this !== this.$root && this.$options.__INTLIFY_META__ && this.$el) {
284
+ this.$el.setAttribute('data-intlify', this.$options.__INTLIFY_META__);
285
+ }
286
+ }
287
+
288
+ return bridge
289
+ ? { mounted: mounted } // delegate `vue-i18n-bridge` mixin implementation
290
+ : { // regulary
291
+ beforeCreate: function beforeCreate () {
292
+ var options = this.$options;
293
+ options.i18n = options.i18n || (options.__i18n ? {} : null);
294
+
295
+ if (options.i18n) {
296
+ if (options.i18n instanceof VueI18n) {
297
+ // init locale messages via custom blocks
298
+ if (options.__i18n) {
299
+ try {
300
+ var localeMessages = options.i18n && options.i18n.messages ? options.i18n.messages : {};
301
+ options.__i18n.forEach(function (resource) {
302
+ localeMessages = merge(localeMessages, JSON.parse(resource));
303
+ });
304
+ Object.keys(localeMessages).forEach(function (locale) {
305
+ options.i18n.mergeLocaleMessage(locale, localeMessages[locale]);
306
+ });
307
+ } catch (e) {
308
+ if (process.env.NODE_ENV !== 'production') {
309
+ error("Cannot parse locale messages via custom blocks.", e);
310
+ }
293
311
  }
294
312
  }
295
- }
296
- this._i18n = options.i18n;
297
- this._i18nWatcher = this._i18n.watchI18nData();
298
- } else if (isPlainObject(options.i18n)) {
299
- var rootI18n = this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n
300
- ? this.$root.$i18n
301
- : null;
302
- // component local i18n
303
- if (rootI18n) {
304
- options.i18n.root = this.$root;
305
- options.i18n.formatter = rootI18n.formatter;
306
- options.i18n.fallbackLocale = rootI18n.fallbackLocale;
307
- options.i18n.formatFallbackMessages = rootI18n.formatFallbackMessages;
308
- options.i18n.silentTranslationWarn = rootI18n.silentTranslationWarn;
309
- options.i18n.silentFallbackWarn = rootI18n.silentFallbackWarn;
310
- options.i18n.pluralizationRules = rootI18n.pluralizationRules;
311
- options.i18n.preserveDirectiveContent = rootI18n.preserveDirectiveContent;
312
- }
313
+ this._i18n = options.i18n;
314
+ this._i18nWatcher = this._i18n.watchI18nData();
315
+ } else if (isPlainObject(options.i18n)) {
316
+ var rootI18n = this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n
317
+ ? this.$root.$i18n
318
+ : null;
319
+ // component local i18n
320
+ if (rootI18n) {
321
+ options.i18n.root = this.$root;
322
+ options.i18n.formatter = rootI18n.formatter;
323
+ options.i18n.fallbackLocale = rootI18n.fallbackLocale;
324
+ options.i18n.formatFallbackMessages = rootI18n.formatFallbackMessages;
325
+ options.i18n.silentTranslationWarn = rootI18n.silentTranslationWarn;
326
+ options.i18n.silentFallbackWarn = rootI18n.silentFallbackWarn;
327
+ options.i18n.pluralizationRules = rootI18n.pluralizationRules;
328
+ options.i18n.preserveDirectiveContent = rootI18n.preserveDirectiveContent;
329
+ }
313
330
 
314
- // init locale messages via custom blocks
315
- if (options.__i18n) {
316
- try {
317
- var localeMessages$1 = options.i18n && options.i18n.messages ? options.i18n.messages : {};
318
- options.__i18n.forEach(function (resource) {
319
- localeMessages$1 = merge(localeMessages$1, JSON.parse(resource));
320
- });
321
- options.i18n.messages = localeMessages$1;
322
- } catch (e) {
323
- if (process.env.NODE_ENV !== 'production') {
324
- warn("Cannot parse locale messages via custom blocks.", e);
331
+ // init locale messages via custom blocks
332
+ if (options.__i18n) {
333
+ try {
334
+ var localeMessages$1 = options.i18n && options.i18n.messages ? options.i18n.messages : {};
335
+ options.__i18n.forEach(function (resource) {
336
+ localeMessages$1 = merge(localeMessages$1, JSON.parse(resource));
337
+ });
338
+ options.i18n.messages = localeMessages$1;
339
+ } catch (e) {
340
+ if (process.env.NODE_ENV !== 'production') {
341
+ warn("Cannot parse locale messages via custom blocks.", e);
342
+ }
325
343
  }
326
344
  }
327
- }
328
345
 
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
- }
346
+ var ref = options.i18n;
347
+ var sharedMessages = ref.sharedMessages;
348
+ if (sharedMessages && isPlainObject(sharedMessages)) {
349
+ options.i18n.messages = merge(options.i18n.messages, sharedMessages);
350
+ }
334
351
 
335
- this._i18n = new VueI18n(options.i18n);
336
- this._i18nWatcher = this._i18n.watchI18nData();
352
+ this._i18n = new VueI18n(options.i18n);
353
+ this._i18nWatcher = this._i18n.watchI18nData();
337
354
 
338
- if (options.i18n.sync === undefined || !!options.i18n.sync) {
339
- this._localeWatcher = this.$i18n.watchLocale();
340
- }
355
+ if (options.i18n.sync === undefined || !!options.i18n.sync) {
356
+ this._localeWatcher = this.$i18n.watchLocale();
357
+ }
341
358
 
342
- if (rootI18n) {
343
- rootI18n.onComponentInstanceCreated(this._i18n);
344
- }
345
- } else {
346
- if (process.env.NODE_ENV !== 'production') {
347
- warn("Cannot be interpreted 'i18n' option.");
359
+ if (rootI18n) {
360
+ rootI18n.onComponentInstanceCreated(this._i18n);
361
+ }
362
+ } else {
363
+ if (process.env.NODE_ENV !== 'production') {
364
+ warn("Cannot be interpreted 'i18n' option.");
365
+ }
348
366
  }
367
+ } else if (this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n) {
368
+ // root i18n
369
+ this._i18n = this.$root.$i18n;
370
+ } else if (options.parent && options.parent.$i18n && options.parent.$i18n instanceof VueI18n) {
371
+ // parent i18n
372
+ this._i18n = options.parent.$i18n;
349
373
  }
350
- } else if (this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n) {
351
- // root i18n
352
- this._i18n = this.$root.$i18n;
353
- } else if (options.parent && options.parent.$i18n && options.parent.$i18n instanceof VueI18n) {
354
- // parent i18n
355
- this._i18n = options.parent.$i18n;
356
- }
357
- },
358
-
359
- beforeMount: function beforeMount () {
360
- var options = this.$options;
361
- options.i18n = options.i18n || (options.__i18n ? {} : null);
374
+ },
362
375
 
363
- if (options.i18n) {
364
- if (options.i18n instanceof VueI18n) {
365
- // init locale messages via custom blocks
376
+ beforeMount: function beforeMount () {
377
+ var options = this.$options;
378
+ options.i18n = options.i18n || (options.__i18n ? {} : null);
379
+
380
+ if (options.i18n) {
381
+ if (options.i18n instanceof VueI18n) {
382
+ // init locale messages via custom blocks
383
+ this._i18n.subscribeDataChanging(this);
384
+ this._subscribing = true;
385
+ } else if (isPlainObject(options.i18n)) {
386
+ this._i18n.subscribeDataChanging(this);
387
+ this._subscribing = true;
388
+ } else {
389
+ if (process.env.NODE_ENV !== 'production') {
390
+ warn("Cannot be interpreted 'i18n' option.");
391
+ }
392
+ }
393
+ } else if (this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n) {
366
394
  this._i18n.subscribeDataChanging(this);
367
395
  this._subscribing = true;
368
- } else if (isPlainObject(options.i18n)) {
396
+ } else if (options.parent && options.parent.$i18n && options.parent.$i18n instanceof VueI18n) {
369
397
  this._i18n.subscribeDataChanging(this);
370
398
  this._subscribing = true;
371
- } else {
372
- if (process.env.NODE_ENV !== 'production') {
373
- warn("Cannot be interpreted 'i18n' option.");
374
- }
375
399
  }
376
- } else if (this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n) {
377
- this._i18n.subscribeDataChanging(this);
378
- this._subscribing = true;
379
- } else if (options.parent && options.parent.$i18n && options.parent.$i18n instanceof VueI18n) {
380
- this._i18n.subscribeDataChanging(this);
381
- this._subscribing = true;
382
- }
383
- },
400
+ },
384
401
 
385
- mounted: function mounted () {
386
- if (this !== this.$root && this.$options.__INTLIFY_META__ && this.$el) {
387
- this.$el.setAttribute('data-intlify', this.$options.__INTLIFY_META__);
388
- }
389
- },
402
+ mounted: mounted,
390
403
 
391
- beforeDestroy: function beforeDestroy () {
392
- if (!this._i18n) { return }
404
+ beforeDestroy: function beforeDestroy () {
405
+ if (!this._i18n) { return }
393
406
 
394
- var self = this;
395
- this.$nextTick(function () {
396
- if (self._subscribing) {
397
- self._i18n.unsubscribeDataChanging(self);
398
- delete self._subscribing;
399
- }
407
+ var self = this;
408
+ this.$nextTick(function () {
409
+ if (self._subscribing) {
410
+ self._i18n.unsubscribeDataChanging(self);
411
+ delete self._subscribing;
412
+ }
400
413
 
401
- if (self._i18nWatcher) {
402
- self._i18nWatcher();
403
- self._i18n.destroyVM();
404
- delete self._i18nWatcher;
405
- }
414
+ if (self._i18nWatcher) {
415
+ self._i18nWatcher();
416
+ self._i18n.destroyVM();
417
+ delete self._i18nWatcher;
418
+ }
406
419
 
407
- if (self._localeWatcher) {
408
- self._localeWatcher();
409
- delete self._localeWatcher;
410
- }
411
- });
420
+ if (self._localeWatcher) {
421
+ self._localeWatcher();
422
+ delete self._localeWatcher;
423
+ }
424
+ });
425
+ }
412
426
  }
413
- };
427
+ }
414
428
 
415
429
  /* */
416
430
 
@@ -715,7 +729,9 @@ function makeParams (locale, args) {
715
729
 
716
730
  var Vue;
717
731
 
718
- function install (_Vue) {
732
+ function install (_Vue, options) {
733
+ if ( options === void 0 ) options = { bridge: false };
734
+
719
735
  /* istanbul ignore if */
720
736
  if (process.env.NODE_ENV !== 'production' && install.installed && _Vue === Vue) {
721
737
  warn('already installed.');
@@ -733,7 +749,7 @@ function install (_Vue) {
733
749
  }
734
750
 
735
751
  extend(Vue);
736
- Vue.mixin(mixin);
752
+ Vue.mixin(defineMixin(options.bridge));
737
753
  Vue.directive('t', { bind: bind, update: update, unbind: unbind });
738
754
  Vue.component(interpolationComponent.name, interpolationComponent);
739
755
  Vue.component(numberComponent.name, numberComponent);
@@ -1155,7 +1171,7 @@ I18nPath.prototype.getPathValue = function getPathValue (obj, path) {
1155
1171
 
1156
1172
 
1157
1173
  var htmlTagMatcher = /<\/?[\w\s="/.':;#-\/]+>/;
1158
- var linkKeyMatcher = /(?:@(?:\.[a-z]+)?:(?:[\w\-_|.]+|\([\w\-_|.]+\)))/g;
1174
+ var linkKeyMatcher = /(?:@(?:\.[a-z]+)?:(?:[\w\-_|./]+|\([\w\-_|./]+\)))/g;
1159
1175
  var linkKeyPrefixMatcher = /^@(?:\.([a-z]+))?:/;
1160
1176
  var bracketsMatcher = /[()]/g;
1161
1177
  var defaultModifiers = {
@@ -1183,7 +1199,7 @@ var VueI18n = function VueI18n (options) {
1183
1199
  ? false
1184
1200
  : options.fallbackLocale || 'en-US';
1185
1201
  var messages = options.messages || {};
1186
- var dateTimeFormats = options.dateTimeFormats || {};
1202
+ var dateTimeFormats = options.dateTimeFormats || options.datetimeFormats || {};
1187
1203
  var numberFormats = options.numberFormats || {};
1188
1204
 
1189
1205
  this._vm = null;
@@ -1217,6 +1233,10 @@ var VueI18n = function VueI18n (options) {
1217
1233
  this._postTranslation = options.postTranslation || null;
1218
1234
  this._escapeParameterHtml = options.escapeParameterHtml || false;
1219
1235
 
1236
+ if ('__VUE_I18N_BRIDGE__' in options) {
1237
+ this.__VUE_I18N_BRIDGE__ = options.__VUE_I18N_BRIDGE__;
1238
+ }
1239
+
1220
1240
  /**
1221
1241
  * @param choice {number} a choice index given by the input to $tc: `$tc('path.to.rule', choiceIndex)`
1222
1242
  * @param choicesLength {number} an overall amount of available choices
@@ -1275,7 +1295,7 @@ var VueI18n = function VueI18n (options) {
1275
1295
  });
1276
1296
  };
1277
1297
 
1278
- 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 } };
1298
+ 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 },sync: { configurable: true } };
1279
1299
 
1280
1300
  VueI18n.prototype._checkLocaleMessage = function _checkLocaleMessage (locale, level, message) {
1281
1301
  var paths = [];
@@ -1329,7 +1349,7 @@ VueI18n.prototype._checkLocaleMessage = function _checkLocaleMessage (locale, le
1329
1349
  VueI18n.prototype._initVM = function _initVM (data) {
1330
1350
  var silent = Vue.config.silent;
1331
1351
  Vue.config.silent = true;
1332
- this._vm = new Vue({ data: data });
1352
+ this._vm = new Vue({ data: data, __VUE18N__INSTANCE__: true });
1333
1353
  Vue.config.silent = silent;
1334
1354
  };
1335
1355
 
@@ -1427,6 +1447,9 @@ prototypeAccessors.warnHtmlInMessage.set = function (level) {
1427
1447
  prototypeAccessors.postTranslation.get = function () { return this._postTranslation };
1428
1448
  prototypeAccessors.postTranslation.set = function (handler) { this._postTranslation = handler; };
1429
1449
 
1450
+ prototypeAccessors.sync.get = function () { return this._sync };
1451
+ prototypeAccessors.sync.set = function (val) { this._sync = val; };
1452
+
1430
1453
  VueI18n.prototype._getMessages = function _getMessages () { return this._vm.messages };
1431
1454
  VueI18n.prototype._getDateTimeFormats = function _getDateTimeFormats () { return this._vm.dateTimeFormats };
1432
1455
  VueI18n.prototype._getNumberFormats = function _getNumberFormats () { return this._vm.numberFormats };
@@ -2220,6 +2243,6 @@ Object.defineProperty(VueI18n, 'availabilities', {
2220
2243
  });
2221
2244
 
2222
2245
  VueI18n.install = install;
2223
- VueI18n.version = '8.25.0';
2246
+ VueI18n.version = '8.26.2';
2224
2247
 
2225
2248
  module.exports = VueI18n;