diff --git a/packages/petite-vue-i18n/src/vue.d.ts b/packages/petite-vue-i18n/src/vue.d.ts index c4d1b7449..c9f7efaa5 100644 --- a/packages/petite-vue-i18n/src/vue.d.ts +++ b/packages/petite-vue-i18n/src/vue.d.ts @@ -1,32 +1,19 @@ import type { Path, NamedValue } from '@intlify/core-base' import type { - Locale, - LocaleMessageValue, - MessageFunction, TranslateOptions, - DateTimeOptions, - NumberOptions, IsNever, IsEmptyObject, - PickupPaths, - PickupKeys, - PickupFormatPathKeys + PickupPaths } from '@intlify/core-base' -import type { - CustomBlocks, - VueMessageType -} from '../../vue-i18n-core/src/composer' +import type { CustomBlocks } from '../../vue-i18n-core/src/composer' import type { DefineLocaleMessage, - DefineDateTimeFormat, RemovedIndexResources } from '../../vue-i18n-core/src/composer' import type { VueI18n, VueI18nOptions, - TranslateResult, - DateTimeFormatResult, - NumberFormatResult + TranslateResult } from '../../vue-i18n-core/src/legacy' import type { ExportedGlobalComposer } from '../../vue-i18n-core/src/i18n' @@ -417,696 +404,5 @@ declare module '@vue/runtime-core' { named: NamedValue, options: TranslateOptions ): TranslateResult - /** - * Resolve locale message translation - * - * @remarks - * If this is used in a reactive context, it will re-evaluate once the locale changes. - * - * In {@link I18nMode | Legacy API mode}, the input / output is the same as for VueI18n instance. About that details, see {@link VueI18n#rt | `VueI18n#rt`}. - * - * In {@link I18nMode | Composition API mode}, the `$rt` is injected by `app.config.globalProperties`. - * the input / output is the same as for Composer, and it work on **global scope**. About that details, see {@link Composer#rt | `Composer#rt` }. - * - * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `$tm`. - * - * @returns translated message - */ - $rt(message: MessageFunction | VueMessageType): string - /** - * Resolve locale message translation for plurals - * - * @remarks - * Overloaded `$rt`. About details, see the {@link $rt} remarks. - * - * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `$tm`. - * @param plural - Which plural string to get. 1 returns the first one. - * @param options - Additional {@link TranslateOptions | options} for translation - * - * @returns Translated message - */ - $rt( - message: MessageFunction | VueMessageType, - plural: number, - options?: TranslateOptions - ): string - /** - * Resolve locale message translation for list interpolations - * - * @remarks - * Overloaded `$rt`. About details, see the {@link $rt} remarks. - * - * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `$tm`. - * @param list - A values of list interpolation. - * @param options - Additional {@link TranslateOptions | options} for translation - * - * @returns Translated message - */ - $rt( - message: MessageFunction | VueMessageType, - list: unknown[], - options?: TranslateOptions - ): string - /** - * Resolve locale message translation for named interpolations - * - * @remarks - * Overloaded `$rt`. About details, see the {@link $rt} remarks. - * - * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `$tm`. - * @param named - A values of named interpolation. - * @param options - Additional {@link TranslateOptions | options} for translation - * - * @returns Translated message - */ - $rt( - message: MessageFunction | VueMessageType, - named: NamedValue, - options?: TranslateOptions - ): string - /** - * Locale message pluralization - * - * @remarks - * If this is used in a reactive context, it will re-evaluate once the locale changes. - * - * The input / output is the same as for VueI18n instance. About that details, see {@link VueI18n#tc | `VueI18n#tc` }. - * The value of plural is handled with default `1`. - * Supported for Legacy API mode only. - * - * @param key - A target locale message key - * - * @returns translation message that is pluraled - */ - $tc< - Key extends string, - DefinedLocaleMessage extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? PickupPaths<{ - [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - key: Key | ResourceKeys | Path - ): TranslateResult - /** - * Locale message pluralization - * - * @remarks - * Overloaded `$tc`. About details, see the {@link $tc} remarks. - * Supported for Legacy API mode only. - * - * @param key - A target locale message key - * @param locale - A locale, override locale that global scope or local scope - * - * @returns translation message that is pluraled - */ - $tc< - Key extends string, - DefinedLocaleMessage extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? PickupPaths<{ - [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - key: Key | ResourceKeys | Path, - locale: Locale - ): TranslateResult - /** - * Locale message pluralization - * - * @remarks - * Overloaded `$tc`. About details, see the {@link $tc} remarks. - * Supported for Legacy API mode only. - * - * @param key - A target locale message key - * @param list - A values of list interpolation - * - * @returns translation message that is pluraled - */ - $tc< - Key extends string, - DefinedLocaleMessage extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? PickupPaths<{ - [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - key: Key | ResourceKeys | Path, - list: unknown[] - ): TranslateResult - /** - * Locale message pluralization - * Supported for Legacy API mode only. - * - * @remarks - * Overloaded `$tc`. About details, see the {@link $tc} remarks. - * Supported for Legacy API mode only. - * - * @param key - A target locale message key - * @param named - A values of named interpolation - * - * @returns translation message that is pluraled - */ - $tc< - Key extends string, - DefinedLocaleMessage extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? PickupPaths<{ - [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - key: Key | ResourceKeys | Path, - named: Record - ): TranslateResult - /** - * Locale message pluralization - * Supported for Legacy API mode only. - * - * @remarks - * Overloaded `$tc`. About details, see the {@link $tc} remarks. - * Supported for Legacy API mode only. - * - * @param key - A target locale message key - * @param choice - Which plural string to get. 1 returns the first one. - * - * @returns translation message that is pluraled - */ - $tc< - Key extends string, - DefinedLocaleMessage extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? PickupPaths<{ - [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - key: Key | ResourceKeys | Path, - choice: number - ): TranslateResult - /** - * Locale message pluralization - * Supported for Legacy API mode only. - * - * @remarks - * Overloaded `$tc`. About details, see the {@link $tc} remarks. - * Supported for Legacy API mode only. - * - * @param key - A target locale message key - * @param choice - Which plural string to get. 1 returns the first one. - * @param locale - A locale, override locale that global scope or local scope - * - * @returns translation message that is pluraled - */ - $tc< - Key extends string, - DefinedLocaleMessage extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? PickupPaths<{ - [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - key: Key | ResourceKeys | Path, - choice: number, - locale: Locale - ): TranslateResult - /** - * Locale message pluralization - * Supported for Legacy API mode only. - * - * @remarks - * Overloaded `$tc`. About details, see the {@link $tc} remarks. - * Supported for Legacy API mode only. - * - * @param key - A target locale message key - * @param choice - Which plural string to get. 1 returns the first one. - * @param list - A values of list interpolation - * - * @returns translation message that is pluraled - */ - $tc< - Key extends string, - DefinedLocaleMessage extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? PickupPaths<{ - [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - key: Key | ResourceKeys | Path, - choice: number, - list: unknown[] - ): TranslateResult - /** - * Locale message pluralization - * Supported for Legacy API mode only. - * - * @remarks - * Overloaded `$tc`. About details, see the {@link $tc} remarks. - * Supported for Legacy API mode only. - * - * @param key - A target locale message key - * @param choice - Which plural string to get. 1 returns the first one. - * @param named - A values of named interpolation - * - * @returns translation message that is pluraled - */ - $tc< - Key extends string, - DefinedLocaleMessage extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? PickupPaths<{ - [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - key: Key | ResourceKeys | Path, - choice: number, - named: Record - ): TranslateResult - /** - * Translation message exist - * - * @remarks - * About that details, see {@link VueI18n#te | `VueI18n#te` } or {@link Composer#te | `Composer#te`}. - * - * @param key - A target locale message key - * @param locale - A locale, optional, override locale that global scope or local scope - * - * @returns If found locale message, `true`, else `false`, Note that `false` is returned even if the value present in the key is not translatable, yet if `translateExistCompatible` is set to `true`, it will return `true` if the key is available, even if the value is not translatable. - */ - $te< - Key extends string, - DefinedLocaleMessage extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? PickupPaths<{ - [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - key: Key | ResourceKeys | Path, - locale?: Locale - ): boolean - /** - * Datetime formatting - * - * @remarks - * If this is used in a reactive context, it will re-evaluate once the locale changes. - * - * In {@link I18nMode | Legacy API mode}, the input / output is the same as for VueI18n instance. About that details, see {@link VueI18n#d | `VueI18n#d` }. - * - * In {@link I18nMode | Composition API mode}, the `$d` is injected by `app.config.globalProperties`. - * the input / output is the same as for Composer instance, and it work on **global scope**. About that details, see {@link Composer#d | `Composer#d` }. - * - * @param value - A value, timestamp number or `Date` instance - * - * @returns formatted value - */ - $d(value: number | Date): DateTimeFormatResult - /** - * Datetime formatting - * - * @remarks - * Overloaded `$d`. About details, see the {@link $d} remarks. - * - * @param value - A value, timestamp number or `Date` instance - * @param key - A key of datetime formats - * - * @returns formatted value - */ - $d< - Value extends number | Date = number, - Key extends string = string, - DefinedDateTimeFormat extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? PickupFormatPathKeys<{ - [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - value: Value, - key: Key | ResourceKeys - ): DateTimeFormatResult - /** - * Datetime formatting - * - * @remarks - * Overloaded `$d`. About details, see the {@link $d} remarks. - * - * @param value - A value, timestamp number or `Date` instance - * @param key - A key of datetime formats - * @param locale - A locale, optional, override locale that global scope or local scope - * - * @returns formatted value - */ - $d< - Value extends number | Date = number, - Key extends string = string, - DefinedDateTimeFormat extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? PickupFormatPathKeys<{ - [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - value: Value, - key: Key | ResourceKeys, - locale: Locale - ): DateTimeFormatResult - /** - * Datetime formatting - * - * @remarks - * Overloaded `$d`. About details, see the {@link $d} remarks. - * - * @param value - A value, timestamp number or `Date` instance - * @param args - An argument values - * - * @returns formatted value - */ - $d( - value: number | Date, - args: { [key: string]: string } - ): DateTimeFormatResult - /** - * Datetime formatting - * - * @remarks - * Overloaded `$d`. About details, see the {@link $d} remarks. - * - * @param value - A value, timestamp number or `Date` instance - * - * @returns formatted value - */ - $d(value: number | Date): string - /** - * Datetime formatting - * - * @remarks - * Overloaded `$d`. About details, see the {@link $d} remarks. - * - * @param value - A value, timestamp number or `Date` instance - * @param key - A key of datetime formats - * - * @returns formatted value - */ - $d< - Value extends number | Date = number, - Key extends string = string, - DefinedDateTimeFormat extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? PickupFormatPathKeys<{ - [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - value: Value, - key: Key | ResourceKeys - ): string - /** - * Datetime formatting - * - * @remarks - * Overloaded `$d`. About details, see the {@link $d} remarks. - * - * @param value - A value, timestamp number or `Date` instance - * @param key - A key of datetime formats - * @param locale - A locale, optional, override locale that global scope or local scope - * - * @returns formatted value - */ - $d< - Value extends number | Date = number, - Key extends string = string, - DefinedDateTimeFormat extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? PickupFormatPathKeys<{ - [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - value: Value, - key: Key | ResourceKeys, - locale: Locale - ): string - /** - * Datetime formatting - * - * @remarks - * Overloaded `$d`. About details, see the {@link $d} remarks. - * - * @param value - A value, timestamp number or `Date` instance - * @param options - An options, see the {@link DateTimeOptions} - * - * @returns formatted value - */ - $d(value: number | Date, options: DateTimeOptions): string - /** - * Number formatting - * - * @remarks - * If this is used in a reactive context, it will re-evaluate once the locale changes. - * - * In {@link I18nMode | Legacy API mode}, the input / output is the same as for VueI18n instance. About that details, see {@link VueI18n#n | `VueI18n.n` }. - * - * In {@link I18nMode | Composition API mode}, the `$n` is injected by `app.config.globalProperties`. - * the input / output is the same as for Composer instance, and it work on **global scope**. About that details, see {@link Composer#n | `Composer.n` }. - * - * @param value - A number value - * - * @returns formatted value - */ - $n(value: number): NumberFormatResult - /** - * Number formatting - * - * @remarks - * Overloaded `$n`. About details, see the {@link $n} remarks. - * - * @param value - A number value - * @param key - A key of number formats - * - * @returns formatted value - */ - $n< - Key extends string = string, - DefinedNumberFormat extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? PickupFormatPathKeys<{ - [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - value: number, - key: Key | ResourceKeys - ): NumberFormatResult - /** - * Number formatting - * - * @remarks - * Overloaded `$n`. About details, see the {@link $n} remarks. - * - * @param value - A number value - * @param key - A key of number formats - * @param locale - A locale, optional, override locale that global scope or local scope - * - * @returns formatted value - */ - $n< - Key extends string = string, - DefinedNumberFormat extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? PickupFormatPathKeys<{ - [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - value: number, - key: Key | ResourceKeys, - locale: Locale - ): NumberFormatResult - /** - * Number formatting - * - * @remarks - * Overloaded `$n`. About details, see the {@link $n} remarks. - * - * @param value - A number value - * @param args - An argument values - * - * @returns formatted value - */ - $n( - value: number, - args: { [key: string]: string | boolean | number } - ): NumberFormatResult - /** - * Number formatting - * - * @remarks - * Overloaded `$n`. About details, see the {@link $n} remarks. - * - * @param value - A number value - * @param key - A key of number formats - * @param args - An argument values - * - * @returns formatted value - */ - $n( - value: number, - key: string, - args: { [key: string]: string | boolean | number } - ): NumberFormatResult - /** - * Number formatting - * - * @remarks - * Overloaded `$n`. About details, see the {@link $n} remarks. - * - * @param value - A number value - * @param key - A key of number formats - * @param locale - A locale, optional, override locale that global scope or local scope - * @param args - An argument values - * - * @returns formatted value - */ - $n( - value: number, - key: string, - locale: Locale, - args: { [key: string]: string | boolean | number } - ): NumberFormatResult - /** - * Number formatting - * - * @remarks - * Overloaded `$n`. About details, see the {@link $n} remarks. - * - * @param value - A number value - * - * @returns formatted value - */ - $n(value: number): string - /** - * Number formatting - * - * @remarks - * Overloaded `$n`. About details, see the {@link $n} remarks. - * - * @param value - A number value - * @param key - A key of number formats - * - * @returns formatted value - */ - $n< - Key extends string = string, - DefinedNumberFormat extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? PickupFormatPathKeys<{ - [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - value: number, - key: Key | ResourceKeys - ): string - /** - * Number formatting - * - * @remarks - * Overloaded `$n`. About details, see the {@link $n} remarks. - * - * @param value - A number value - * @param key - A key of number formats - * @param locale - A locale, optional, override locale that global scope or local scope - * - * @returns formatted value - */ - $n< - Key extends string = string, - DefinedNumberFormat extends - RemovedIndexResources = RemovedIndexResources, - Keys = IsEmptyObject extends false - ? PickupFormatPathKeys<{ - [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K] - }> - : never, - ResourceKeys extends Keys = IsNever extends false ? Keys : never - >( - value: number, - key: Key | ResourceKeys, - locale: Locale - ): string - /** - * Number formatting - * - * @remarks - * Overloaded `$n`. About details, see the {@link $n} remarks. - * - * @param value - A number value - * @param options - An options, see the {@link NumberOptions} - * - * @returns formatted value - */ - $n(value: number, options: NumberOptions): string - /** - * Locale messages getter - * - * In {@link I18nMode | Legacy API mode}, the input / output is the same as for VueI18n instance. About that details, see {@link VueI18n#tm | `VueI18n#tm` }. - * - * @remarks - * In {@link I18nMode | Composition API mode}, the `$tm` is injected by `app.config.globalProperties`. - * the input / output is the same as for Composer instance, and it work on **global scope**. About that details, see {@link Composer#tm | `Composer.tm` }. - * 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. - * - * @param key - A target locale message key - * - * @returns locale messages - */ - $tm< - Key extends string, - Messages extends object = {}, - ResourceKeys extends PickupKeys = PickupKeys - >( - key: Key | ResourceKeys - ): LocaleMessageValue | {} } }