Skip to content

Legacy API

DateTimeFormatResult

Signature:

typescript
export type DateTimeFormatResult = string;

LocaleMessageObject

Signature:

typescript
export type LocaleMessageObject<Message = string> = LocaleMessageDictionary<Message>;

NumberFormatResult

Signature:

typescript
export type NumberFormatResult = string;

TranslateResult

Signature:

typescript
export type TranslateResult = string;

VueI18n

VueI18n legacy interfaces

Signature:

typescript
export interface VueI18n<Messages extends Record<string, any> = {}, DateTimeFormats extends Record<string, any> = {}, NumberFormats extends Record<string, any> = {}, OptionLocale = Locale, ResourceLocales = PickupLocales<NonNullable<Messages>> | PickupLocales<NonNullable<DateTimeFormats>> | PickupLocales<NonNullable<NumberFormats>>, Locales = Locale extends GeneratedLocale ? GeneratedLocale : OptionLocale extends string ? [ResourceLocales] extends [never] ? Locale : ResourceLocales : OptionLocale | ResourceLocales, Composition extends Composer<Messages, DateTimeFormats, NumberFormats, OptionLocale> = Composer<Messages, DateTimeFormats, NumberFormats, OptionLocale>>

Details

This interface is compatible with interface of VueI18n class (offered with Vue I18n v8.x).

availableLocales

Signature:

typescript
readonly availableLocales: Composition['availableLocales'];

Details

The list of available locales in messages in lexical order.

d

Datetime formatting

Signature:

typescript
d: VueI18nDateTimeFormatting<DateTimeFormats, Locales, RemoveIndexSignature<{
        [K in keyof DefineDateTimeFormat]: DefineDateTimeFormat[K];
    }>>;

Details

About details functions, See the VueI18nDateTimeFormatting

datetimeFormats

Signature:

typescript
readonly datetimeFormats: {
        [K in keyof DateTimeFormats]: DateTimeFormats[K];
    };

Details

The datetime formats of localization.

See Also

escapeParameterHtml

Signature:

typescript
escapeParameterHtml: Composition['escapeParameter'];

Details

Whether interpolation parameters are escaped before the message is translated.

See Also

fallbackLocale

Signature:

typescript
fallbackLocale: FallbackLocales<Locales>;

Details

The current fallback locales this VueI18n instance is using.

See Also

formatFallbackMessages

Signature:

typescript
formatFallbackMessages: Composition['fallbackFormat'];

Details

Whether suppress warnings when falling back to either fallbackLocale or root.

See Also

getDateTimeFormat

Get datetime format

Signature:

typescript
getDateTimeFormat: Composition['getDateTimeFormat'];

Details

get datetime format from VueI18n instance datetimeFormats.

getLocaleMessage

Get locale message

Signature:

typescript
getLocaleMessage: Composition['getLocaleMessage'];

Details

get locale message from VueI18n instance messages.

getNumberFormat

Get number format

Signature:

typescript
getNumberFormat: Composition['getNumberFormat'];

Details

get number format from VueI18n instance numberFormats.

id

Signature:

typescript
id: number;

Details

Instance ID.

locale

Signature:

typescript
locale: Locales;

Details

The current locale this VueI18n instance is using.

If the locale contains a territory and a dialect, this locale contains an implicit fallback.

See Also

mergeDateTimeFormat

Merge datetime format

Signature:

typescript
mergeDateTimeFormat: Composition['mergeDateTimeFormat'];

Details

Merge datetime format to VueI18n instance datetimeFormats.

mergeLocaleMessage

Merge locale message

Signature:

typescript
mergeLocaleMessage: Composition['mergeLocaleMessage'];

Details

Merge locale message to VueI18n instance messages.

mergeNumberFormat

Merge number format

Signature:

typescript
mergeNumberFormat: Composition['mergeNumberFormat'];

Details

Merge number format to VueI18n instance numberFormats.

messages

Signature:

typescript
readonly messages: {
        [K in keyof Messages]: Messages[K];
    };

Details

The locale messages of localization.

See Also

missing

Signature:

typescript
missing: MissingHandler | null;

Details

A handler for localization missing.

modifiers

Signature:

typescript
readonly modifiers: Composition['modifiers'];

Details

Custom Modifiers for linked messages.

See Also

n

Number Formatting

Signature:

typescript
n: VueI18nNumberFormatting<NumberFormats, Locales, RemoveIndexSignature<{
        [K in keyof DefineNumberFormat]: DefineNumberFormat[K];
    }>>;

Details

About details functions, See the VueI18nNumberFormatting

numberFormats

Signature:

typescript
readonly numberFormats: {
        [K in keyof NumberFormats]: NumberFormats[K];
    };

Details

The number formats of localization.

See Also

pluralizationRules

A set of rules for word pluralization

Signature:

typescript
pluralizationRules: Composition['pluralRules'];

See Also

postTranslation

Signature:

typescript
postTranslation: PostTranslationHandler<VueMessageType> | null;

Details

A handler for post processing of translation.

rt

Resolve locale message translation

Signature:

typescript
rt: VueI18nResolveLocaleMessageTranslation<Locales>;

Details

About details functions, See the VueI18nResolveLocaleMessageTranslation

setDateTimeFormat

Set datetime format

Signature:

typescript
setDateTimeFormat: Composition['setDateTimeFormat'];

Details

Set datetime format to VueI18n instance datetimeFormats.

setLocaleMessage

Set locale message

Signature:

typescript
setLocaleMessage: Composition['setLocaleMessage'];

Details

Set locale message to VueI18n instance messages.

setNumberFormat

Set number format

Signature:

typescript
setNumberFormat: Composition['setNumberFormat'];

Details

Set number format to VueI18n instance numberFormats.

silentFallbackWarn

Signature:

typescript
silentFallbackWarn: Composition['fallbackWarn'];

Details

Whether suppress fallback warnings when localization fails.

silentTranslationWarn

Signature:

typescript
silentTranslationWarn: Composition['missingWarn'];

Details

Whether suppress warnings outputted when localization fails.

See Also

sync

Signature:

typescript
sync: Composition['inheritLocale'];

Details

Whether synchronize the root level locale to the component localization locale.

See Also

t

Locale message translation

Signature:

typescript
t: VueI18nTranslation<Messages, Locales, RemoveIndexSignature<{
        [K in keyof DefineLocaleMessage]: DefineLocaleMessage[K];
    }>>;

Details

About details functions, See the VueI18nTranslation

tc

Locale message pluralization

Signature:

typescript
tc: VueI18nTranslationChoice<Messages, Locales, RemoveIndexSignature<{
        [K in keyof DefineLocaleMessage]: DefineLocaleMessage[K];
    }>>;

Details

About details functions, See the VueI18nTranslationChoice

tm

Locale messages getter

Signature:

typescript
tm: Composition['tm'];

Details

If i18n component options is specified, it’s get in preferentially local scope locale messages than global scope locale messages.

If i18n component options isn't specified, it’s get with global scope locale messages.

Based on the current locale, locale messages will be returned from Composer instance messages.

If you change the locale, the locale messages returned will also correspond to the locale.

If there are no locale messages for the given key in the composer instance messages, they will be returned with fallbacking.

WARNING

You need to use rt for the locale message returned by tm. see the rt details.

Examples

template:

html
<div class="container">
  <template v-for="content in $tm('contents')">
    <h2>{{ $rt(content.title) }}</h2>
    <p v-for="paragraph in content.paragraphs">
     {{ $rt(paragraph) }}
    </p>
  </template>
</div>
js
import { createI18n } from 'vue-i18n'

const i18n = createI18n({
  messages: {
    en: {
      contents: [
        {
          title: 'Title1',
          // ...
          paragraphs: [
            // ...
          ]
        }
      ]
    }
  }
  // ...
})

warnHtmlInMessage

Signature:

typescript
warnHtmlInMessage: WarnHtmlInMessageLevel;

Details

Whether to allow the use locale messages of HTML formatting.

If you set warn or error, will check the locale messages on the VueI18n instance.

If you are specified warn, a warning will be output at console.

If you are specified error will occurred an Error.

See Also

te(key, locale)

Translation locale message exist

Signature:

typescript
te<Str extends string, Key extends PickupKeys<Messages> = PickupKeys<Messages>>(key: Str | Key, locale?: Locales): boolean;

Details

whether do exist locale message on VueI18n instance messages.

If you specified locale, check the locale messages of locale.

Parameters

ParameterTypeDescription
keyStr | KeyA target locale message key
localeLocalesA target locale

Returns

If found locale message, true, else false

VueI18nDateTimeFormatting

Datetime formatting functions for VueI18n legacy interfaces

Signature:

typescript
export interface VueI18nDateTimeFormatting<DateTimeFormats extends Record<string, any> = {}, Locales = 'en-US', DefinedDateTimeFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>, C = IsEmptyObject<DefinedDateTimeFormat> extends false ? PickupFormatPathKeys<{
    [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K];
}> : never, M = IsEmptyObject<DateTimeFormats> extends false ? PickupFormatKeys<DateTimeFormats> : never, ResourceKeys extends C | M = IsNever<C> extends false ? IsNever<M> extends false ? C | M : C : IsNever<M> extends false ? M : never>

Details

This is the interface for VueI18n

(value: number | Date): DateTimeFormatResult;

Datetime formatting

Signature:

typescript
(value: number | Date): DateTimeFormatResult;

Details

If this is used in a reactive context, it will re-evaluate once the locale changes.

If i18n component options is specified, it’s formatted in preferentially local scope datetime formats than global scope locale messages.

If i18n component options isn't specified, it’s formatted with global scope datetime formats.

See Also

Parameters

ParameterTypeDescription
valuenumber | DateA value, timestamp number or Date instance

Returns

Formatted value

(value: Value, key: Key | ResourceKeys): DateTimeFormatResult;

Datetime formatting

Signature:

typescript
<Value extends number | Date = number, Key extends string = string>(value: Value, key: Key | ResourceKeys): DateTimeFormatResult;

Details

Overloaded d. About details, see the call signature details.

Parameters

ParameterTypeDescription
valueValueA value, timestamp number or Date instance
keyKey | ResourceKeysA key of datetime formats

Returns

Formatted value

(value: Value, key: Key | ResourceKeys, locale: Locales): DateTimeFormatResult;

Datetime formatting

Signature:

typescript
<Value extends number | Date = number, Key extends string = string>(value: Value, key: Key | ResourceKeys, locale: Locales): DateTimeFormatResult;

Details

Overloaded d. About details, see the call signature details.

Parameters

ParameterTypeDescription
valueValueA value, timestamp number or Date instance
keyKey | ResourceKeysA key of datetime formats
localeLocalesA locale, it will be used over than global scope or local scope.

Returns

Formatted value

(value: number | Date, args: { [key: string]: string | boolean | number; }): DateTimeFormatResult;

Datetime formatting

Signature:

typescript
(value: number | Date, args: {
        [key: string]: string | boolean | number;
    }): DateTimeFormatResult;

Details

Overloaded d. About details, see the call signature details.

Parameters

ParameterTypeDescription
valuenumber | DateA value, timestamp number or Date instance
args{ [key: string]: string | boolean | number; }An argument values

Returns

Formatted value

VueI18nNumberFormatting

Number formatting functions for VueI18n legacy interfaces

Signature:

typescript
export interface VueI18nNumberFormatting<NumberFormats extends Record<string, any> = {}, Locales = 'en-US', DefinedNumberFormat extends RemovedIndexResources<DefineNumberFormat> = RemovedIndexResources<DefineNumberFormat>, C = IsEmptyObject<DefinedNumberFormat> extends false ? PickupFormatPathKeys<{
    [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K];
}> : never, M = IsEmptyObject<NumberFormats> extends false ? PickupFormatKeys<NumberFormats> : never, ResourceKeys extends C | M = IsNever<C> extends false ? IsNever<M> extends false ? C | M : C : IsNever<M> extends false ? M : never>

Details

This is the interface for VueI18n

(value: number): NumberFormatResult;

Number formatting

Signature:

typescript
(value: number): NumberFormatResult;

Details

If this is used in a reactive context, it will re-evaluate once the locale changes.

If i18n component options is specified, it’s formatted in preferentially local scope number formats than global scope locale messages.

If i18n component options isn't specified, it’s formatted with global scope number formats.

See Also

Parameters

ParameterTypeDescription
valuenumberA number value

Returns

Formatted value

(value: number, key: Key | ResourceKeys): NumberFormatResult;

Number formatting

Signature:

typescript
<Key extends string = string>(value: number, key: Key | ResourceKeys): NumberFormatResult;

Details

Overloaded n. About details, see the call signature details.

Parameters

ParameterTypeDescription
valuenumberA number value
keyKey | ResourceKeysA key of number formats

Returns

Formatted value

(value: number, key: Key | ResourceKeys, locale: Locales): NumberFormatResult;

Number formatting

Signature:

typescript
<Key extends string = string>(value: number, key: Key | ResourceKeys, locale: Locales): NumberFormatResult;

Details

Overloaded n. About details, see the call signature details.

Parameters

ParameterTypeDescription
valuenumberA number value
keyKey | ResourceKeysA key of number formats
localeLocalesA locale, it will be used over than global scope or local scope.

Returns

Formatted value

(value: number, args: { [key: string]: string | boolean | number; }): NumberFormatResult;

Number formatting

Signature:

typescript
(value: number, args: {
        [key: string]: string | boolean | number;
    }): NumberFormatResult;

Details

Overloaded n. About details, see the call signature details.

Parameters

ParameterTypeDescription
valuenumberA number value
args{ [key: string]: string | boolean | number; }An argument values

Returns

Formatted value

VueI18nOptions

VueI18n Options

Signature:

typescript
export interface VueI18nOptions<Schema extends {
    message?: unknown;
    datetime?: unknown;
    number?: unknown;
} = {
    message: DefaultLocaleMessageSchema;
    datetime: DefaultDateTimeFormatSchema;
    number: DefaultNumberFormatSchema;
}, Locales extends {
    messages: unknown;
    datetimeFormats: unknown;
    numberFormats: unknown;
} | string = Locale, Options extends ComposerOptions<Schema, Locales> = ComposerOptions<Schema, Locales>>

Details

This option is compatible with VueI18n class constructor options (offered with Vue I18n v8.x)

availableLocales

Signature:

typescript
availableLocales?: Locale[];

Details

The list of available locales in messages in lexical order.

Default Value

[]

datetime

datetimeFormats

escapeParameterHtml

Signature:

typescript
escapeParameterHtml?: Options['escapeParameter'];

Details

If escapeParameterHtml is configured as true then interpolation parameters are escaped before the message is translated.

This is useful when translation output is used in v-html and the translation resource contains html markup (e.g. around a user provided value).

This usage pattern mostly occurs when passing precomputed text strings into UI components.

The escape process involves replacing the following symbols with their respective HTML character entities: <, >, ", '.

Setting escapeParameterHtml as true should not break existing functionality but provides a safeguard against a subtle type of XSS attack vectors.

Default Value

false

See Also

fallbackLocale

Signature:

typescript
fallbackLocale?: Options['fallbackLocale'];

Details

The locale of fallback localization.

For more complex fallback definitions see fallback.

Default Value

The default 'en-US' for the locale if it's not specified, or it's locale value

See Also

fallbackRoot

Signature:

typescript
fallbackRoot?: Options['fallbackRoot'];

Details

In the component localization, whether to fall back to root level (global scope) localization when localization fails.

If false, it's not fallback to root.

Default Value

true

See Also

flatJson

Signature:

typescript
flatJson?: Options['flatJson'];

Details

Allow use flat json messages or not

Default Value

false

formatFallbackMessages

Signature:

typescript
formatFallbackMessages?: Options['fallbackFormat'];

Details

Whether suppress warnings when falling back to either fallbackLocale or root.

Default Value

false

See Also

locale

Signature:

typescript
locale?: Options['locale'];

Details

The locale of localization.

If the locale contains a territory and a dialect, this locale contains an implicit fallback.

Default Value

'en-US'

See Also

message

messageResolver

Signature:

typescript
messageResolver?: MessageResolver;

Details

A message resolver to resolve messages.

If not specified, the vue-i18n internal message resolver will be used by default.

You need to implement a message resolver yourself that supports the following requirements:

  • Resolve the message using the locale message of locale passed as the first argument of the message resolver, and the path passed as the second argument.

  • If the message could not be resolved, you need to return null.

  • If you will be returned null, the message resolver will also be called on fallback if fallbackLocale is enabled, so the message will need to be resolved as well.

The message resolver is called indirectly by the following APIs:

TIP

🆕 v9.2+

WARNING

If you use the message resolver, the flatJson setting will be ignored. That is, you need to resolve the flat JSON by yourself.

Default Value

undefined

See Also

Examples

Here is an example of how to set it up using your createI18n:

js
import { createI18n } from 'vue-i18n'

// your message resolver
function messageResolver(obj, path) {
  // simple message resolving!
  const msg = obj[path]
  return msg != null ? msg : null
}

// call with I18n option
const i18n = createI18n({
  locale: 'ja',
  messageResolver, // set your message resolver
  messages: {
    en: { ... },
    ja: { ... }
  }
})

// the below your something to do ...
// ...

messages

missing

Signature:

typescript
missing?: Options['missing'];

Details

A handler for localization missing.

The handler gets called with the localization target locale, localization path key, the Vue instance and values.

If missing handler is assigned, and occurred localization missing, it's not warned.

Default Value

null

modifiers

Signature:

typescript
modifiers?: Options['modifiers'];

Details

Custom Modifiers for linked messages.

See Also

number

numberFormats

pluralizationRules

Signature:

typescript
pluralizationRules?: Options['pluralRules'];

Details

A set of rules for word pluralization

Default Value

{}

See Also

postTranslation

Signature:

typescript
postTranslation?: Options['postTranslation'];

Details

A handler for post processing of translation. The handler gets after being called with the $t, t, $tc, and tc.

This handler is useful if you want to filter on translated text such as space trimming.

Default Value

null

sharedMessages

Signature:

typescript
sharedMessages?: LocaleMessages<VueMessageType>;

Details

The shared locale messages of localization for components. More detail see Component based localization.

Default Value

undefined

See Also

silentFallbackWarn

Signature:

typescript
silentFallbackWarn?: Options['fallbackWarn'];

Details

Whether do template interpolation on translation keys when your language lacks a translation for a key.

If true, skip writing templates for your "base" language; the keys are your templates.

Default Value

false

See Also

silentTranslationWarn

Signature:

typescript
silentTranslationWarn?: Options['missingWarn'];

Details

Whether suppress warnings outputted when localization fails.

If true, suppress localization fail warnings.

If you use regular expression, you can suppress localization fail warnings that it match with translation key (e.g. t).

Default Value

false

See Also

sync

Signature:

typescript
sync?: boolean;

Details

Whether synchronize the root level locale to the component localization locale.

If false, regardless of the root level locale, localize for each component locale.

Default Value

true

See Also

warnHtmlInMessage

Signature:

typescript
warnHtmlInMessage?: WarnHtmlInMessageLevel;

Details

Whether to allow the use locale messages of HTML formatting.

See the warnHtmlInMessage property.

Default Value

'off'

See Also

VueI18nResolveLocaleMessageTranslation

Resolve locale message translation functions for VueI18n legacy interfaces

Signature:

typescript
export type VueI18nResolveLocaleMessageTranslation<Locales = 'en-US'> = ComposerResolveLocaleMessageTranslation<Locales>;

Details

This is the interface for VueI18n. This interface is an alias of ComposerResolveLocaleMessageTranslation.

VueI18nTranslation

Locale message translation functions for VueI18n legacy interfaces

Signature:

typescript
export interface VueI18nTranslation<Messages extends Record<string, any> = {}, Locales = 'en-US', DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>, C = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
    [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
}> : never, M = IsEmptyObject<Messages> extends false ? PickupKeys<Messages> : never, ResourceKeys extends C | M = IsNever<C> extends false ? IsNever<M> extends false ? C | M : C : IsNever<M> extends false ? M : never>

Details

This is the interface for VueI18n

(key: Key | ResourceKeys): TranslateResult;

Locale message translation.

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys): TranslateResult;

Details

If this is used in a reactive context, it will re-evaluate once the locale changes.

If i18n component options is specified, it’s translated in preferentially local scope locale messages than global scope locale messages.

If i18n component options isn't specified, it’s translated with global scope locale messages.

See Also

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key

Returns

Translated message

(key: Key | ResourceKeys, named: Record<string, unknown>): TranslateResult;

Locale message translation.

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys, named: Record<string, unknown>): TranslateResult;

Details

Overloaded t. About details, see the call signature details.

See Also

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
namedRecord<string, unknown>A values of named interpolation

Returns

Translated message

(key: Key | ResourceKeys, named: NamedValue, plural: number): TranslateResult;

Locale message translation for named interpolations and plurals

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys, named: NamedValue, plural: number): TranslateResult;

Details

Overloaded t. About details, see the call signature details.

In this overloaded t, for each placeholder x, the locale messages should contain a {x} token, and return a pluralized translation message.

See Also

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
namedNamedValueA values of named interpolation
pluralnumberWhich plural string to get. 1 returns the first one.

Returns

Translated message

(key: Key | ResourceKeys, named: NamedValue, defaultMsg: string): TranslateResult;

Locale message translation for named interpolations and plurals

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys, named: NamedValue, defaultMsg: string): TranslateResult;

Details

Overloaded t. About details, see the call signature details.

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 Also

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
namedNamedValueA values of named interpolation
defaultMsgstringA default message to return if no translation was found

Returns

Translated message

(key: Key | ResourceKeys, named: NamedValue, options: TranslateOptions<Locales>): TranslateResult;

Locale message translation for named interpolations

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys, named: NamedValue, options: TranslateOptions<Locales>): TranslateResult;

Details

Overloaded t. About details, see the call signature details.

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 .

See Also

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
namedNamedValueA values of named interpolation
optionsTranslateOptions<Locales>Additional for translation

Returns

Translated message

(key: Key | ResourceKeys, plural: number): TranslateResult;

Locale message translation for plurals

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys, plural: number): TranslateResult;

Details

Overloaded t. About details, see the call signature details.

In this overloaded t, return a pluralized translation message.

You can also suppress the warning, when the translation missing according to the options.

See Also

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
pluralnumberWhich plural string to get. 1 returns the first one.

Returns

Translated message

(key: Key | ResourceKeys, plural: number, options: TranslateOptions<Locales>): TranslateResult;

Locale message translation for plurals

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys, plural: number, options: TranslateOptions<Locales>): TranslateResult;

Details

Overloaded t. About details, see the call signature details.

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 .

See Also

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
pluralnumberWhich plural string to get. 1 returns the first one.
optionsTranslateOptions<Locales>Additional for translation

Returns

Translated message

(key: Key | ResourceKeys, defaultMsg: string): TranslateResult;

Locale message translation for missing default message

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys, defaultMsg: string): TranslateResult;

Details

Overloaded t. About details, see the call signature details.

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.

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
defaultMsgstringA default message to return if no translation was found

Returns

Translated message

(key: Key | ResourceKeys, defaultMsg: string, options: TranslateOptions<Locales>): TranslateResult;

Locale message translation for missing default message

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys, defaultMsg: string, options: TranslateOptions<Locales>): TranslateResult;

Details

Overloaded t. About details, see the call signature details.

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 .

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
defaultMsgstringA default message to return if no translation was found
optionsTranslateOptions<Locales>Additional for translation

Returns

Translated message

(key: Key | ResourceKeys, list: unknown[]): TranslateResult;

Locale message translation.

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys, list: unknown[]): TranslateResult;

Details

Overloaded t. About details, see the call signature details.

See Also

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
listunknown[]A values of list interpolation

Returns

Translated message

(key: Key | ResourceKeys, list: unknown[], plural: number): TranslateResult;

Locale message translation for list interpolations and plurals

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys, list: unknown[], plural: number): TranslateResult;

Details

Overloaded t. About details, see the call signature details.

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 Also

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
listunknown[]A values of list interpolation
pluralnumberWhich plural string to get. 1 returns the first one.

Returns

Translated message

(key: Key | ResourceKeys, list: unknown[], defaultMsg: string): TranslateResult;

Locale message translation for list interpolations and missing default message

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys, list: unknown[], defaultMsg: string): TranslateResult;

Details

Overloaded t. About details, see the call signature details.

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.

