vue-i18n / general / ComposerTranslation
接口: ComposerTranslation()<Messages, Locales, DefinedLocaleMessage, C, M, ResourceKeys>
本地化消息翻译函数
备注
这是 Composer 的接口
Vue I18n 组合式 API
类型参数
| 类型参数 | 默认类型 |
|---|---|
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 |
调用签名
ComposerTranslation<Key>(key): string;本地化消息翻译
类型参数
| 类型参数 |
|---|
Key extends string |
参数
| 参数 | 类型 | 描述 |
|---|---|---|
key | number | ResourceKeys | Key | 目标本地化消息键 |
返回值
string
已翻译的消息
备注
如果在响应式上下文中使用,当语言环境更改时将重新评估。
如果在 useI18n 中指定了 I18nScope 'local' 或某些 UseI18nOptions,则优先在本地作用域本地化消息中进行翻译,而不是全局作用域本地化消息。
否则,将在全局作用域本地化消息中进行翻译。
参见:
调用签名
ComposerTranslation<Key>(key, plural): string;复数形式的本地化消息翻译
类型参数
| 类型参数 |
|---|
Key extends string |
参数
| 参数 | 类型 | 描述 |
|---|---|---|
key | number | ResourceKeys | Key | 目标本地化消息键 |
plural | number | 获取哪个复数字符串。1 返回第一个。 |
返回值
string
已翻译的消息
备注
重载的 t。
在此重载的 t 中,返回一个复数化的翻译消息。
您也可以根据选项抑制缺少翻译时的警告。
参见:
调用签名
ComposerTranslation<Key>(
key,
plural,
options): string;复数形式的本地化消息翻译
类型参数
| 类型参数 |
|---|
Key extends string |
参数
| 参数 | 类型 | 描述 |
|---|---|---|
key | number | ResourceKeys | Key | 目标本地化消息键 |
plural | number | 获取哪个复数字符串。1 返回第一个。 |
options | TranslateOptions<Locales> | 翻译的附加 选项 |
返回值
string
已翻译的消息
备注
重载的 t。
在此重载的 t 中,返回一个复数化的翻译消息。
您也可以根据选项抑制缺少翻译时的警告。
有关选项的详细信息,请参阅 TranslateOptions。
参见:
调用签名
ComposerTranslation<Key>(key, defaultMsg): string;缺少默认消息时的本地化消息翻译
类型参数
| 类型参数 |
|---|
Key extends string |
参数
| 参数 | 类型 | 描述 |
|---|---|---|
key | number | ResourceKeys | Key | 目标本地化消息键 |
defaultMsg | string | 如果未找到翻译,则返回的默认消息 |
返回值
string
已翻译的消息
备注
重载的 t。
在此重载的 t 中,如果没有找到翻译,则返回默认消息。
您也可以根据选项抑制缺少翻译时的警告。
调用签名
ComposerTranslation<Key>(
key,
defaultMsg,
options): string;缺少默认消息时的本地化消息翻译
类型参数
| 类型参数 |
|---|
Key extends string |
参数
| 参数 | 类型 | 描述 |
|---|---|---|
key | number | ResourceKeys | Key | 目标本地化消息键 |
defaultMsg | string | 如果未找到翻译,则返回的默认消息 |
options | TranslateOptions<Locales> | 翻译的附加 选项 |
返回值
string
已翻译的消息
备注
重载的 t。
在此重载的 t 中,如果没有找到翻译,则返回默认消息。
您也可以根据选项抑制缺少翻译时的警告。
有关选项的详细信息,请参阅 TranslateOptions。
调用签名
ComposerTranslation<Key>(key, list): string;列表插值的本地化消息翻译
类型参数
| 类型参数 |
|---|
Key extends string |
参数
| 参数 | 类型 | 描述 |
|---|---|---|
key | number | ResourceKeys | Key | 目标本地化消息键 |
list | unknown[] | 列表插值的值 |
返回值
string
已翻译的消息
备注
重载的 t。
在此重载的 t 中,本地化消息应包含 {0}、{1} 等每个列表中的占位符。
您也可以根据选项抑制缺少翻译时的警告。
参见:
调用签名
ComposerTranslation<Key>(
key,
list,
plural): string;列表插值和复数的本地化消息翻译
类型参数
| 类型参数 |
|---|
Key extends string |
参数
| 参数 | 类型 | 描述 |
|---|---|---|
key | number | ResourceKeys | Key | 目标本地化消息键 |
list | unknown[] | 列表插值的值 |
plural | number | 获取哪个复数字符串。1 返回第一个。 |
返回值
string
已翻译的消息
备注
重载的 t。
在此重载的 t 中,本地化消息应包含 {0}、{1} 等每个列表中的占位符,并返回一个复数化的翻译消息。
参见:
调用签名
ComposerTranslation<Key>(
key,
list,
defaultMsg): string;列表插值和缺少默认消息时的本地化消息翻译
类型参数
| 类型参数 |
|---|
Key extends string |
参数
| 参数 | 类型 | 描述 |
|---|---|---|
key | number | ResourceKeys | Key | 目标本地化消息键 |
list | unknown[] | 列表插值的值 |
defaultMsg | string | 如果未找到翻译,则返回的默认消息 |
返回值
string
已翻译的消息
备注
重载的 t。
参见:
在此重载的 t 中,本地化消息应包含 {0}、{1} 等每个列表中的占位符,并且如果没有找到翻译,则返回默认消息。
调用签名
ComposerTranslation<Key>(
key,
list,
options): string;列表插值的本地化消息翻译
类型参数
| 类型参数 |
|---|
Key extends string |
参数
| 参数 | 类型 | 描述 |
|---|---|---|
key | number | ResourceKeys | Key | 目标本地化消息键 |
list | unknown[] | 列表插值的值 |
options | TranslateOptions<Locales> | 翻译的附加 选项 |
返回值
string
已翻译的消息
备注
重载的 t。
在此重载的 t 中,本地化消息应包含 {0}、{1} 等每个列表中的占位符。
您也可以根据选项抑制缺少翻译时的警告。
有关选项的详细信息,请参阅 TranslateOptions。
如何使用详情:
调用签名
ComposerTranslation<Key>(key, named): string;命名插值的本地化消息翻译
类型参数
| 类型参数 |
|---|
Key extends string |
参数
| 参数 | 类型 | 描述 |
|---|---|---|
key | number | ResourceKeys | Key | 目标本地化消息键 |
named | NamedValue | 命名插值的值 |
返回值
string
已翻译的消息
备注
重载的 t。
在此重载的 t 中,对于每个占位符 x,本地化消息应包含 {x} 标记。
您也可以根据选项抑制缺少翻译时的警告。
参见:
调用签名
ComposerTranslation<Key>(
key,
named,
plural): string;命名插值和复数的本地化消息翻译
类型参数
| 类型参数 |
|---|
Key extends string |
参数
| 参数 | 类型 | 描述 |
|---|---|---|
key | number | ResourceKeys | Key | 目标本地化消息键 |
named | NamedValue | 命名插值的值 |
plural | number | 获取哪个复数字符串。1 返回第一个。 |
返回值
string
已翻译的消息
备注
重载的 t。
在此重载的 t 中,对于每个占位符 x,本地化消息应包含 {x} 标记,并返回一个复数化的翻译消息。
参见:
调用签名
ComposerTranslation<Key>(
key,
named,
defaultMsg): string;命名插值和复数的本地化消息翻译
类型参数
| 类型参数 |
|---|
Key extends string |
参数
| 参数 | 类型 | 描述 |
|---|---|---|
key | number | ResourceKeys | Key | 目标本地化消息键 |
named | NamedValue | 命名插值的值 |
defaultMsg | string | 如果未找到翻译,则返回的默认消息 |
返回值
string
已翻译的消息
备注
重载的 t。
在此重载的 t 中,对于每个占位符 x,本地化消息应包含 {x} 标记,并且如果没有找到翻译,则返回默认消息。
参见:
调用签名
ComposerTranslation<Key>(
key,
named,
options): string;命名插值的本地化消息翻译
类型参数
| 类型参数 |
|---|
Key extends string |
参数
| 参数 | 类型 | 描述 |
|---|---|---|
key | number | ResourceKeys | Key | 目标本地化消息键 |
named | NamedValue | 命名插值的值 |
options | TranslateOptions<Locales> | 翻译的附加 选项 |
返回值
string
已翻译的消息
备注
重载的 t。
在此重载的 t 中,对于每个占位符 x,本地化消息应包含 {x} 标记。
您也可以根据选项抑制缺少翻译时的警告。
有关选项的详细信息,请参阅 TranslateOptions。
如何使用详情: