vue-i18n 11.4.16 → 11.4.17

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/dist/vue-i18n.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vue-i18n v11.4.16
2
+ * vue-i18n v11.4.17
3
3
  * (c) 2026 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
@@ -30,7 +30,7 @@ var Vue__namespace = /*#__PURE__*/_interopNamespaceDefault(Vue);
30
30
  *
31
31
  * @VueI18nGeneral
32
32
  */
33
- const VERSION = '11.4.16';
33
+ const VERSION = '11.4.17';
34
34
 
35
35
  const I18nErrorCodes = {
36
36
  // composer module errors
@@ -792,6 +792,22 @@ function createComposer(options = {}) {
792
792
  /* eslint-enable @typescript-eslint/no-explicit-any */
793
793
 
794
794
  /* eslint-disable @typescript-eslint/no-explicit-any */
795
+ // `silentTranslationWarn` and `silentFallbackWarn` suppress the warnings for the keys that match a regular expression,
796
+ // while `missingWarn` and `fallbackWarn` of Composer output the warnings only for the keys that match it, so convert
797
+ // a regular expression into one that matches the keys that it does not match (and back again)
798
+ const invertedWarnRegExps = new WeakMap();
799
+ function invertWarn(warn) {
800
+ if (!shared.isRegExp(warn)) {
801
+ return !warn;
802
+ }
803
+ let inverted = invertedWarnRegExps.get(warn);
804
+ if (!inverted) {
805
+ inverted = new RegExp(`^(?![\\s\\S]*(?:${warn.source}))`, warn.flags.replace(/[gy]/g, ''));
806
+ invertedWarnRegExps.set(warn, inverted);
807
+ invertedWarnRegExps.set(inverted, warn);
808
+ }
809
+ return inverted;
810
+ }
795
811
  /**
796
812
  * Convert to I18n Composer Options from VueI18n Options
797
813
  *
@@ -808,11 +824,11 @@ function convertComposerOptions(options) {
808
824
  const missing = shared.isFunction(options.missing) ? options.missing : undefined;
809
825
  const missingWarn = shared.isBoolean(options.silentTranslationWarn) ||
810
826
  shared.isRegExp(options.silentTranslationWarn)
811
- ? !options.silentTranslationWarn
827
+ ? invertWarn(options.silentTranslationWarn)
812
828
  : true;
813
829
  const fallbackWarn = shared.isBoolean(options.silentFallbackWarn) ||
814
830
  shared.isRegExp(options.silentFallbackWarn)
815
- ? !options.silentFallbackWarn
831
+ ? invertWarn(options.silentFallbackWarn)
816
832
  : true;
817
833
  const fallbackRoot = shared.isBoolean(options.fallbackRoot)
818
834
  ? options.fallbackRoot
@@ -922,21 +938,17 @@ function createVueI18n(options = {}) {
922
938
  },
923
939
  // silentTranslationWarn
924
940
  get silentTranslationWarn() {
925
- return shared.isBoolean(composer.missingWarn)
926
- ? !composer.missingWarn
927
- : composer.missingWarn;
941
+ return invertWarn(composer.missingWarn);
928
942
  },
929
943
  set silentTranslationWarn(val) {
930
- composer.missingWarn = shared.isBoolean(val) ? !val : val;
944
+ composer.missingWarn = invertWarn(val);
931
945
  },
932
946
  // silentFallbackWarn
933
947
  get silentFallbackWarn() {
934
- return shared.isBoolean(composer.fallbackWarn)
935
- ? !composer.fallbackWarn
936
- : composer.fallbackWarn;
948
+ return invertWarn(composer.fallbackWarn);
937
949
  },
938
950
  set silentFallbackWarn(val) {
939
- composer.fallbackWarn = shared.isBoolean(val) ? !val : val;
951
+ composer.fallbackWarn = invertWarn(val);
940
952
  },
941
953
  // modifiers
942
954
  get modifiers() {
@@ -1597,7 +1609,7 @@ function createI18n(options = {}) {
1597
1609
  : 'composition';
1598
1610
  },
1599
1611
  // install plugin
1600
- async install(app, ...options) {
1612
+ install(app, ...options) {
1601
1613
  // setup global provider
1602
1614
  app.__VUE_I18N_SYMBOL__ = symbol;
1603
1615
  app.provide(app.__VUE_I18N_SYMBOL__, i18n);
@@ -199,14 +199,14 @@ export declare interface Composer<Messages extends Record<string, any> = {}, Dat
199
199
  readonly isGlobal: boolean;
200
200
  /**
201
201
  * @remarks
202
- * Whether suppress warnings outputted when localization fails.
202
+ * Whether to output a warning when the locale messages of a locale do not have the key.
203
203
  *
204
204
  * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
205
205
  */
206
206
  missingWarn: boolean | RegExp;
207
207
  /**
208
208
  * @remarks
209
- * Whether suppress fall back warnings when localization fails.
209
+ * Whether to output a warning when falling back to either `fallbackLocale` or root.
210
210
  *
211
211
  * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
212
212
  */
@@ -220,7 +220,7 @@ export declare interface Composer<Messages extends Record<string, any> = {}, Dat
220
220
  fallbackRoot: boolean;
221
221
  /**
222
222
  * @remarks
223
- * Whether suppress warnings when falling back to either `fallbackLocale` or root.
223
+ * Whether do template interpolation on translation keys when your language lacks a translation for a key.
224
224
  *
225
225
  * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
226
226
  */
@@ -808,11 +808,11 @@ export declare interface ComposerOptions<Schema extends {
808
808
  missing?: MissingHandler;
809
809
  /**
810
810
  * @remarks
811
- * Whether suppress warnings outputted when localization fails.
811
+ * Whether to output a warning when the locale messages of a locale do not have the key.
812
812
  *
813
- * If `false`, suppress localization fail warnings.
813
+ * If `false`, no warnings are output, including the warning for a key that no locale has.
814
814
  *
815
- * If you use regular expression, you can suppress localization fail warnings that it match with translation key (e.g. `t`).
815
+ * If you use regular expression, the warnings are output only for the translation keys that match it (e.g. `t`).
816
816
  *
817
817
  * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
818
818
  *
@@ -821,11 +821,13 @@ export declare interface ComposerOptions<Schema extends {
821
821
  missingWarn?: boolean | RegExp;
822
822
  /**
823
823
  * @remarks
824
- * Whether suppress warnings when falling back to either `fallbackLocale` or root.
824
+ * Whether to output a warning when falling back to either `fallbackLocale` or root.
825
+ *
826
+ * If `false`, no warnings are output when falling back to `fallbackLocale`.
825
827
  *
826
- * If `false`, suppress fall back warnings.
828
+ * If you use regular expression, the warnings are output only for the translation keys that match it (e.g. `t`).
827
829
  *
828
- * If you use regular expression, you can suppress fallback warnings that it match with translation key (e.g. `t`).
830
+ * The warning when falling back to root is output if `fallbackWarn` or `missingWarn` outputs a warning for the key.
829
831
  *
830
832
  * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
831
833
  *
@@ -885,7 +887,9 @@ export declare interface ComposerOptions<Schema extends {
885
887
  * - Sanitizes the final translated HTML to prevent XSS attacks by:
886
888
  * - Escaping dangerous characters in HTML attribute values
887
889
  * - Neutralizing event handler attributes (onclick, onerror, etc.)
888
- * - Disabling javascript: URLs in href, src, action, formaction, and style attributes
890
+ * - Neutralizing the `srcdoc` attribute of `<iframe>`
891
+ * - Neutralizing `<base>` elements, and SVG `<animate>` and `<set>` elements
892
+ * - Disabling javascript: URLs in href (and xlink:href of SVG), src, action, formaction, and style attributes
889
893
  *
890
894
  * This is useful when translation output is used in `v-html` and the translation resource contains html markup (e.g. <b> around a user provided value).
891
895
  *
@@ -2237,12 +2241,14 @@ export declare interface VueI18n<Messages extends Record<string, any> = {}, Date
2237
2241
  silentTranslationWarn: Composition['missingWarn'];
2238
2242
  /**
2239
2243
  * @remarks
2240
- * Whether suppress fallback warnings when localization fails.
2244
+ * Whether suppress warnings when falling back to either `fallbackLocale` or root.
2245
+ *
2246
+ * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
2241
2247
  */
2242
2248
  silentFallbackWarn: Composition['fallbackWarn'];
2243
2249
  /**
2244
2250
  * @remarks
2245
- * Whether suppress warnings when falling back to either `fallbackLocale` or root.
2251
+ * Whether do template interpolation on translation keys when your language lacks a translation for a key.
2246
2252
  *
2247
2253
  * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
2248
2254
  */
@@ -2761,9 +2767,11 @@ export declare interface VueI18nOptions<Schema extends {
2761
2767
  silentTranslationWarn?: Options['missingWarn'];
2762
2768
  /**
2763
2769
  * @remarks
2764
- * Whether do template interpolation on translation keys when your language lacks a translation for a key.
2770
+ * Whether suppress warnings when falling back to either `fallbackLocale` or root.
2765
2771
  *
2766
- * If `true`, skip writing templates for your "base" language; the keys are your templates.
2772
+ * If `true`, suppress fall back warnings.
2773
+ *
2774
+ * If you use regular expression, you can suppress fall back warnings that it match with translation key (e.g. `t`).
2767
2775
  *
2768
2776
  * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
2769
2777
  *
@@ -2772,7 +2780,9 @@ export declare interface VueI18nOptions<Schema extends {
2772
2780
  silentFallbackWarn?: Options['fallbackWarn'];
2773
2781
  /**
2774
2782
  * @remarks
2775
- * Whether suppress warnings when falling back to either `fallbackLocale` or root.
2783
+ * Whether do template interpolation on translation keys when your language lacks a translation for a key.
2784
+ *
2785
+ * If `true`, skip writing templates for your "base" language; the keys are your templates.
2776
2786
  *
2777
2787
  * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
2778
2788
  *
@@ -2799,7 +2809,9 @@ export declare interface VueI18nOptions<Schema extends {
2799
2809
  * - Sanitizes the final translated HTML to prevent XSS attacks by:
2800
2810
  * - Escaping dangerous characters in HTML attribute values
2801
2811
  * - Neutralizing event handler attributes (onclick, onerror, etc.)
2802
- * - Disabling javascript: URLs in href, src, action, formaction, and style attributes
2812
+ * - Neutralizing the `srcdoc` attribute of `<iframe>`
2813
+ * - Neutralizing `<base>` elements, and SVG `<animate>` and `<set>` elements
2814
+ * - Disabling javascript: URLs in href (and xlink:href of SVG), src, action, formaction, and style attributes
2803
2815
  *
2804
2816
  * This is useful when translation output is used in `v-html` and the translation resource contains html markup (e.g. <b> around a user provided value).
2805
2817
  *
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * vue-i18n v11.4.16
2
+ * vue-i18n v11.4.17
3
3
  * (c) 2026 kazuya kawaguchi
4
4
  * Released under the MIT License.
5
5
  */
@@ -202,7 +202,8 @@ function escapeAttributeValue(value) {
202
202
  .replace(/>/g, '&gt;');
203
203
  }
204
204
  const javascriptSchemePattern = /^javascript:/i;
205
- const urlAttributePattern = /^(?:href|src|action|formaction)$/i;
205
+ // `xlink:href` is the older spelling of `href` on SVG elements, and an SVG `<a>` follows either of them
206
+ const urlAttributePattern = /^(?:href|xlink:href|src|action|formaction)$/i;
206
207
  const numericCharacterReferencePattern = /&#(?:x([0-9a-f]+)|(\d+));?/gi;
207
208
  const namedWhitespaceCharacterReferencePattern = /&(?:Tab|NewLine);/g;
208
209
  const colonCharacterReferencePattern = /&colon;?/gi;
@@ -214,7 +215,11 @@ const eventHandlerAttributePattern = /(^|[\s"'<>/])on(\w+\s*=)/gi;
214
215
  // so neither escaping the value nor neutralizing `on*` inside it makes it inert
215
216
  const srcdocPattern = /(?:^|[\s"'<>/])srcdoc\s*=/i;
216
217
  const srcdocAttributePattern = /(^|[\s"'<>/])s(rcdoc\s*=)/gi;
217
- const unquotedUrlAttributePattern = /(^|[\s"'<>/])((?:href|src|action|formaction)\s*=\s*)([^\s"'=<>`]+)/gi;
218
+ // `<base>` changes how the page resolves every relative URL after it, and SVG `<animate>` and `<set>`
219
+ // can set `href` of an SVG `<a>` through `values` or `to`, which the URL check does not look at
220
+ const dangerousElementPattern = /<(?:base|animate|set)(?=[\s/>]|$)/i;
221
+ const dangerousElementStartTagPattern = /<(base|animate|set)(?=[\s/>]|$)/gi;
222
+ const unquotedUrlAttributePattern = /(^|[\s"'<>/])((?:href|xlink:href|src|action|formaction)\s*=\s*)([^\s"'=<>`]+)/gi;
218
223
  function decodeNumericCharacterReference(match, hex, decimal) {
219
224
  const digits = hex || decimal;
220
225
  if (!digits) {
@@ -310,6 +315,15 @@ function sanitizeTranslatedHtml(html) {
310
315
  // Neutralize `srcdoc` by escaping 's': character references are not decoded in attribute names
311
316
  html = html.replace(srcdocAttributePattern, '$1&#115;$2');
312
317
  }
318
+ // Detect and neutralize `<base>`, `<animate>` and `<set>` elements
319
+ if (dangerousElementPattern.test(html)) {
320
+ {
321
+ warn('Potentially dangerous element (<base>, <animate> or <set>) detected in translation. ' +
322
+ 'Consider removing it from your translation messages.');
323
+ }
324
+ // Neutralize these elements by escaping '<': the start tag becomes text
325
+ html = html.replace(dangerousElementStartTagPattern, '&lt;$1');
326
+ }
313
327
  // Disable javascript: URLs in unquoted attributes
314
328
  html = html.replace(unquotedUrlAttributePattern, (match, boundary, prefix, attrValue) => hasJavascriptScheme(attrValue) ? `${boundary}${prefix}about:blank` : match);
315
329
  return html;
@@ -2691,7 +2705,7 @@ function getWarnMessage$1(code, ...args) {
2691
2705
  * Intlify core-base version
2692
2706
  * @internal
2693
2707
  */
2694
- const VERSION$1 = '11.4.16';
2708
+ const VERSION$1 = '11.4.17';
2695
2709
  const NOT_REOSLVED = -1;
2696
2710
  const DEFAULT_LOCALE = 'en-US';
2697
2711
  const MISSING_RESOLVE_VALUE = '';
@@ -3815,7 +3829,7 @@ function getMessageContextOptions(context, locale, message, options) {
3815
3829
  *
3816
3830
  * @VueI18nGeneral
3817
3831
  */
3818
- const VERSION = '11.4.16';
3832
+ const VERSION = '11.4.17';
3819
3833
  /**
3820
3834
  * This is only called development env
3821
3835
  * istanbul-ignore-next
@@ -5236,6 +5250,22 @@ function editScope(payload, i18n) {
5236
5250
  }
5237
5251
 
5238
5252
  /* eslint-disable @typescript-eslint/no-explicit-any */
5253
+ // `silentTranslationWarn` and `silentFallbackWarn` suppress the warnings for the keys that match a regular expression,
5254
+ // while `missingWarn` and `fallbackWarn` of Composer output the warnings only for the keys that match it, so convert
5255
+ // a regular expression into one that matches the keys that it does not match (and back again)
5256
+ const invertedWarnRegExps = new WeakMap();
5257
+ function invertWarn(warn) {
5258
+ if (!isRegExp(warn)) {
5259
+ return !warn;
5260
+ }
5261
+ let inverted = invertedWarnRegExps.get(warn);
5262
+ if (!inverted) {
5263
+ inverted = new RegExp(`^(?![\\s\\S]*(?:${warn.source}))`, warn.flags.replace(/[gy]/g, ''));
5264
+ invertedWarnRegExps.set(warn, inverted);
5265
+ invertedWarnRegExps.set(inverted, warn);
5266
+ }
5267
+ return inverted;
5268
+ }
5239
5269
  /**
5240
5270
  * Convert to I18n Composer Options from VueI18n Options
5241
5271
  *
@@ -5252,11 +5282,11 @@ function convertComposerOptions(options) {
5252
5282
  const missing = isFunction(options.missing) ? options.missing : undefined;
5253
5283
  const missingWarn = isBoolean(options.silentTranslationWarn) ||
5254
5284
  isRegExp(options.silentTranslationWarn)
5255
- ? !options.silentTranslationWarn
5285
+ ? invertWarn(options.silentTranslationWarn)
5256
5286
  : true;
5257
5287
  const fallbackWarn = isBoolean(options.silentFallbackWarn) ||
5258
5288
  isRegExp(options.silentFallbackWarn)
5259
- ? !options.silentFallbackWarn
5289
+ ? invertWarn(options.silentFallbackWarn)
5260
5290
  : true;
5261
5291
  const fallbackRoot = isBoolean(options.fallbackRoot)
5262
5292
  ? options.fallbackRoot
@@ -5366,21 +5396,17 @@ function createVueI18n(options = {}) {
5366
5396
  },
5367
5397
  // silentTranslationWarn
5368
5398
  get silentTranslationWarn() {
5369
- return isBoolean(composer.missingWarn)
5370
- ? !composer.missingWarn
5371
- : composer.missingWarn;
5399
+ return invertWarn(composer.missingWarn);
5372
5400
  },
5373
5401
  set silentTranslationWarn(val) {
5374
- composer.missingWarn = isBoolean(val) ? !val : val;
5402
+ composer.missingWarn = invertWarn(val);
5375
5403
  },
5376
5404
  // silentFallbackWarn
5377
5405
  get silentFallbackWarn() {
5378
- return isBoolean(composer.fallbackWarn)
5379
- ? !composer.fallbackWarn
5380
- : composer.fallbackWarn;
5406
+ return invertWarn(composer.fallbackWarn);
5381
5407
  },
5382
5408
  set silentFallbackWarn(val) {
5383
- composer.fallbackWarn = isBoolean(val) ? !val : val;
5409
+ composer.fallbackWarn = invertWarn(val);
5384
5410
  },
5385
5411
  // modifiers
5386
5412
  get modifiers() {
@@ -6082,7 +6108,7 @@ function createI18n(options = {}) {
6082
6108
  : 'composition';
6083
6109
  },
6084
6110
  // install plugin
6085
- async install(app, ...options) {
6111
+ install(app, ...options) {
6086
6112
  {
6087
6113
  app.__VUE_I18N__ = i18n;
6088
6114
  }
@@ -6119,21 +6145,31 @@ function createI18n(options = {}) {
6119
6145
  };
6120
6146
  // setup vue-devtools plugin
6121
6147
  {
6122
- const ret = await enableDevTools(app, i18n);
6123
- if (!ret) {
6124
- throw createI18nError(I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN);
6125
- }
6126
- const emitter = createEmitter();
6127
- if (__legacyMode) {
6128
- const _vueI18n = __global;
6129
- _vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter);
6130
- }
6131
- else {
6132
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
6133
- const _composer = __global;
6134
- _composer[EnableEmitter] && _composer[EnableEmitter](emitter);
6135
- }
6136
- emitter.on('*', addTimelineEvent);
6148
+ // do not wait for the devtools: a Vue plugin installs synchronously, and the devtools call
6149
+ // the setup only when they are open, so the setup may never finish
6150
+ enableDevTools(app, i18n)
6151
+ .then(ret => {
6152
+ if (!ret) {
6153
+ throw createI18nError(I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN);
6154
+ }
6155
+ const emitter = createEmitter();
6156
+ if (__legacyMode) {
6157
+ const _vueI18n = __global;
6158
+ _vueI18n.__enableEmitter && _vueI18n.__enableEmitter(emitter);
6159
+ }
6160
+ else {
6161
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6162
+ const _composer = __global;
6163
+ _composer[EnableEmitter] && _composer[EnableEmitter](emitter);
6164
+ }
6165
+ emitter.on('*', addTimelineEvent);
6166
+ })
6167
+ .catch(() => {
6168
+ // a failure of the devtools must not break the app
6169
+ {
6170
+ warn(errorMessages[I18nErrorCodes.CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN]);
6171
+ }
6172
+ });
6137
6173
  }
6138
6174
  },
6139
6175
  // global accessor