See Also

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
listunknown[]A values of list interpolation
defaultMsgstringA default message to return if no translation was found

Returns

Translated message

(key: Key | ResourceKeys, list: unknown[], options: TranslateOptions<Locales>): TranslateResult;

Locale message translation for list interpolations

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys, list: unknown[], options: TranslateOptions<Locales>): TranslateResult;

Details

Overloaded t. About details, see the call signature details.

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 .

See Also

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
listunknown[]A values of list interpolation
optionsTranslateOptions<Locales>Additional for translation

Returns

Translated message

VueI18nTranslationChoice

Locale message pluralization functions for VueI18n legacy interfaces

Signature:

typescript
export interface VueI18nTranslationChoice<Messages extends Record<string, any> = {}, Locales = 'en-US', DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>, C = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
    [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
}> : never, M = IsEmptyObject<Messages> extends false ? PickupKeys<Messages> : never, ResourceKeys extends C | M = IsNever<C> extends false ? IsNever<M> extends false ? C | M : C : IsNever<M> extends false ? M : never>

Details

This is the interface for VueI18n

(key: Key | ResourceKeys): TranslateResult;

Locale message pluralization

Signature:

typescript
<Key extends string = string>(key: Key | ResourceKeys): TranslateResult;

Details

If this is used in a reactive context, it will re-evaluate once the locale changes.

If i18n component options is specified, it’s pluraled in preferentially local scope locale messages than global scope locale messages.

If i18n component options isn't specified, it’s pluraled with global scope locale messages.

The plural choice number is handled with default 1.

See Also

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key

Returns

Pluraled message

(key: Key | ResourceKeys, locale: Locales | Locale): TranslateResult;

Locale message pluralization

Signature:

typescript
<Key extends string = string>(key: Key | ResourceKeys, locale: Locales | Locale): TranslateResult;

Details

Overloaded tc. About details, see the call signature details.

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
localeLocales | LocaleA locale, it will be used over than global scope or local scope.

Returns

Pluraled message

(key: Key | ResourceKeys, list: unknown[]): TranslateResult;

Locale message pluralization

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys, list: unknown[]): TranslateResult;

Details

Overloaded tc. About details, see the call signature details.

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
listunknown[]A values of list interpolation

Returns

Pluraled message

(key: Key | ResourceKeys, named: Record<string, unknown>): TranslateResult;

Locale message pluralization

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys, named: Record<string, unknown>): TranslateResult;

Details

Overloaded tc. About details, see the call signature details.

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
namedRecord<string, unknown>A values of named interpolation

Returns

Pluraled message

(key: Key | ResourceKeys, choice: number): TranslateResult;

Locale message pluralization

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys, choice: number): TranslateResult;

Details

Overloaded tc. About details, see the call signature details.

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
choicenumberWhich plural string to get. 1 returns the first one.

Returns

Pluraled message

(key: Key | ResourceKeys, choice: number, locale: Locales | Locale): TranslateResult;

Locale message pluralization

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys, choice: number, locale: Locales | Locale): TranslateResult;

Details

Overloaded tc. About details, see the call signature details.

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
choicenumberWhich plural string to get. 1 returns the first one.
localeLocales | LocaleA locale, it will be used over than global scope or local scope.

Returns

Pluraled message

(key: Key | ResourceKeys, choice: number, list: unknown[]): TranslateResult;

Locale message pluralization

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys, choice: number, list: unknown[]): TranslateResult;

Details

Overloaded tc. About details, see the call signature details.

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
choicenumberWhich plural string to get. 1 returns the first one.
listunknown[]A values of list interpolation

Returns

Pluraled message

(key: Key | ResourceKeys, choice: number, named: Record<string, unknown>): TranslateResult;

Locale message pluralization

Signature:

typescript
<Key extends string>(key: Key | ResourceKeys, choice: number, named: Record<string, unknown>): TranslateResult;

Details

Overloaded tc. About details, see the call signature details.

Parameters

ParameterTypeDescription
keyKey | ResourceKeysA target locale message key
choicenumberWhich plural string to get. 1 returns the first one.
namedRecord<string, unknown>A values of named interpolation

Returns

Pluraled message

Released under the MIT License.