vue-i18n / general / ComposerTranslation
Interface: ComposerTranslation()<Messages, Locales, DefinedLocaleMessage, C, M, ResourceKeys>
Vue I18n Composition
Locale message translation functions
Remarks
This is the interface for Composer
Type Parameters
| Type Parameter | Default type |
|---|---|
Messages extends Record<string, any> | object |
Locales | "en-US" |
DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> | RemovedIndexResources<DefineLocaleMessage> |
C | IsEmptyObject<DefinedLocaleMessage> extends false ? JsonPaths<{ [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] }> : never |
M | IsEmptyObject<Messages> extends false ? TranslationsPaths<Messages> : never |
ResourceKeys extends C | M | IsNever<C> extends false ? IsNever<M> extends false ? C | M : C : IsNever<M> extends false ? M : never |
Call Signature
ComposerTranslation<Key>(key): string;Locale message translation
Type Parameters
| Type Parameter |
|---|
Key extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | number | ResourceKeys | Key | A target locale message key |
Returns
string
Translated message
Remarks
If this is used in a reactive context, it will re-evaluate once the locale changes.
If I18nScope 'local' or Some UseI18nOptions are specified at useI18n, it’s translated in preferentially local scope locale messages than global scope locale messages.
If not, then it’s translated with global scope locale messages.
See about:
Call Signature
ComposerTranslation<Key>(key, plural): string;Locale message translation for plurals
Type Parameters
| Type Parameter |
|---|
Key extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | number | ResourceKeys | Key | A target locale message key |
plural | number | Which plural string to get. 1 returns the first one. |
Returns
string
Translated message
Remarks
Overloaded t.
In this overloaded t, return a pluralized translation message.
You can also suppress the warning, when the translation missing according to the options.
See about:
Call Signature
ComposerTranslation<Key>(
key,
plural,
options): string;Locale message translation for plurals
Type Parameters
| Type Parameter |
|---|
Key extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | number | ResourceKeys | Key | A target locale message key |
plural | number | Which plural string to get. 1 returns the first one. |
options | TranslateOptions<Locales> | Additional options for translation |
Returns
string
Translated message
Remarks
Overloaded t.
In this overloaded t, return a pluralized translation message.
You can also suppress the warning, when the translation missing according to the options.
About details of options, see the TranslateOptions.
See about:
Call Signature
ComposerTranslation<Key>(key, defaultMsg): string;Locale message translation for missing default message
Type Parameters
| Type Parameter |
|---|
Key extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | number | ResourceKeys | Key | A target locale message key |
defaultMsg | string | A default message to return if no translation was found |
Returns
string
Translated message
Remarks
Overloaded t.
In this overloaded t, if no translation was found, return a default message.
You can also suppress the warning, when the translation missing according to the options.
Call Signature
ComposerTranslation<Key>(
key,
defaultMsg,
options): string;Locale message translation for missing default message
Type Parameters
| Type Parameter |
|---|
Key extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | number | ResourceKeys | Key | A target locale message key |
defaultMsg | string | A default message to return if no translation was found |
options | TranslateOptions<Locales> | Additional options for translation |
Returns
string
Translated message
Remarks
Overloaded t.
In this overloaded t, if no translation was found, return a default message.
You can also suppress the warning, when the translation missing according to the options.
About details of options, see the TranslateOptions.
Call Signature
ComposerTranslation<Key>(key, list): string;Locale message translation for list interpolations
Type Parameters
| Type Parameter |
|---|
Key extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | number | ResourceKeys | Key | A target locale message key |
list | unknown[] | A values of list interpolation |
Returns
string
Translated message
Remarks
Overloaded t.
In this overloaded t, the locale messages should contain a {0}, {1}, … for each placeholder in the list.
You can also suppress the warning, when the translation missing according to the options.
See about:
Call Signature
ComposerTranslation<Key>(
key,
list,
plural): string;Locale message translation for list interpolations and plurals
Type Parameters
| Type Parameter |
|---|
Key extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | number | ResourceKeys | Key | A target locale message key |
list | unknown[] | A values of list interpolation |
plural | number | Which plural string to get. 1 returns the first one. |
Returns
string
Translated message
Remarks
Overloaded t.
In this overloaded t, the locale messages should contain a {0}, {1}, … for each placeholder in the list, and return a pluralized translation message.
See about:
Call Signature
ComposerTranslation<Key>(
key,
list,
defaultMsg): string;Locale message translation for list interpolations and missing default message
Type Parameters
| Type Parameter |
|---|
Key extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | number | ResourceKeys | Key | A target locale message key |
list | unknown[] | A values of list interpolation |
defaultMsg | string | A default message to return if no translation was found |
Returns
string
Translated message
Remarks
Overloaded t.
See about:
In this overloaded t, the locale messages should contain a {0}, {1}, … for each placeholder in the list, and if no translation was found, return a default message.
Call Signature
ComposerTranslation<Key>(
key,
list,
options): string;Locale message translation for list interpolations
Type Parameters
| Type Parameter |
|---|
Key extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | number | ResourceKeys | Key | A target locale message key |
list | unknown[] | A values of list interpolation |
options | TranslateOptions<Locales> | Additional options for translation |
Returns
string
Translated message
Remarks
Overloaded t.
In this overloaded t, the locale messages should contain a {0}, {1}, … for each placeholder in the list.
You can also suppress the warning, when the translation missing according to the options.
About details of options, see the TranslateOptions.
How to usage for details:
Call Signature
ComposerTranslation<Key>(key, named): string;Locale message translation for named interpolations
Type Parameters
| Type Parameter |
|---|
Key extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | number | ResourceKeys | Key | A target locale message key |
named | NamedValue | A values of named interpolation |
Returns
string
Translated message
Remarks
Overloaded t.
In this overloaded t, for each placeholder x, the locale messages should contain a {x} token.
You can also suppress the warning, when the translation missing according to the options.
See about:
Call Signature
ComposerTranslation<Key>(
key,
named,
plural): string;Locale message translation for named interpolations and plurals
Type Parameters
| Type Parameter |
|---|
Key extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | number | ResourceKeys | Key | A target locale message key |
named | NamedValue | A values of named interpolation |
plural | number | Which plural string to get. 1 returns the first one. |
Returns
string
Translated message
Remarks
Overloaded t.
In this overloaded t, for each placeholder x, the locale messages should contain a {x} token, and return a pluralized translation message.
See about:
Call Signature
ComposerTranslation<Key>(
key,
named,
defaultMsg): string;Locale message translation for named interpolations and plurals
Type Parameters
| Type Parameter |
|---|
Key extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | number | ResourceKeys | Key | A target locale message key |
named | NamedValue | A values of named interpolation |
defaultMsg | string | A default message to return if no translation was found |
Returns
string
Translated message
Remarks
Overloaded t.
In this overloaded t, for each placeholder x, the locale messages should contain a {x} token, and if no translation was found, return a default message.
See about:
Call Signature
ComposerTranslation<Key>(
key,
named,
options): string;Locale message translation for named interpolations
Type Parameters
| Type Parameter |
|---|
Key extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
key | number | ResourceKeys | Key | A target locale message key |
named | NamedValue | A values of named interpolation |
options | TranslateOptions<Locales> | Additional options for translation |
Returns
string
Translated message
Remarks
Overloaded t.
In this overloaded t, for each placeholder x, the locale messages should contain a {x} token.
You can also suppress the warning, when the translation missing according to the options.
About details of options, see the TranslateOptions.
How to usage for details: