vue-i18n 11.4.22 → 11.4.24
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 +57 -8
- package/dist/vue-i18n.d.ts +123 -42
- package/dist/vue-i18n.esm-browser.js +63 -17
- package/dist/vue-i18n.esm-browser.prod.js +2 -2
- package/dist/vue-i18n.global.js +62 -16
- package/dist/vue-i18n.global.prod.js +2 -2
- package/dist/vue-i18n.mjs +61 -10
- package/dist/vue-i18n.node.mjs +60 -10
- package/dist/vue-i18n.prod.cjs +57 -8
- package/dist/vue-i18n.runtime.esm-browser.js +63 -17
- package/dist/vue-i18n.runtime.esm-browser.prod.js +2 -2
- package/dist/vue-i18n.runtime.global.js +62 -16
- package/dist/vue-i18n.runtime.global.prod.js +2 -2
- package/dist/vue-i18n.runtime.mjs +61 -10
- package/dist/vue-i18n.runtime.node.mjs +60 -10
- package/package.json +4 -4
package/dist/vue-i18n.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* vue-i18n v11.4.
|
|
2
|
+
* vue-i18n v11.4.24
|
|
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.
|
|
33
|
+
const VERSION = '11.4.24';
|
|
34
34
|
|
|
35
35
|
const I18nErrorCodes = {
|
|
36
36
|
// composer module errors
|
|
@@ -235,6 +235,34 @@ function getCurrentInstance() {
|
|
|
235
235
|
return Vue.getCurrentInstance();
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Get the effect scope of a component instance.
|
|
240
|
+
*
|
|
241
|
+
* Every component instance has one, but it is not in the published types of Vue.
|
|
242
|
+
*/
|
|
243
|
+
function getInstanceScope(instance) {
|
|
244
|
+
return instance.scope;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Run `fn` when the effect scope of a component instance stops.
|
|
248
|
+
*
|
|
249
|
+
* Vue stops this scope when it unmounts the component, and also when
|
|
250
|
+
* `<Suspense>` discards a pending branch. In the second case, Vue drops the
|
|
251
|
+
* post-render jobs of the branch, so `onUnmounted` hooks never run.
|
|
252
|
+
*
|
|
253
|
+
* If the scope has already stopped, `fn` runs right away. This happens when
|
|
254
|
+
* `<Suspense>` discards a component while its async `setup()` is waiting,
|
|
255
|
+
* and the `setup()` continues after the `await`.
|
|
256
|
+
*/
|
|
257
|
+
function onInstanceScopeDispose(instance, fn) {
|
|
258
|
+
const scope = getInstanceScope(instance);
|
|
259
|
+
if (scope.active) {
|
|
260
|
+
scope.run(() => Vue.onScopeDispose(fn));
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
fn();
|
|
264
|
+
}
|
|
265
|
+
}
|
|
238
266
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
239
267
|
|
|
240
268
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
@@ -1133,6 +1161,18 @@ function defineMixin(vuei18n, composer, i18n) {
|
|
|
1133
1161
|
this.$n = (...args) => this.$i18n.n(...args);
|
|
1134
1162
|
this.$tm = (key) => this.$i18n.tm(key);
|
|
1135
1163
|
i18n.__setInstance(instance, this.$i18n);
|
|
1164
|
+
// Clean up also when the effect scope of the component stops.
|
|
1165
|
+
// `<Suspense>` stops the scope of a component in a discarded pending
|
|
1166
|
+
// branch, but drops its `unmounted` hooks (#2795).
|
|
1167
|
+
const vueI18n = this.$i18n;
|
|
1168
|
+
onInstanceScopeDispose(instance, () => {
|
|
1169
|
+
if (vueI18n.__disposer) {
|
|
1170
|
+
vueI18n.__disposer();
|
|
1171
|
+
delete vueI18n.__disposer;
|
|
1172
|
+
delete vueI18n.__extender;
|
|
1173
|
+
}
|
|
1174
|
+
i18n.__deleteInstance(instance);
|
|
1175
|
+
});
|
|
1136
1176
|
},
|
|
1137
1177
|
mounted() {
|
|
1138
1178
|
},
|
|
@@ -1482,9 +1522,15 @@ function vTDirective(i18n) {
|
|
|
1482
1522
|
const register = (el, binding) => {
|
|
1483
1523
|
const [textContent, composer] = _process(binding);
|
|
1484
1524
|
if (shared.inBrowser) {
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1525
|
+
// Create the watcher in the effect scope of the component, so that it
|
|
1526
|
+
// also stops when `<Suspense>` discards a pending branch and drops the
|
|
1527
|
+
// `unmounted` hook of this directive (#2795).
|
|
1528
|
+
const scope = getInstanceScope(binding.instance.$);
|
|
1529
|
+
if (scope.active) {
|
|
1530
|
+
el.__i18nWatcher = scope.run(() => Vue.watch(composer.locale, () => {
|
|
1531
|
+
binding.instance && binding.instance.$forceUpdate();
|
|
1532
|
+
}));
|
|
1533
|
+
}
|
|
1488
1534
|
}
|
|
1489
1535
|
el.__composer = composer;
|
|
1490
1536
|
el.textContent = textContent;
|
|
@@ -1733,8 +1779,8 @@ function useI18n(options = {}) {
|
|
|
1733
1779
|
composer[DisposeSymbol] =
|
|
1734
1780
|
i18nInternal.__composerExtend(composer);
|
|
1735
1781
|
}
|
|
1736
|
-
setupLifeCycle(i18nInternal, instance, composer);
|
|
1737
1782
|
i18nInternal.__setInstance(instance, composer);
|
|
1783
|
+
setupLifeCycle(i18nInternal, instance, composer);
|
|
1738
1784
|
}
|
|
1739
1785
|
return composer;
|
|
1740
1786
|
}
|
|
@@ -1823,7 +1869,10 @@ function getParentComponentInstance(target, useComponent = false) {
|
|
|
1823
1869
|
function setupLifeCycle(i18n, target, composer) {
|
|
1824
1870
|
Vue.onMounted(() => {
|
|
1825
1871
|
}, target);
|
|
1826
|
-
|
|
1872
|
+
// Clean up when the effect scope of the component stops, instead of in
|
|
1873
|
+
// `onUnmounted`. `<Suspense>` stops the scope of a component in a discarded
|
|
1874
|
+
// pending branch, but drops its `onUnmounted` hooks (#2795).
|
|
1875
|
+
onInstanceScopeDispose(target, () => {
|
|
1827
1876
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1828
1877
|
const _composer = composer;
|
|
1829
1878
|
i18n.__deleteInstance(target);
|
|
@@ -1833,7 +1882,7 @@ function setupLifeCycle(i18n, target, composer) {
|
|
|
1833
1882
|
dispose();
|
|
1834
1883
|
delete _composer[DisposeSymbol];
|
|
1835
1884
|
}
|
|
1836
|
-
}
|
|
1885
|
+
});
|
|
1837
1886
|
}
|
|
1838
1887
|
const globalExportProps = [
|
|
1839
1888
|
'locale',
|
package/dist/vue-i18n.d.ts
CHANGED
|
@@ -143,7 +143,7 @@ export declare interface Composer<Messages extends Record<string, any> = {}, Dat
|
|
|
143
143
|
* @remarks
|
|
144
144
|
* Whether inherit the root level locale to the component localization locale.
|
|
145
145
|
*
|
|
146
|
-
* @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-
|
|
146
|
+
* @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-1)
|
|
147
147
|
*/
|
|
148
148
|
inheritLocale: boolean;
|
|
149
149
|
/**
|
|
@@ -248,7 +248,7 @@ export declare interface Composer<Messages extends Record<string, any> = {}, Dat
|
|
|
248
248
|
* Locale message translation
|
|
249
249
|
*
|
|
250
250
|
* @remarks
|
|
251
|
-
*
|
|
251
|
+
* For the call forms, the arguments and examples, see {@link ComposerTranslation}
|
|
252
252
|
*/
|
|
253
253
|
t: ComposerTranslation<Messages, Locales, RemoveIndexSignature<{
|
|
254
254
|
[K in keyof DefineLocaleMessage]: DefineLocaleMessage[K];
|
|
@@ -298,7 +298,7 @@ export declare interface Composer<Messages extends Record<string, any> = {}, Dat
|
|
|
298
298
|
* Locale messages getter
|
|
299
299
|
*
|
|
300
300
|
* @remarks
|
|
301
|
-
* If [
|
|
301
|
+
* If [I18nScope](general#i18nscope) `'local'` or Some [UseI18nOptions](composition#usei18noptions) are specified at `useI18n`, it’s translated in preferentially local scope locale messages than global scope locale messages.
|
|
302
302
|
*
|
|
303
303
|
* Based on the current `locale`, locale messages will be returned from Composer instance messages.
|
|
304
304
|
*
|
|
@@ -307,7 +307,7 @@ export declare interface Composer<Messages extends Record<string, any> = {}, Dat
|
|
|
307
307
|
* If there are no locale messages for the given `key` in the composer instance messages, they will be returned with [fallbacking](../guide/essentials/fallback).
|
|
308
308
|
*
|
|
309
309
|
* @VueI18nWarning
|
|
310
|
-
* You need to use `rt` for the locale message returned by `tm`. see the [rt](composition#rt
|
|
310
|
+
* You need to use `rt` for the locale message returned by `tm`. see the [rt](composition#rt) details.
|
|
311
311
|
*
|
|
312
312
|
* @example
|
|
313
313
|
* template block:
|
|
@@ -352,7 +352,7 @@ export declare interface Composer<Messages extends Record<string, any> = {}, Dat
|
|
|
352
352
|
*
|
|
353
353
|
* @param key - A target locale message key
|
|
354
354
|
*
|
|
355
|
-
* @
|
|
355
|
+
* @returns Locale messages
|
|
356
356
|
*/
|
|
357
357
|
tm<Key extends string, ResourceKeys extends PickupKeys<Messages> = PickupKeys<Messages>, Locale extends PickupLocales<NonNullable<Messages>> = PickupLocales<NonNullable<Messages>>, Target = IsEmptyObject<Messages> extends false ? NonNullable<Messages>[Locale] : RemoveIndexSignature<{
|
|
358
358
|
[K in keyof DefineLocaleMessage]: DefineLocaleMessage[K];
|
|
@@ -443,7 +443,7 @@ export declare interface Composer<Messages extends Record<string, any> = {}, Dat
|
|
|
443
443
|
* Get number format
|
|
444
444
|
*
|
|
445
445
|
* @remarks
|
|
446
|
-
* get number format from Composer instance [numberFormats](composition#
|
|
446
|
+
* get number format from Composer instance [numberFormats](composition#numberformats).
|
|
447
447
|
*
|
|
448
448
|
* @param locale - A target locale
|
|
449
449
|
*
|
|
@@ -458,7 +458,7 @@ export declare interface Composer<Messages extends Record<string, any> = {}, Dat
|
|
|
458
458
|
* Set number format
|
|
459
459
|
*
|
|
460
460
|
* @remarks
|
|
461
|
-
* Set number format to Composer instance [numberFormats](composition#
|
|
461
|
+
* Set number format to Composer instance [numberFormats](composition#numberformats).
|
|
462
462
|
*
|
|
463
463
|
* @param locale - A target locale
|
|
464
464
|
* @param format - A target number format
|
|
@@ -472,7 +472,7 @@ export declare interface Composer<Messages extends Record<string, any> = {}, Dat
|
|
|
472
472
|
* Merge number format
|
|
473
473
|
*
|
|
474
474
|
* @remarks
|
|
475
|
-
* Merge number format to Composer instance [numberFormats](composition#
|
|
475
|
+
* Merge number format to Composer instance [numberFormats](composition#numberformats).
|
|
476
476
|
*
|
|
477
477
|
* @param locale - A target locale
|
|
478
478
|
* @param format - A target number format
|
|
@@ -570,7 +570,7 @@ export declare interface ComposerDateTimeFormatting<DateTimeFormats extends Reco
|
|
|
570
570
|
* @remarks
|
|
571
571
|
* If this is used in a reactive context, it will re-evaluate once the locale changes.
|
|
572
572
|
*
|
|
573
|
-
* If [
|
|
573
|
+
* If [I18nScope](general#i18nscope) `'local'` or Some [UseI18nOptions](composition#usei18noptions) are specified at `useI18n`, it’s translated in preferentially local scope datetime formats than global scope datetime formats.
|
|
574
574
|
*
|
|
575
575
|
* If not, then it’s formatted with global scope datetime formats.
|
|
576
576
|
*
|
|
@@ -631,7 +631,7 @@ export declare interface ComposerNumberFormatting<NumberFormats extends Record<s
|
|
|
631
631
|
* @remarks
|
|
632
632
|
* If this is used in a reactive context, it will re-evaluate once the locale changes.
|
|
633
633
|
*
|
|
634
|
-
* If [
|
|
634
|
+
* If [I18nScope](general#i18nscope) `'local'` or Some [UseI18nOptions](composition#usei18noptions) are specified at `useI18n`, it’s translated in preferentially local scope datetime formats than global scope datetime formats.
|
|
635
635
|
*
|
|
636
636
|
* If not, then it’s formatted with global scope number formats.
|
|
637
637
|
*
|
|
@@ -734,7 +734,7 @@ export declare interface ComposerOptions<Schema extends {
|
|
|
734
734
|
*
|
|
735
735
|
* If `false`, regardless of the root level locale, localize for each component locale.
|
|
736
736
|
*
|
|
737
|
-
* @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-
|
|
737
|
+
* @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-1)
|
|
738
738
|
*
|
|
739
739
|
* @defaultValue `true`
|
|
740
740
|
*/
|
|
@@ -919,11 +919,11 @@ export declare interface ComposerOptions<Schema extends {
|
|
|
919
919
|
*
|
|
920
920
|
* - If the message could not be resolved, you need to return `null`.
|
|
921
921
|
*
|
|
922
|
-
* - If you will be returned `null`, the message resolver will also be called on fallback if [`fallbackLocale`](composition#fallbacklocale-
|
|
922
|
+
* - If you will be returned `null`, the message resolver will also be called on fallback if [`fallbackLocale`](composition#fallbacklocale-1) is enabled, so the message will need to be resolved as well.
|
|
923
923
|
*
|
|
924
924
|
* The message resolver is called indirectly by the following APIs:
|
|
925
925
|
*
|
|
926
|
-
* - [`t`](composition#t
|
|
926
|
+
* - [`t`](composition#t)
|
|
927
927
|
*
|
|
928
928
|
* - [`te`](composition#te-key-locale)
|
|
929
929
|
*
|
|
@@ -1048,7 +1048,7 @@ export declare interface ComposerResolveLocaleMessageTranslation<Locales = 'en-U
|
|
|
1048
1048
|
* @remarks
|
|
1049
1049
|
* If this is used in a reactive context, it will re-evaluate once the locale changes.
|
|
1050
1050
|
*
|
|
1051
|
-
* If [
|
|
1051
|
+
* If [I18nScope](general#i18nscope) `'local'` or Some [UseI18nOptions](composition#usei18noptions) are specified at `useI18n`, it’s translated in preferentially local scope locale messages than global scope locale messages.
|
|
1052
1052
|
*
|
|
1053
1053
|
* If not, then it’s translated with global scope locale messages.
|
|
1054
1054
|
*
|
|
@@ -1069,7 +1069,7 @@ export declare interface ComposerResolveLocaleMessageTranslation<Locales = 'en-U
|
|
|
1069
1069
|
* Resolve locale message translation for plurals
|
|
1070
1070
|
*
|
|
1071
1071
|
* @remarks
|
|
1072
|
-
* Overloaded `rt`. About details, see the [call signature](composition#message-messagefunction-
|
|
1072
|
+
* Overloaded `rt`. About details, see the [call signature](composition#message-messagefunction-lt-vuemessagetype-gt-vuemessagetype-string) details.
|
|
1073
1073
|
*
|
|
1074
1074
|
* In this overloaded `rt`, return a pluralized translation message.
|
|
1075
1075
|
*
|
|
@@ -1080,7 +1080,7 @@ export declare interface ComposerResolveLocaleMessageTranslation<Locales = 'en-U
|
|
|
1080
1080
|
* `rt` differs from `t` in that it processes the locale message directly, not the key of the locale message. There is no internal fallback with `rt`. You need to understand and use the structure of the locale messge returned by `tm`.
|
|
1081
1081
|
*
|
|
1082
1082
|
* @param message - A target locale message to be resolved. You will need to specify the locale message returned by `tm`.
|
|
1083
|
-
* @param plural -
|
|
1083
|
+
* @param plural - The number used to choose the plural form, not the position of the form.
|
|
1084
1084
|
* @param options - Additional {@link TranslateOptions | options} for translation
|
|
1085
1085
|
*
|
|
1086
1086
|
* @returns Translated message
|
|
@@ -1092,7 +1092,7 @@ export declare interface ComposerResolveLocaleMessageTranslation<Locales = 'en-U
|
|
|
1092
1092
|
* Resolve locale message translation for list interpolations
|
|
1093
1093
|
*
|
|
1094
1094
|
* @remarks
|
|
1095
|
-
* Overloaded `rt`. About details, see the [call signature](composition#message-messagefunction-
|
|
1095
|
+
* Overloaded `rt`. About details, see the [call signature](composition#message-messagefunction-lt-vuemessagetype-gt-vuemessagetype-string) details.
|
|
1096
1096
|
*
|
|
1097
1097
|
* In this overloaded `rt`, return a pluralized translation message.
|
|
1098
1098
|
*
|
|
@@ -1115,7 +1115,7 @@ export declare interface ComposerResolveLocaleMessageTranslation<Locales = 'en-U
|
|
|
1115
1115
|
* Resolve locale message translation for named interpolations
|
|
1116
1116
|
*
|
|
1117
1117
|
* @remarks
|
|
1118
|
-
* Overloaded `rt`. About details, see the [call signature](composition#message-messagefunction-
|
|
1118
|
+
* Overloaded `rt`. About details, see the [call signature](composition#message-messagefunction-lt-vuemessagetype-gt-vuemessagetype-string) details.
|
|
1119
1119
|
*
|
|
1120
1120
|
* In this overloaded `rt`, for each placeholder x, the locale messages should contain a `{x}` token.
|
|
1121
1121
|
*
|
|
@@ -1139,6 +1139,46 @@ export declare interface ComposerResolveLocaleMessageTranslation<Locales = 'en-U
|
|
|
1139
1139
|
/**
|
|
1140
1140
|
* Locale message translation functions
|
|
1141
1141
|
*
|
|
1142
|
+
* The first argument is the key of a locale message. The type of the second argument decides how it is used, and a third argument can follow it.
|
|
1143
|
+
*
|
|
1144
|
+
* ```ts
|
|
1145
|
+
* t(key)
|
|
1146
|
+
* t(key, named) // object: values for named interpolation, such as {name}
|
|
1147
|
+
* t(key, list) // array: values for list interpolation, such as {0}
|
|
1148
|
+
* t(key, plural) // number: used to choose the plural form
|
|
1149
|
+
* t(key, defaultMsg) // string: returned if no translation is found
|
|
1150
|
+
*
|
|
1151
|
+
* // with a third argument
|
|
1152
|
+
* t(key, named, plural | defaultMsg | options)
|
|
1153
|
+
* t(key, list, plural | defaultMsg | options)
|
|
1154
|
+
* t(key, plural, options)
|
|
1155
|
+
* t(key, defaultMsg, options)
|
|
1156
|
+
* ```
|
|
1157
|
+
*
|
|
1158
|
+
* `options` is {@link TranslateOptions}.
|
|
1159
|
+
*
|
|
1160
|
+
* ```ts
|
|
1161
|
+
* const { t } = useI18n({
|
|
1162
|
+
* locale: 'en',
|
|
1163
|
+
* messages: {
|
|
1164
|
+
* en: {
|
|
1165
|
+
* hello: 'Hello, {name}!',
|
|
1166
|
+
* welcome: 'Welcome, {0}!',
|
|
1167
|
+
* apple: 'no apples | one apple | {count} apples'
|
|
1168
|
+
* },
|
|
1169
|
+
* fr: { hello: 'Bonjour, {name} !' }
|
|
1170
|
+
* }
|
|
1171
|
+
* })
|
|
1172
|
+
*
|
|
1173
|
+
* t('hello', { name: 'Vue' }) // 'Hello, Vue!'
|
|
1174
|
+
* t('welcome', ['Vue']) // 'Welcome, Vue!'
|
|
1175
|
+
* t('apple', 1) // 'one apple'
|
|
1176
|
+
* t('apple', 5) // '5 apples'
|
|
1177
|
+
* t('apple', { count: 'many' }, 5) // 'many apples'
|
|
1178
|
+
* t('missing', 'Not found') // 'Not found'
|
|
1179
|
+
* t('hello', { name: 'Vue' }, { locale: 'fr' }) // 'Bonjour, Vue !'
|
|
1180
|
+
* ```
|
|
1181
|
+
*
|
|
1142
1182
|
* @remarks
|
|
1143
1183
|
* This is the interface for {@link Composer}
|
|
1144
1184
|
*
|
|
@@ -1153,7 +1193,7 @@ export declare interface ComposerTranslation<Messages extends Record<string, any
|
|
|
1153
1193
|
* @remarks
|
|
1154
1194
|
* If this is used in a reactive context, it will re-evaluate once the locale changes.
|
|
1155
1195
|
*
|
|
1156
|
-
* If [
|
|
1196
|
+
* If [I18nScope](general#i18nscope) `'local'` or Some [UseI18nOptions](composition#usei18noptions) are specified at `useI18n`, it’s translated in preferentially local scope locale messages than global scope locale messages.
|
|
1157
1197
|
*
|
|
1158
1198
|
* If not, then it’s translated with global scope locale messages.
|
|
1159
1199
|
*
|
|
@@ -1175,7 +1215,7 @@ export declare interface ComposerTranslation<Messages extends Record<string, any
|
|
|
1175
1215
|
* You can also suppress the warning, when the translation missing according to the options.
|
|
1176
1216
|
*
|
|
1177
1217
|
* @param key - A target locale message key
|
|
1178
|
-
* @param plural -
|
|
1218
|
+
* @param plural - The number used to choose the plural form, not the position of the form.
|
|
1179
1219
|
*
|
|
1180
1220
|
* @returns Translated message
|
|
1181
1221
|
*
|
|
@@ -1195,7 +1235,7 @@ export declare interface ComposerTranslation<Messages extends Record<string, any
|
|
|
1195
1235
|
* About details of options, see the {@link TranslateOptions}.
|
|
1196
1236
|
*
|
|
1197
1237
|
* @param key - A target locale message key
|
|
1198
|
-
* @param plural -
|
|
1238
|
+
* @param plural - The number used to choose the plural form, not the position of the form.
|
|
1199
1239
|
* @param options - Additional {@link TranslateOptions | options} for translation
|
|
1200
1240
|
*
|
|
1201
1241
|
* @returns Translated message
|
|
@@ -1266,7 +1306,7 @@ export declare interface ComposerTranslation<Messages extends Record<string, any
|
|
|
1266
1306
|
*
|
|
1267
1307
|
* @param key - A target locale message key
|
|
1268
1308
|
* @param list - A values of list interpolation
|
|
1269
|
-
* @param plural -
|
|
1309
|
+
* @param plural - The number used to choose the plural form, not the position of the form.
|
|
1270
1310
|
*
|
|
1271
1311
|
* @returns Translated message
|
|
1272
1312
|
*
|
|
@@ -1340,7 +1380,7 @@ export declare interface ComposerTranslation<Messages extends Record<string, any
|
|
|
1340
1380
|
*
|
|
1341
1381
|
* @param key - A target locale message key
|
|
1342
1382
|
* @param named - A values of named interpolation
|
|
1343
|
-
* @param plural -
|
|
1383
|
+
* @param plural - The number used to choose the plural form, not the position of the form.
|
|
1344
1384
|
*
|
|
1345
1385
|
* @returns Translated message
|
|
1346
1386
|
*
|
|
@@ -1349,7 +1389,7 @@ export declare interface ComposerTranslation<Messages extends Record<string, any
|
|
|
1349
1389
|
*/
|
|
1350
1390
|
<Key extends string>(key: Key | ResourceKeys | number, named: NamedValue, plural: number): string;
|
|
1351
1391
|
/**
|
|
1352
|
-
* Locale message translation for named interpolations and
|
|
1392
|
+
* Locale message translation for named interpolations and missing default message
|
|
1353
1393
|
*
|
|
1354
1394
|
* @remarks
|
|
1355
1395
|
* Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details.
|
|
@@ -2262,7 +2302,7 @@ export declare interface VueI18n<Messages extends Record<string, any> = {}, Date
|
|
|
2262
2302
|
* @remarks
|
|
2263
2303
|
* Whether synchronize the root level locale to the component localization locale.
|
|
2264
2304
|
*
|
|
2265
|
-
* @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-
|
|
2305
|
+
* @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-1)
|
|
2266
2306
|
*/
|
|
2267
2307
|
sync: Composition['inheritLocale'];
|
|
2268
2308
|
/**
|
|
@@ -2296,7 +2336,7 @@ export declare interface VueI18n<Messages extends Record<string, any> = {}, Date
|
|
|
2296
2336
|
* Locale message translation
|
|
2297
2337
|
*
|
|
2298
2338
|
* @remarks
|
|
2299
|
-
*
|
|
2339
|
+
* For the call forms, the arguments and examples, see {@link VueI18nTranslation}
|
|
2300
2340
|
*/
|
|
2301
2341
|
t: VueI18nTranslation<Messages, Locales, RemoveIndexSignature<{
|
|
2302
2342
|
[K in keyof DefineLocaleMessage]: DefineLocaleMessage[K];
|
|
@@ -2339,7 +2379,7 @@ export declare interface VueI18n<Messages extends Record<string, any> = {}, Date
|
|
|
2339
2379
|
* If there are no locale messages for the given `key` in the composer instance messages, they will be returned with [fallbacking](../guide/essentials/fallback).
|
|
2340
2380
|
*
|
|
2341
2381
|
* @VueI18nWarning
|
|
2342
|
-
* You need to use `rt` for the locale message returned by `tm`. see the [rt](legacy#rt
|
|
2382
|
+
* You need to use `rt` for the locale message returned by `tm`. see the [rt](legacy#rt) details.
|
|
2343
2383
|
*
|
|
2344
2384
|
* @example
|
|
2345
2385
|
* template:
|
|
@@ -2376,7 +2416,7 @@ export declare interface VueI18n<Messages extends Record<string, any> = {}, Date
|
|
|
2376
2416
|
* ```
|
|
2377
2417
|
* @param key - A target locale message key
|
|
2378
2418
|
*
|
|
2379
|
-
* @
|
|
2419
|
+
* @returns Locale messages
|
|
2380
2420
|
*/
|
|
2381
2421
|
tm: Composition['tm'];
|
|
2382
2422
|
/**
|
|
@@ -2463,7 +2503,7 @@ export declare interface VueI18n<Messages extends Record<string, any> = {}, Date
|
|
|
2463
2503
|
* Get number format
|
|
2464
2504
|
*
|
|
2465
2505
|
* @remarks
|
|
2466
|
-
* get number format from VueI18n instance [numberFormats](legacy#
|
|
2506
|
+
* get number format from VueI18n instance [numberFormats](legacy#numberformats).
|
|
2467
2507
|
*
|
|
2468
2508
|
* @param locale - A target locale
|
|
2469
2509
|
*
|
|
@@ -2474,7 +2514,7 @@ export declare interface VueI18n<Messages extends Record<string, any> = {}, Date
|
|
|
2474
2514
|
* Set number format
|
|
2475
2515
|
*
|
|
2476
2516
|
* @remarks
|
|
2477
|
-
* Set number format to VueI18n instance [numberFormats](legacy#
|
|
2517
|
+
* Set number format to VueI18n instance [numberFormats](legacy#numberformats).
|
|
2478
2518
|
*
|
|
2479
2519
|
* @param locale - A target locale
|
|
2480
2520
|
* @param format - A target number format
|
|
@@ -2484,7 +2524,7 @@ export declare interface VueI18n<Messages extends Record<string, any> = {}, Date
|
|
|
2484
2524
|
* Merge number format
|
|
2485
2525
|
*
|
|
2486
2526
|
* @remarks
|
|
2487
|
-
* Merge number format to VueI18n instance [numberFormats](legacy#
|
|
2527
|
+
* Merge number format to VueI18n instance [numberFormats](legacy#numberformats).
|
|
2488
2528
|
*
|
|
2489
2529
|
* @param locale - A target locale
|
|
2490
2530
|
* @param format - A target number format
|
|
@@ -2867,7 +2907,7 @@ export declare interface VueI18nOptions<Schema extends {
|
|
|
2867
2907
|
*
|
|
2868
2908
|
* If `false`, regardless of the root level locale, localize for each component locale.
|
|
2869
2909
|
*
|
|
2870
|
-
* @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-
|
|
2910
|
+
* @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-1)
|
|
2871
2911
|
*
|
|
2872
2912
|
* @defaultValue `true`
|
|
2873
2913
|
*/
|
|
@@ -2884,15 +2924,15 @@ export declare interface VueI18nOptions<Schema extends {
|
|
|
2884
2924
|
*
|
|
2885
2925
|
* - If the message could not be resolved, you need to return `null`.
|
|
2886
2926
|
*
|
|
2887
|
-
* - If you will be returned `null`, the message resolver will also be called on fallback if [`fallbackLocale`](legacy#fallbacklocale-
|
|
2927
|
+
* - If you will be returned `null`, the message resolver will also be called on fallback if [`fallbackLocale`](legacy#fallbacklocale-1) is enabled, so the message will need to be resolved as well.
|
|
2888
2928
|
*
|
|
2889
2929
|
* The message resolver is called indirectly by the following APIs:
|
|
2890
2930
|
*
|
|
2891
|
-
* - [`t`](legacy#t
|
|
2931
|
+
* - [`t`](legacy#t)
|
|
2892
2932
|
*
|
|
2893
2933
|
* - [`te`](legacy#te-key-locale)
|
|
2894
2934
|
*
|
|
2895
|
-
* - [`tm`](legacy#tm
|
|
2935
|
+
* - [`tm`](legacy#tm)
|
|
2896
2936
|
*
|
|
2897
2937
|
* - [Translation component](component#translation)
|
|
2898
2938
|
*
|
|
@@ -2950,6 +2990,47 @@ export declare type VueI18nResolveLocaleMessageTranslation<Locales = 'en-US'> =
|
|
|
2950
2990
|
/**
|
|
2951
2991
|
* Locale message translation functions for VueI18n legacy interfaces
|
|
2952
2992
|
*
|
|
2993
|
+
* The first argument is the key of a locale message. The type of the second argument decides how it is used, and a third argument can follow it.
|
|
2994
|
+
*
|
|
2995
|
+
* ```ts
|
|
2996
|
+
* t(key)
|
|
2997
|
+
* t(key, named) // object: values for named interpolation, such as {name}
|
|
2998
|
+
* t(key, list) // array: values for list interpolation, such as {0}
|
|
2999
|
+
* t(key, plural) // number: used to choose the plural form
|
|
3000
|
+
* t(key, defaultMsg) // string: returned if no translation is found
|
|
3001
|
+
*
|
|
3002
|
+
* // with a third argument
|
|
3003
|
+
* t(key, named, plural | defaultMsg | options)
|
|
3004
|
+
* t(key, list, plural | defaultMsg | options)
|
|
3005
|
+
* t(key, plural, options)
|
|
3006
|
+
* t(key, defaultMsg, options)
|
|
3007
|
+
* ```
|
|
3008
|
+
*
|
|
3009
|
+
* `options` is {@link TranslateOptions}.
|
|
3010
|
+
*
|
|
3011
|
+
* ```ts
|
|
3012
|
+
* const i18n = createI18n({
|
|
3013
|
+
* locale: 'en',
|
|
3014
|
+
* messages: {
|
|
3015
|
+
* en: {
|
|
3016
|
+
* hello: 'Hello, {name}!',
|
|
3017
|
+
* welcome: 'Welcome, {0}!',
|
|
3018
|
+
* apple: 'no apples | one apple | {count} apples'
|
|
3019
|
+
* },
|
|
3020
|
+
* fr: { hello: 'Bonjour, {name} !' }
|
|
3021
|
+
* }
|
|
3022
|
+
* })
|
|
3023
|
+
* const { t } = i18n.global
|
|
3024
|
+
*
|
|
3025
|
+
* t('hello', { name: 'Vue' }) // 'Hello, Vue!'
|
|
3026
|
+
* t('welcome', ['Vue']) // 'Welcome, Vue!'
|
|
3027
|
+
* t('apple', 1) // 'one apple'
|
|
3028
|
+
* t('apple', 5) // '5 apples'
|
|
3029
|
+
* t('apple', { count: 'many' }, 5) // 'many apples'
|
|
3030
|
+
* t('missing', 'Not found') // 'Not found'
|
|
3031
|
+
* t('hello', { name: 'Vue' }, { locale: 'fr' }) // 'Bonjour, Vue !'
|
|
3032
|
+
* ```
|
|
3033
|
+
*
|
|
2953
3034
|
* @remarks
|
|
2954
3035
|
* This is the interface for {@link VueI18n}
|
|
2955
3036
|
*
|
|
@@ -2988,7 +3069,7 @@ export declare interface VueI18nTranslation<Messages extends Record<string, any>
|
|
|
2988
3069
|
* You can also suppress the warning, when the translation missing according to the options.
|
|
2989
3070
|
*
|
|
2990
3071
|
* @param key - A target locale message key
|
|
2991
|
-
* @param plural -
|
|
3072
|
+
* @param plural - The number used to choose the plural form, not the position of the form.
|
|
2992
3073
|
*
|
|
2993
3074
|
* @returns Translated message
|
|
2994
3075
|
*
|
|
@@ -3008,7 +3089,7 @@ export declare interface VueI18nTranslation<Messages extends Record<string, any>
|
|
|
3008
3089
|
* About details of options, see the {@link TranslateOptions}.
|
|
3009
3090
|
*
|
|
3010
3091
|
* @param key - A target locale message key
|
|
3011
|
-
* @param plural -
|
|
3092
|
+
* @param plural - The number used to choose the plural form, not the position of the form.
|
|
3012
3093
|
* @param options - Additional {@link TranslateOptions | options} for translation
|
|
3013
3094
|
*
|
|
3014
3095
|
* @returns Translated message
|
|
@@ -3075,7 +3156,7 @@ export declare interface VueI18nTranslation<Messages extends Record<string, any>
|
|
|
3075
3156
|
*
|
|
3076
3157
|
* @param key - A target locale message key
|
|
3077
3158
|
* @param list - A values of list interpolation
|
|
3078
|
-
* @param plural -
|
|
3159
|
+
* @param plural - The number used to choose the plural form, not the position of the form.
|
|
3079
3160
|
*
|
|
3080
3161
|
* @returns Translated message
|
|
3081
3162
|
*
|
|
@@ -3145,7 +3226,7 @@ export declare interface VueI18nTranslation<Messages extends Record<string, any>
|
|
|
3145
3226
|
*
|
|
3146
3227
|
* @param key - A target locale message key
|
|
3147
3228
|
* @param named - A values of named interpolation
|
|
3148
|
-
* @param plural -
|
|
3229
|
+
* @param plural - The number used to choose the plural form, not the position of the form.
|
|
3149
3230
|
*
|
|
3150
3231
|
* @returns Translated message
|
|
3151
3232
|
*
|
|
@@ -3154,7 +3235,7 @@ export declare interface VueI18nTranslation<Messages extends Record<string, any>
|
|
|
3154
3235
|
*/
|
|
3155
3236
|
<Key extends string>(key: Key | ResourceKeys, named: NamedValue, plural: number): TranslateResult;
|
|
3156
3237
|
/**
|
|
3157
|
-
* Locale message translation for named interpolations and
|
|
3238
|
+
* Locale message translation for named interpolations and missing default message
|
|
3158
3239
|
*
|
|
3159
3240
|
* @remarks
|
|
3160
3241
|
* Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details.
|
|
@@ -3306,7 +3387,7 @@ declare module 'vue' {
|
|
|
3306
3387
|
* Overloaded `$t`. About details, see the {@link $t} remarks.
|
|
3307
3388
|
*
|
|
3308
3389
|
* @param key - A target locale message key
|
|
3309
|
-
* @param plural -
|
|
3390
|
+
* @param plural - The number used to choose the plural form, not the position of the form.
|
|
3310
3391
|
* @param options - An options, see the {@link TranslateOptions}
|
|
3311
3392
|
*
|
|
3312
3393
|
* @returns translation message
|
|
@@ -3613,7 +3694,7 @@ declare module 'vue' {
|
|
|
3613
3694
|
* Overloaded `$rt`. About details, see the {@link $rt} remarks.
|
|
3614
3695
|
*
|
|
3615
3696
|
* @param message - A target locale message to be resolved. You will need to specify the locale message returned by `$tm`.
|
|
3616
|
-
* @param plural -
|
|
3697
|
+
* @param plural - The number used to choose the plural form, not the position of the form.
|
|
3617
3698
|
* @param options - Additional {@link TranslateOptions | options} for translation
|
|
3618
3699
|
*
|
|
3619
3700
|
* @returns Translated message
|