core-base.d.ts 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263
  1. import type { BaseError } from '@intlify/shared';
  2. import { CompileError } from '@intlify/message-compiler';
  3. import { CompileErrorCodes } from '@intlify/message-compiler';
  4. import type { CompileOptions } from '@intlify/message-compiler';
  5. import type { CoreMissingType as CoreMissingType_2 } from '@intlify/core-base';
  6. import { createCompileError } from '@intlify/message-compiler';
  7. import type { Emittable } from '@intlify/shared';
  8. import type { Locale as Locale_2 } from '@intlify/core-base';
  9. import type { MessageFunction as MessageFunction_2 } from '@intlify/core-base';
  10. import type { Path as Path_2 } from '@intlify/core-base';
  11. import type { PathValue as PathValue_2 } from '@intlify/core-base';
  12. import { ResourceNode } from '@intlify/message-compiler';
  13. import type { ResourceNode as ResourceNode_2 } from '@intlify/core-base';
  14. declare type __ResourceFormatPath<T, Key extends keyof T> = Key extends string ? T[Key] extends Record<string, any> ? `${Key}` : never : never;
  15. export declare type __ResourcePath<T, Key extends keyof T> = Key extends string ? T[Key] extends Record<string, any> ? `${Key}.${__ResourcePath<T[Key], Exclude<keyof T[Key], keyof any[]>> & string}` | `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}` : never : never;
  16. declare type AdditionalPayloads = {
  17. meta?: Record<string, unknown>;
  18. };
  19. export declare function clearCompileCache(): void;
  20. /* Excluded from this release type: clearDateTimeFormat */
  21. /* Excluded from this release type: clearNumberFormat */
  22. export declare function compile<Message = string, MessageSource = string | ResourceNode>(message: MessageSource, context: MessageCompilerContext): MessageFunction<Message>;
  23. export { CompileError }
  24. export { CompileErrorCodes }
  25. export declare const compileToFunction: <Message = string, MessageSource = string | ResourceNode>(message: MessageSource, context: MessageCompilerContext) => MessageFunction<Message>;
  26. export declare interface CoreCommonContext<Message = string, Locales = 'en-US'> {
  27. cid: number;
  28. version: string;
  29. locale: Locales;
  30. fallbackLocale: FallbackLocales<Exclude<Locales, LocaleDetector>>;
  31. missing: CoreMissingHandler<Message> | null;
  32. missingWarn: boolean | RegExp;
  33. fallbackWarn: boolean | RegExp;
  34. fallbackFormat: boolean;
  35. unresolving: boolean;
  36. localeFallbacker: LocaleFallbacker;
  37. onWarn(msg: string, err?: Error): void;
  38. }
  39. export declare type CoreContext<Message = string, Messages = {}, DateTimeFormats = {}, NumberFormats = {}, LocaleType = Locale, ResourceLocales = PickupLocales<NonNullable<Messages>> | PickupLocales<NonNullable<DateTimeFormats>> | PickupLocales<NonNullable<NumberFormats>>, Locales = IsNever<ResourceLocales> extends true ? LocaleType extends LocaleDetector | Locale ? LocaleType : Locale : ResourceLocales> = CoreCommonContext<Message, Locales> & CoreTranslationContext<NonNullable<Messages>, Message> & CoreDateTimeContext<NonNullable<DateTimeFormats>> & CoreNumberContext<NonNullable<NumberFormats>> & {
  40. fallbackContext?: CoreContext<Message, Messages, DateTimeFormats, NumberFormats, LocaleType, ResourceLocales, Locales>;
  41. };
  42. export declare interface CoreDateTimeContext<DateTimeFormats = {}> {
  43. datetimeFormats: {
  44. [K in keyof DateTimeFormats]: DateTimeFormats[K];
  45. };
  46. }
  47. export declare interface CoreError extends BaseError {
  48. }
  49. export declare const CoreErrorCodes: {
  50. readonly INVALID_ARGUMENT: 17;
  51. readonly INVALID_DATE_ARGUMENT: number;
  52. readonly INVALID_ISO_DATE_ARGUMENT: number;
  53. readonly NOT_SUPPORT_NON_STRING_MESSAGE: number;
  54. readonly NOT_SUPPORT_LOCALE_PROMISE_VALUE: number;
  55. readonly NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: number;
  56. readonly NOT_SUPPORT_LOCALE_TYPE: number;
  57. readonly __EXTEND_POINT__: number;
  58. };
  59. export declare type CoreErrorCodes = (typeof CoreErrorCodes)[keyof typeof CoreErrorCodes];
  60. export declare interface CoreInternalContext {
  61. __datetimeFormatters: Map<string, Intl.DateTimeFormat>;
  62. __numberFormatters: Map<string, Intl.NumberFormat>;
  63. __localeChainCache?: Map<Locale, Locale[]>;
  64. __v_emitter?: VueDevToolsEmitter;
  65. __meta: MetaInfo;
  66. }
  67. export declare interface CoreInternalOptions {
  68. __datetimeFormatters?: Map<string, Intl.DateTimeFormat>;
  69. __numberFormatters?: Map<string, Intl.NumberFormat>;
  70. __v_emitter?: VueDevToolsEmitter;
  71. __meta?: MetaInfo;
  72. }
  73. export declare type CoreMissingHandler<Message = string> = (context: CoreContext<Message>, locale: Locale, key: Path, type: CoreMissingType, ...values: unknown[]) => string | void;
  74. export declare type CoreMissingType = 'translate' | 'datetime format' | 'number format' | 'translate exists';
  75. export declare interface CoreNumberContext<NumberFormats = {}> {
  76. numberFormats: {
  77. [K in keyof NumberFormats]: NumberFormats[K];
  78. };
  79. }
  80. export declare interface CoreOptions<Message = string, Schema extends {
  81. message?: unknown;
  82. datetime?: unknown;
  83. number?: unknown;
  84. } = {
  85. message: DefaultCoreLocaleMessageSchema;
  86. datetime: DateTimeFormat;
  87. number: NumberFormat;
  88. }, Locales extends {
  89. messages: unknown;
  90. datetimeFormats: unknown;
  91. numberFormats: unknown;
  92. } | string = Locale, MessagesLocales = Locales extends {
  93. messages: infer M;
  94. } ? M : Locales extends string ? Locales : Locale, DateTimeFormatsLocales = Locales extends {
  95. datetimeFormats: infer D;
  96. } ? D : Locales extends string ? Locales : Locale, NumberFormatsLocales = Locales extends {
  97. numberFormats: infer N;
  98. } ? N : Locales extends string ? Locales : Locale, MessageSchema = Schema extends {
  99. message: infer M;
  100. } ? M : DefaultCoreLocaleMessageSchema, DateTimeSchema = Schema extends {
  101. datetime: infer D;
  102. } ? D : DateTimeFormat, NumberSchema = Schema extends {
  103. number: infer N;
  104. } ? N : NumberFormat, _Messages extends LocaleMessages<MessageSchema, MessagesLocales, Message> = LocaleMessages<MessageSchema, MessagesLocales, Message>, _DateTimeFormats extends DateTimeFormats<DateTimeSchema, DateTimeFormatsLocales> = DateTimeFormats<DateTimeSchema, DateTimeFormatsLocales>, _NumberFormats extends NumberFormats<NumberSchema, NumberFormatsLocales> = NumberFormats<NumberSchema, NumberFormatsLocales>> {
  105. version?: string;
  106. locale?: Locale | LocaleDetector;
  107. fallbackLocale?: FallbackLocale;
  108. messages?: {
  109. [K in keyof _Messages]: MessageSchema;
  110. };
  111. datetimeFormats?: {
  112. [K in keyof _DateTimeFormats]: DateTimeSchema;
  113. };
  114. numberFormats?: {
  115. [K in keyof _NumberFormats]: NumberSchema;
  116. };
  117. modifiers?: LinkedModifiers<Message>;
  118. pluralRules?: PluralizationRules;
  119. missing?: CoreMissingHandler<Message>;
  120. missingWarn?: boolean | RegExp;
  121. fallbackWarn?: boolean | RegExp;
  122. fallbackFormat?: boolean;
  123. unresolving?: boolean;
  124. postTranslation?: PostTranslationHandler<Message>;
  125. processor?: MessageProcessor<Message>;
  126. warnHtmlMessage?: boolean;
  127. escapeParameter?: boolean;
  128. messageCompiler?: MessageCompiler<Message, string | ResourceNode>;
  129. messageResolver?: MessageResolver;
  130. localeFallbacker?: LocaleFallbacker;
  131. fallbackContext?: CoreContext<Message, MessagesLocales, DateTimeFormatsLocales, NumberFormatsLocales>;
  132. onWarn?: (msg: string, err?: Error) => void;
  133. }
  134. export declare interface CoreTranslationContext<Messages = {}, Message = string> {
  135. messages: {
  136. [K in keyof Messages]: Messages[K];
  137. };
  138. modifiers: LinkedModifiers<Message>;
  139. pluralRules?: PluralizationRules;
  140. postTranslation: PostTranslationHandler<Message> | null;
  141. processor: MessageProcessor<Message> | null;
  142. warnHtmlMessage: boolean;
  143. escapeParameter: boolean;
  144. messageCompiler: MessageCompiler<Message, string | ResourceNode> | null;
  145. messageResolver: MessageResolver;
  146. }
  147. export declare const CoreWarnCodes: {
  148. readonly NOT_FOUND_KEY: 2;
  149. readonly FALLBACK_TO_TRANSLATE: number;
  150. readonly CANNOT_FORMAT_NUMBER: number;
  151. readonly FALLBACK_TO_NUMBER_FORMAT: number;
  152. readonly CANNOT_FORMAT_DATE: number;
  153. readonly FALLBACK_TO_DATE_FORMAT: number;
  154. readonly EXPERIMENTAL_CUSTOM_MESSAGE_COMPILER: number;
  155. readonly __EXTEND_POINT__: number;
  156. };
  157. export declare type CoreWarnCodes = (typeof CoreWarnCodes)[keyof typeof CoreWarnCodes];
  158. export { createCompileError }
  159. export declare function createCoreContext<Message = string, Options extends CoreOptions<Message> = CoreOptions<Message>, Messages extends Record<string, any> = Options['messages'] extends Record<string, any> ? Options['messages'] : {}, DateTimeFormats extends Record<string, any> = Options['datetimeFormats'] extends Record<string, any> ? Options['datetimeFormats'] : {}, NumberFormats extends Record<string, any> = Options['numberFormats'] extends Record<string, any> ? Options['numberFormats'] : {}, LocaleType = Locale | LocaleDetector>(options: Options): CoreContext<Message, Messages, DateTimeFormats, NumberFormats, LocaleType>;
  160. export declare function createCoreContext<Schema = LocaleMessage, Locales = 'en-US', Message = string, Options extends CoreOptions<Message, SchemaParams<Schema, Message>, LocaleParams<Locales>> = CoreOptions<Message, SchemaParams<Schema, Message>, LocaleParams<Locales>>, Messages extends Record<string, any> = NonNullable<Options['messages']> extends Record<string, any> ? NonNullable<Options['messages']> : {}, DateTimeFormats extends Record<string, any> = NonNullable<Options['datetimeFormats']> extends Record<string, any> ? NonNullable<Options['datetimeFormats']> : {}, NumberFormats extends Record<string, any> = NonNullable<Options['numberFormats']> extends Record<string, any> ? NonNullable<Options['numberFormats']> : {}, LocaleType = Locale | LocaleDetector>(options: Options): CoreContext<Message, Messages, DateTimeFormats, NumberFormats, LocaleType>;
  161. export declare function createCoreError(code: CoreErrorCodes): CoreError;
  162. export declare function createMessageContext<T = string, N = {}>(options?: MessageContextOptions<T, N>): MessageContext<T>;
  163. /**
  164. * number
  165. */
  166. export declare type CurrencyDisplay = 'symbol' | 'code' | 'name';
  167. export declare interface CurrencyNumberFormatOptions extends Intl.NumberFormatOptions {
  168. style: 'currency';
  169. currency: string;
  170. currencyDisplay?: CurrencyDisplay;
  171. localeMatcher?: LocaleMatcher;
  172. formatMatcher?: FormatMatcher;
  173. }
  174. /**
  175. * `datetime` function overloads
  176. */
  177. export declare function datetime<Context extends CoreContext<Message, {}, {}, {}>, Message = string>(context: Context, value: number | string | Date): string | number | Intl.DateTimeFormatPart[];
  178. export declare function datetime<Context extends CoreContext<Message, {}, {}, {}>, Value extends number | string | Date = number, Key extends string = string, ResourceKeys extends PickupFormatKeys<Context['datetimeFormats']> = PickupFormatKeys<Context['datetimeFormats']>, Message = string>(context: Context, value: Value, keyOrOptions: Key | ResourceKeys | DateTimeOptions<Key | ResourceKeys, Context['locale']>): string | number | Intl.DateTimeFormatPart[];
  179. export declare function datetime<Context extends CoreContext<Message, {}, {}, {}>, Value extends number | string | Date = number, Key extends string = string, ResourceKeys extends PickupFormatKeys<Context['datetimeFormats']> = PickupFormatKeys<Context['datetimeFormats']>, Message = string>(context: Context, value: Value, keyOrOptions: Key | ResourceKeys | DateTimeOptions<Key | ResourceKeys, Context['locale']>, locale: Context['locale']): string | number | Intl.DateTimeFormatPart[];
  180. export declare function datetime<Context extends CoreContext<Message, {}, {}, {}>, Value extends number | string | Date = number, Key extends string = string, ResourceKeys extends PickupFormatKeys<Context['datetimeFormats']> = PickupFormatKeys<Context['datetimeFormats']>, Message = string>(context: Context, value: Value, keyOrOptions: Key | ResourceKeys | DateTimeOptions<Key | ResourceKeys, Context['locale']>, override: Intl.DateTimeFormatOptions): string | number | Intl.DateTimeFormatPart[];
  181. export declare function datetime<Context extends CoreContext<Message, {}, {}, {}>, Value extends number | string | Date = number, Key extends string = string, ResourceKeys extends PickupFormatKeys<Context['datetimeFormats']> = PickupFormatKeys<Context['datetimeFormats']>, Message = string>(context: Context, value: Value, keyOrOptions: Key | ResourceKeys | DateTimeOptions<Key | ResourceKeys, Context['locale']>, locale: Context['locale'], override: Intl.DateTimeFormatOptions): string | number | Intl.DateTimeFormatPart[];
  182. /* Excluded from this release type: DATETIME_FORMAT_OPTIONS_KEYS */
  183. export declare type DateTimeDigital = 'numeric' | '2-digit';
  184. export declare type DateTimeFormat = {
  185. [key: string]: DateTimeFormatOptions;
  186. };
  187. export declare type DateTimeFormatOptions = Intl.DateTimeFormatOptions | SpecificDateTimeFormatOptions;
  188. export declare type DateTimeFormats<Schema = DateTimeFormat, Locales = Locale> = LocaleRecord<UnionToTuple<Locales>, Schema>;
  189. /**
  190. * datetime
  191. */
  192. export declare type DateTimeHumanReadable = 'long' | 'short' | 'narrow';
  193. /**
  194. * # datetime
  195. *
  196. * ## usages:
  197. * // for example `context.datetimeFormats` below
  198. * 'en-US': {
  199. * short: {
  200. * year: 'numeric', month: '2-digit', day: '2-digit',
  201. * hour: '2-digit', minute: '2-digit'
  202. * }
  203. * },
  204. * 'ja-JP': { ... }
  205. *
  206. * // datetimeable value only
  207. * datetime(context, value)
  208. *
  209. * // key argument
  210. * datetime(context, value, 'short')
  211. *
  212. * // key & locale argument
  213. * datetime(context, value, 'short', 'ja-JP')
  214. *
  215. * // object sytle argument
  216. * datetime(context, value, { key: 'short', locale: 'ja-JP' })
  217. *
  218. * // suppress localize miss warning option, override context.missingWarn
  219. * datetime(context, value, { key: 'short', locale: 'ja-JP', missingWarn: false })
  220. *
  221. * // suppress localize fallback warning option, override context.fallbackWarn
  222. * datetime(context, value, { key: 'short', locale: 'ja-JP', fallbackWarn: false })
  223. *
  224. * // if you specify `part` options, you can get an array of objects containing the formatted datetime in parts
  225. * datetime(context, value, { key: 'short', part: true })
  226. *
  227. * // orverride context.datetimeFormats[locale] options with functino options
  228. * datetime(cnotext, value, 'short', { year: '2-digit' })
  229. * datetime(cnotext, value, 'short', 'ja-JP', { year: '2-digit' })
  230. * datetime(context, value, { key: 'short', part: true, year: '2-digit' })
  231. */
  232. /**
  233. * DateTime options
  234. *
  235. * @remarks
  236. * Options for Datetime formatting API
  237. *
  238. * @VueI18nGeneral
  239. */
  240. export declare interface DateTimeOptions<Key = string, Locales = Locale> extends Intl.DateTimeFormatOptions, LocaleOptions<Locales> {
  241. /**
  242. * @remarks
  243. * The target format key
  244. */
  245. key?: Key;
  246. /**
  247. * @remarks
  248. * Whether suppress warnings outputted when localization fails
  249. */
  250. missingWarn?: boolean;
  251. /**
  252. * @remarks
  253. * Whether do resolve on format keys when your language lacks a formatting for a key
  254. */
  255. fallbackWarn?: boolean;
  256. /**
  257. * @remarks
  258. * Whether to use [Intel.DateTimeFormat#formatToParts](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts)
  259. */
  260. part?: boolean;
  261. }
  262. export declare const DEFAULT_LOCALE = "en-US";
  263. export declare const DEFAULT_MESSAGE_DATA_TYPE = "text";
  264. export declare type DefaultCoreLocaleMessageSchema<Schema = RemoveIndexSignature<{
  265. [K in keyof DefineCoreLocaleMessage]: DefineCoreLocaleMessage[K];
  266. }>> = IsEmptyObject<Schema> extends true ? LocaleMessage<string> : Schema;
  267. /**
  268. * The type definition of Locale Message for `@intlify/core-base` package
  269. *
  270. * @remarks
  271. * The typealias is used to strictly define the type of the Locale message.
  272. *
  273. * @example
  274. * ```ts
  275. * // type.d.ts (`.d.ts` file at your app)
  276. * import { DefineCoreLocaleMessage } from '@intlify/core-base'
  277. *
  278. * declare module '@intlify/core-base' {
  279. * export interface DefineCoreLocaleMessage {
  280. * title: string
  281. * menu: {
  282. * login: string
  283. * }
  284. * }
  285. * }
  286. * ```
  287. *
  288. * @VueI18nGeneral
  289. */
  290. export declare interface DefineCoreLocaleMessage extends LocaleMessage<string> {
  291. }
  292. declare type ExtractToStringFunction<T> = T[ExtractToStringKey<T>];
  293. declare type ExtractToStringKey<T> = Extract<keyof T, 'toString'>;
  294. /** @VueI18nGeneral */
  295. export declare type FallbackLocale = Locale | Locale[] | {
  296. [locale in string]: Locale[];
  297. } | false;
  298. export declare type FallbackLocales<Locales = 'en-US'> = Locales | Array<Locales> | {
  299. [locale in string]: Array<PickupFallbackLocales<UnionToTuple<Locales>>>;
  300. } | false;
  301. /**
  302. * Fallback with locale chain
  303. *
  304. * @remarks
  305. * A fallback locale function implemented with a fallback chain algorithm. It's used in VueI18n as default.
  306. *
  307. * @param ctx - A {@link CoreContext | context}
  308. * @param fallback - A {@link FallbackLocale | fallback locale}
  309. * @param start - A starting {@link Locale | locale}
  310. *
  311. * @returns Fallback locales
  312. *
  313. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  314. *
  315. * @VueI18nGeneral
  316. */
  317. export declare function fallbackWithLocaleChain<Message = string>(ctx: CoreContext<Message>, fallback: FallbackLocale, start: Locale): Locale[];
  318. /**
  319. * Fallback with simple implemenation
  320. *
  321. * @remarks
  322. * A fallback locale function implemented with a simple fallback algorithm.
  323. *
  324. * Basically, it returns the value as specified in the `fallbackLocale` props, and is processed with the fallback inside intlify.
  325. *
  326. * @param ctx - A {@link CoreContext | context}
  327. * @param fallback - A {@link FallbackLocale | fallback locale}
  328. * @param start - A starting {@link Locale | locale}
  329. *
  330. * @returns Fallback locales
  331. *
  332. * @VueI18nGeneral
  333. */
  334. export declare function fallbackWithSimple<Message = string>(ctx: CoreContext<Message>, fallback: FallbackLocale, start: Locale): Locale[];
  335. export declare type First<T extends readonly any[]> = T[0];
  336. export declare type FormatMatcher = 'basic' | 'best fit';
  337. export declare type FormattedNumberPart = {
  338. type: FormattedNumberPartType;
  339. value: string;
  340. };
  341. export declare type FormattedNumberPartType = 'currency' | 'decimal' | 'fraction' | 'group' | 'infinity' | 'integer' | 'literal' | 'minusSign' | 'nan' | 'plusSign' | 'percentSign';
  342. export declare const getAdditionalMeta: () => MetaInfo | null;
  343. export declare function getDevToolsHook(): IntlifyDevToolsEmitter | null;
  344. export declare const getFallbackContext: () => CoreContext | null;
  345. /* Excluded from this release type: getLocale */
  346. export declare function getWarnMessage(code: CoreWarnCodes, ...args: unknown[]): string;
  347. /* Excluded from this release type: handleMissing */
  348. export declare function initI18nDevTools(i18n: unknown, version: string, meta?: Record<string, unknown>): void;
  349. declare type IntlifyDevToolsEmitter = Emittable<IntlifyDevToolsEmitterHooks>;
  350. declare type IntlifyDevToolsEmitterHooks = {
  351. [IntlifyDevToolsHooks.I18nInit]: IntlifyDevToolsHookPayloads[IntlifyDevToolsHooks.I18nInit];
  352. [IntlifyDevToolsHooks.FunctionTranslate]: IntlifyDevToolsHookPayloads[IntlifyDevToolsHooks.FunctionTranslate];
  353. };
  354. declare type IntlifyDevToolsHookPayloads = {
  355. [IntlifyDevToolsHooks.I18nInit]: {
  356. timestamp: number;
  357. i18n: unknown;
  358. version: string;
  359. } & AdditionalPayloads;
  360. [IntlifyDevToolsHooks.FunctionTranslate]: {
  361. timestamp: number;
  362. message: string | number;
  363. key: string;
  364. locale: string;
  365. format?: string;
  366. } & AdditionalPayloads;
  367. };
  368. declare const enum IntlifyDevToolsHooks {
  369. I18nInit = "i18n:init",
  370. FunctionTranslate = "function:translate"
  371. }
  372. /* Excluded from this release type: isAlmostSameLocale */
  373. export declare type IsEmptyObject<T> = IsNever<keyof T> extends true ? true : false;
  374. /* Excluded from this release type: isImplicitFallback */
  375. export declare const isMessageAST: (val: unknown) => val is ResourceNode;
  376. export declare const isMessageFunction: <T>(val: unknown) => val is MessageFunction<T>;
  377. export declare type IsNever<T> = [T] extends [never] ? true : false;
  378. /* Excluded from this release type: isTranslateFallbackWarn */
  379. /* Excluded from this release type: isTranslateMissingWarn */
  380. export declare type IsUnion<T, B = T> = T extends B ? [B] extends [T] ? false : true : never;
  381. export declare type LastInUnion<U> = UnionToIntersection<U extends unknown ? (x: U) => 0 : never> extends (x: infer L) => 0 ? L : never;
  382. /** @VueI18nGeneral */
  383. export declare type LinkedModifiers<T = string> = {
  384. [key: string]: LinkedModify<T>;
  385. };
  386. export declare type LinkedModify<T = string> = (value: T, type: string) => MessageType<T>;
  387. export declare interface LinkedOptions {
  388. /**
  389. * The message type of linked message
  390. */
  391. type?: string;
  392. /**
  393. * The modifier of linked message
  394. */
  395. modifier?: string;
  396. }
  397. /** @VueI18nGeneral */
  398. export declare type Locale = string;
  399. /** @VueI18nGeneral */
  400. export declare interface LocaleDetector<Args extends any[] = any[]> {
  401. (...args: Args): Locale | Promise<Locale>;
  402. resolvedOnce?: boolean;
  403. }
  404. /**
  405. * The locale fallbacker
  406. *
  407. * @VueI18nGeneral
  408. */
  409. export declare type LocaleFallbacker = <Message = string>(ctx: CoreContext<Message>, fallback: FallbackLocale, start: Locale) => Locale[];
  410. export declare type LocaleMatcher = 'lookup' | 'best fit';
  411. /** @VueI18nGeneral */
  412. export declare type LocaleMessage<Message = string> = Record<string, LocaleMessageValue<Message>>;
  413. /** @VueI18nGeneral */
  414. export declare type LocaleMessageDictionary<T, Message = string> = {
  415. [K in keyof T]: LocaleMessageType<T[K], Message>;
  416. };
  417. /** @VueI18nGeneral */
  418. export declare type LocaleMessages<Schema, Locales = Locale, Message = string> = LocaleRecord<UnionToTuple<Locales>, Schema>;
  419. /** @VueI18nGeneral */
  420. export declare type LocaleMessageType<T, Message = string> = T extends string ? string : T extends () => Promise<infer P> ? LocaleMessageDictionary<P, Message> : T extends (...args: infer Arguments) => any ? (...args: Arguments) => ReturnType<T> : T extends Record<string, unknown> ? LocaleMessageDictionary<T, Message> : T extends Array<T> ? {
  421. [K in keyof T]: T[K];
  422. } : T;
  423. /** @VueI18nGeneral */
  424. export declare type LocaleMessageValue<Message = string> = LocaleMessageDictionary<any, Message> | string;
  425. /** @VueI18nGeneral */
  426. export declare interface LocaleOptions<Locales = Locale> {
  427. /**
  428. * @remarks
  429. * The locale of localization
  430. */
  431. locale?: Locales | LocaleDetector;
  432. }
  433. export declare type LocaleParams<T, Default = 'en-US'> = T extends IsUnion<T> ? {
  434. messages: T;
  435. datetimeFormats: T;
  436. numberFormats: T;
  437. } : T extends {
  438. messages?: infer M;
  439. datetimeFormats?: infer D;
  440. numberFormats?: infer N;
  441. } ? {
  442. messages: LocaleParamsType<M, Default>;
  443. datetimeFormats: LocaleParamsType<D, Default>;
  444. numberFormats: LocaleParamsType<N, Default>;
  445. } : T extends string ? {
  446. messages: T;
  447. datetimeFormats: T;
  448. numberFormats: T;
  449. } : {
  450. messages: Default;
  451. datetimeFormats: Default;
  452. numberFormats: Default;
  453. };
  454. declare type LocaleParamsType<T, R> = T extends IsUnion<T> ? T : T extends string ? T : R;
  455. export declare type LocaleRecord<T extends any[], R> = {
  456. [K in T[number]]: R;
  457. };
  458. /**
  459. * The message compiler
  460. *
  461. * @param message - A resolved message that ususally will be passed the string. if you can transform to it with bundler, will be passed the AST.
  462. * @param context - A message context {@link MessageCompilerContext}
  463. *
  464. * @returns A {@link MessageFunction}
  465. *
  466. * @VueI18nGeneral
  467. */
  468. export declare type MessageCompiler<Message = string, MessageSource = string | ResourceNode> = (message: MessageSource, context: MessageCompilerContext) => MessageFunction<Message>;
  469. /**
  470. * The context that will pass the message compiler.
  471. *
  472. * @VueI18nGeneral
  473. */
  474. export declare type MessageCompilerContext = Pick<CompileOptions, 'onError' | 'onCacheKey' | 'onWarn'> & {
  475. /**
  476. * Whether to allow the use locale messages of HTML formatting.
  477. */
  478. warnHtmlMessage?: boolean;
  479. /**
  480. * The resolved locale message key
  481. */
  482. key: string;
  483. /**
  484. * The locale
  485. */
  486. locale: Locale;
  487. };
  488. /**
  489. * The message context.
  490. *
  491. * @VueI18nGeneral
  492. */
  493. export declare interface MessageContext<T = string> {
  494. /**
  495. * Resolve message value from list.
  496. *
  497. * @param index - An index of message values.
  498. *
  499. * @returns A resolved message value.
  500. *
  501. * @example
  502. * ```js
  503. * const messages = {
  504. * en: {
  505. * greeting: ({ list }) => `hello, ${list(0)}!`
  506. * }
  507. * }
  508. * ```
  509. */
  510. list(index: number): unknown;
  511. /**
  512. * Resolve message value from named.
  513. *
  514. * @param key - A key of message value.
  515. *
  516. * @returns A resolved message value.
  517. *
  518. * @example
  519. * ```js
  520. * const messages = {
  521. * en: {
  522. * greeting: ({ named }) => `hello, ${named('name')}!`
  523. * }
  524. * }
  525. * ```
  526. */
  527. named(key: string): unknown;
  528. /**
  529. * Resolve message with plural index.
  530. *
  531. * @remarks
  532. * That's resolved with plural index with translation function.
  533. *
  534. * @param messages - the messages, that is resolved with plural index with translation function.
  535. *
  536. * @returns A resolved message.
  537. *
  538. * @example
  539. * ```js
  540. * const messages = {
  541. * en: {
  542. * car: ({ plural }) => plural(['car', 'cars']),
  543. * apple: ({ plural, named }) =>
  544. * plural([
  545. * 'no apples',
  546. * 'one apple',
  547. * `${named('count')} apples`
  548. * ])
  549. * }
  550. * }
  551. * ```
  552. */
  553. plural(messages: T[]): T;
  554. /**
  555. * Resolve linked message.
  556. *
  557. * @param key - A message key
  558. * @param modifier - A modifier
  559. *
  560. * @returns A resolve message.
  561. */
  562. linked(key: Path, modifier?: string): MessageType<T>;
  563. /**
  564. * Overloaded `linked`
  565. *
  566. * @param key - A message key
  567. * @param modifier - A modifier
  568. * @param type - A message type
  569. *
  570. * @returns A resolve message.
  571. */
  572. linked(key: Path, modifier?: string, type?: string): MessageType<T>;
  573. /**
  574. * Overloaded `linked`
  575. *
  576. * @param key - A message key
  577. * @param optoins - An {@link LinkedOptions | linked options}
  578. *
  579. * @returns A resolve message.
  580. */
  581. linked(key: Path, optoins?: LinkedOptions): MessageType<T>;
  582. /* Excluded from this release type: message */
  583. /**
  584. * The message type to be handled by the message function.
  585. *
  586. * @remarks
  587. * Usually `text`, you need to return **string** in message function.
  588. */
  589. type: string;
  590. /* Excluded from this release type: interpolate */
  591. /* Excluded from this release type: normalize */
  592. /**
  593. * The message values.
  594. *
  595. * @remarks
  596. * The message values are the argument values passed from translation fucntion, such as `$t`, `t`, or `translate`.
  597. *
  598. * @example
  599. * vue-i18n `$t` (or `t`) case:
  600. * ```html
  601. * <p>{{ $t('greeting', { name: 'DIO' }) }}</p> <!-- `{ name: 'DIO' }` is message vlaues -->
  602. * ```
  603. *
  604. * `@intlify/core` (`@intlify/core-base`) `translate` case:
  605. * ```js
  606. * translate(context, 'foo.bar', ['dio']) // `['dio']` is message values
  607. * ```
  608. */
  609. values: Record<string, unknown>;
  610. }
  611. export declare interface MessageContextOptions<T = string, N = {}> {
  612. parent?: MessageContext<T>;
  613. locale?: string;
  614. list?: unknown[];
  615. named?: NamedValue<N>;
  616. modifiers?: LinkedModifiers<T>;
  617. pluralIndex?: number;
  618. pluralRules?: PluralizationRules;
  619. messages?: MessageFunctions<T> | MessageResolveFunction<T>;
  620. processor?: MessageProcessor<T>;
  621. }
  622. /**
  623. * The Message Function.
  624. *
  625. * @param ctx - A {@link MessageContext}
  626. *
  627. * @return A resolved format message, that is string type basically.
  628. *
  629. * @VueI18nGeneral
  630. */
  631. export declare type MessageFunction<T = string> = MessageFunctionCallable | MessageFunctionInternal<T>;
  632. export declare type MessageFunctionCallable = <T = string>(ctx: MessageContext<T>) => MessageFunctionReturn<T>;
  633. export declare type MessageFunctionInternal<T = string> = {
  634. (ctx: MessageContext<T>): MessageFunctionReturn<T>;
  635. key?: string;
  636. locale?: string;
  637. source?: string;
  638. };
  639. /** @VueI18nGeneral */
  640. export declare type MessageFunctionReturn<T = string> = T extends string ? MessageType<T> : MessageType<T>[];
  641. export declare type MessageFunctions<T = string> = Record<string, MessageFunction<T>>;
  642. export declare type MessageInterpolate<T = string> = (val: unknown) => MessageType<T>;
  643. export declare type MessageNormalize<T = string> = (values: MessageType<T>[]) => MessageFunctionReturn<T>;
  644. export declare interface MessageProcessor<T = string> {
  645. type?: string;
  646. interpolate?: MessageInterpolate<T>;
  647. normalize?: MessageNormalize<T>;
  648. }
  649. export declare type MessageResolveFunction<T = string> = (key: string) => MessageFunction<T>;
  650. /** @VueI18nGeneral */
  651. export declare type MessageResolver = (obj: unknown, path: Path) => PathValue;
  652. export declare type MessageType<T = string> = T extends string ? string : StringConvertable<T>;
  653. export declare interface MetaInfo {
  654. [field: string]: unknown;
  655. }
  656. export declare const MISSING_RESOLVE_VALUE = "";
  657. /** @VueI18nGeneral */
  658. export declare type NamedValue<T = {}> = T & Record<string, unknown>;
  659. export declare const NOT_REOSLVED = -1;
  660. /**
  661. * `number` function overloads
  662. */
  663. export declare function number<Context extends CoreContext<Message, {}, {}, {}>, Message = string>(context: Context, value: number): string | number | Intl.NumberFormatPart[];
  664. export declare function number<Context extends CoreContext<Message, {}, {}, {}>, Value extends number = number, Key extends string = string, ResourceKeys extends PickupFormatKeys<Context['numberFormats']> = PickupFormatKeys<Context['numberFormats']>, Message = string>(context: Context, value: Value, keyOrOptions: Key | ResourceKeys | NumberOptions<Key | ResourceKeys, Context['locale']>): string | number | Intl.NumberFormatPart[];
  665. export declare function number<Context extends CoreContext<Message, {}, {}, {}>, Value extends number = number, Key extends string = string, ResourceKeys extends PickupFormatKeys<Context['numberFormats']> = PickupFormatKeys<Context['numberFormats']>, Message = string>(context: Context, value: Value, keyOrOptions: Key | ResourceKeys | NumberOptions<Key | ResourceKeys, Context['locale']>, locale: Context['locale']): string | number | Intl.NumberFormatPart[];
  666. export declare function number<Context extends CoreContext<Message, {}, {}, {}>, Value extends number = number, Key extends string = string, ResourceKeys extends PickupFormatKeys<Context['numberFormats']> = PickupFormatKeys<Context['numberFormats']>, Message = string>(context: Context, value: Value, keyOrOptions: Key | ResourceKeys | NumberOptions<Key | ResourceKeys, Context['locale']>, override: Intl.NumberFormatOptions): string | number | Intl.NumberFormatPart[];
  667. export declare function number<Context extends CoreContext<Message, {}, {}, {}>, Value extends number = number, Key extends string = string, ResourceKeys extends PickupFormatKeys<Context['numberFormats']> = PickupFormatKeys<Context['numberFormats']>, Message = string>(context: Context, value: Value, keyOrOptions: Key | ResourceKeys | NumberOptions<Key | ResourceKeys, Context['locale']>, locale: Context['locale'], override: Intl.NumberFormatOptions): string | number | Intl.NumberFormatPart[];
  668. /* Excluded from this release type: NUMBER_FORMAT_OPTIONS_KEYS */
  669. export declare type NumberFormat = {
  670. [key: string]: NumberFormatOptions;
  671. };
  672. export declare type NumberFormatOptions = Intl.NumberFormatOptions | SpecificNumberFormatOptions | CurrencyNumberFormatOptions;
  673. export declare type NumberFormats<Schema = NumberFormat, Locales = Locale> = LocaleRecord<UnionToTuple<Locales>, Schema>;
  674. export declare type NumberFormatToPartsResult = {
  675. [index: number]: FormattedNumberPart;
  676. };
  677. /**
  678. * # number
  679. *
  680. * ## usages
  681. * // for example `context.numberFormats` below
  682. * 'en-US': {
  683. * 'currency': {
  684. * style: 'currency', currency: 'USD', currencyDisplay: 'symbol'
  685. * }
  686. * },
  687. * 'ja-JP: { ... }
  688. *
  689. * // value only
  690. * number(context, value)
  691. *
  692. * // key argument
  693. * number(context, value, 'currency')
  694. *
  695. * // key & locale argument
  696. * number(context, value, 'currency', 'ja-JP')
  697. *
  698. * // object sytle argument
  699. * number(context, value, { key: 'currency', locale: 'ja-JP' })
  700. *
  701. * // suppress localize miss warning option, override context.missingWarn
  702. * number(context, value, { key: 'currency', locale: 'ja-JP', missingWarn: false })
  703. *
  704. * // suppress localize fallback warning option, override context.fallbackWarn
  705. * number(context, value, { key: 'currency', locale: 'ja-JP', fallbackWarn: false })
  706. *
  707. * // if you specify `part` options, you can get an array of objects containing the formatted number in parts
  708. * number(context, value, { key: 'currenty', part: true })
  709. *
  710. * // orverride context.numberFormats[locale] options with functino options
  711. * number(cnotext, value, 'currency', { year: '2-digit' })
  712. * number(cnotext, value, 'currency', 'ja-JP', { year: '2-digit' })
  713. * number(context, value, { key: 'currenty', locale: 'ja-JP', part: true, year: '2-digit'})
  714. */
  715. /**
  716. * Number Options
  717. *
  718. * @remarks
  719. * Options for Number formatting API
  720. *
  721. * @VueI18nGeneral
  722. */
  723. export declare interface NumberOptions<Key = string, Locales = Locale> extends Intl.NumberFormatOptions, LocaleOptions<Locales> {
  724. /**
  725. * @remarks
  726. * The target format key
  727. */
  728. key?: Key;
  729. /**
  730. * @remarks
  731. * Whether suppress warnings outputted when localization fails
  732. */
  733. missingWarn?: boolean;
  734. /**
  735. * @remarks
  736. * Whether do resolve on format keys when your language lacks a formatting for a key
  737. */
  738. fallbackWarn?: boolean;
  739. /**
  740. * @remarks
  741. * Whether to use [Intel.NumberFormat#formatToParts](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts)
  742. */
  743. part?: boolean;
  744. }
  745. /**
  746. * Parse a string path into an array of segments
  747. */
  748. export declare function parse(path: Path): string[] | undefined;
  749. /* Excluded from this release type: parseDateTimeArgs */
  750. /* Excluded from this release type: parseNumberArgs */
  751. /* Excluded from this release type: parseTranslateArgs */
  752. /** @VueI18nGeneral */
  753. export declare type Path = string;
  754. /** @VueI18nGeneral */
  755. export declare type PathValue = string | number | boolean | Function | null | {
  756. [key: string]: PathValue;
  757. } | PathValue[];
  758. export declare type PickupFallbackLocales<T extends any[]> = T[number] | `${T[number]}!`;
  759. export declare type PickupFormatKeys<T extends Record<string, any>, K = keyof T> = K extends string ? ResourceFormatPath<T[K]> : never;
  760. export declare type PickupFormatPathKeys<T extends object> = ResourceFormatPath<T>;
  761. export declare type PickupKeys<T extends Record<string, any>, K = keyof T> = K extends string ? ResourcePath<T[K]> : never;
  762. export declare type PickupLocales<T extends Record<string, any>, K = keyof T> = K extends string ? K : never;
  763. export declare type PickupPaths<T extends object> = ResourcePath<T>;
  764. export declare type PluralizationProps = {
  765. n?: number;
  766. count?: number;
  767. };
  768. export declare type PluralizationRule = (choice: number, choicesLength: number, orgRule?: PluralizationRule) => number;
  769. /** @VueI18nGeneral */
  770. export declare type PluralizationRules = {
  771. [locale: string]: PluralizationRule;
  772. };
  773. /** @VueI18nGeneral */
  774. export declare type PostTranslationHandler<Message = string> = (translated: MessageFunctionReturn<Message>, key: string) => MessageFunctionReturn<Message>;
  775. /**
  776. * Register the locale fallbacker
  777. *
  778. * @param fallbacker - A {@link LocaleFallbacker} function
  779. *
  780. * @VueI18nGeneral
  781. */
  782. export declare function registerLocaleFallbacker(fallbacker: LocaleFallbacker): void;
  783. export declare function registerMessageCompiler<Message>(compiler: MessageCompiler<Message, string | ResourceNode>): void;
  784. /**
  785. * Register the message resolver
  786. *
  787. * @param resolver - A {@link MessageResolver} function
  788. *
  789. * @VueI18nGeneral
  790. */
  791. export declare function registerMessageResolver(resolver: MessageResolver): void;
  792. export declare type RemovedIndexResources<T> = RemoveIndexSignature<{
  793. [K in keyof T]: T[K];
  794. }>;
  795. export declare type RemoveIndexSignature<T> = {
  796. [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
  797. };
  798. /* Excluded from this release type: resolveLocale */
  799. /**
  800. * message resolver
  801. *
  802. * @remarks
  803. * Resolves messages. messages with a hierarchical structure such as objects can be resolved. This resolver is used in VueI18n as default.
  804. *
  805. * @param obj - A target object to be resolved with path
  806. * @param path - A {@link Path | path} to resolve the value of message
  807. *
  808. * @returns A resolved {@link PathValue | path value}
  809. *
  810. * @VueI18nGeneral
  811. */
  812. export declare function resolveValue(obj: unknown, path: Path): PathValue;
  813. /**
  814. * key-value message resolver
  815. *
  816. * @remarks
  817. * Resolves messages with the key-value structure. Note that messages with a hierarchical structure such as objects cannot be resolved
  818. *
  819. * @param obj - A target object to be resolved with path
  820. * @param path - A {@link Path | path} to resolve the value of message
  821. *
  822. * @returns A resolved {@link PathValue | path value}
  823. *
  824. * @VueI18nGeneral
  825. */
  826. export declare function resolveWithKeyValue(obj: unknown, path: Path): PathValue;
  827. export declare type ResourceFormatPath<T> = _ResourceFormatPath<T> extends string | keyof T ? _ResourceFormatPath<T> : keyof T;
  828. declare type _ResourceFormatPath<T> = __ResourceFormatPath<T, keyof T> | keyof T;
  829. export { ResourceNode }
  830. export declare type ResourcePath<T> = _ResourcePath<T> extends string | keyof T ? _ResourcePath<T> : keyof T;
  831. export declare type _ResourcePath<T> = __ResourcePath<T, keyof T> | keyof T;
  832. export declare type ResourceValue<T, P extends ResourcePath<T>> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? Rest extends ResourcePath<T[Key]> ? ResourceValue<T[Key], Rest> : never : never : P extends keyof T ? T[P] : never;
  833. export declare type SchemaParams<T, Message = string> = T extends readonly any[] ? {
  834. message: First<T>;
  835. datetime: DateTimeFormat;
  836. number: NumberFormat;
  837. } : T extends {
  838. message?: infer M;
  839. datetime?: infer D;
  840. number?: infer N;
  841. } ? {
  842. message: M extends LocaleMessage<Message> ? M : LocaleMessage<Message>;
  843. datetime: D extends DateTimeFormat ? D : DateTimeFormat;
  844. number: N extends NumberFormat ? N : NumberFormat;
  845. } : {
  846. message: LocaleMessage<Message>;
  847. datetime: DateTimeFormat;
  848. number: NumberFormat;
  849. };
  850. export declare const setAdditionalMeta: (meta: MetaInfo | null) => void;
  851. export declare function setDevToolsHook(hook: IntlifyDevToolsEmitter | null): void;
  852. export declare const setFallbackContext: (context: CoreContext | null) => void;
  853. export declare interface SpecificDateTimeFormatOptions extends Intl.DateTimeFormatOptions {
  854. year?: DateTimeDigital;
  855. month?: DateTimeDigital | DateTimeHumanReadable;
  856. day?: DateTimeDigital;
  857. hour?: DateTimeDigital;
  858. minute?: DateTimeDigital;
  859. second?: DateTimeDigital;
  860. weekday?: DateTimeHumanReadable;
  861. era?: DateTimeHumanReadable;
  862. timeZoneName?: 'long' | 'short';
  863. localeMatcher?: LocaleMatcher;
  864. formatMatcher?: FormatMatcher;
  865. }
  866. export declare interface SpecificNumberFormatOptions extends Intl.NumberFormatOptions {
  867. style?: 'decimal' | 'percent';
  868. currency?: string;
  869. currencyDisplay?: CurrencyDisplay;
  870. localeMatcher?: LocaleMatcher;
  871. formatMatcher?: FormatMatcher;
  872. }
  873. declare type StringConvertable<T> = ExtractToStringKey<T> extends never ? unknown : ExtractToStringFunction<T> extends (...args: any) => string ? T : unknown;
  874. /**
  875. * TODO:
  876. * this type should be used (refactored) at `translate` type definition
  877. * (Unfortunately, using this type will result in key completion failure due to type mismatch...)
  878. */
  879. /**
  880. * `translate` function overloads
  881. */
  882. export declare function translate<Context extends CoreContext<Message>, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources<DefineCoreLocaleMessage> = RemovedIndexResources<DefineCoreLocaleMessage>, CoreMessages = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  883. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  884. }> : never, ContextMessages = IsEmptyObject<Context['messages']> extends false ? PickupKeys<Context['messages']> : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever<CoreMessages> extends false ? IsNever<ContextMessages> extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever<ContextMessages> extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction<Message>, plural: number): MessageFunctionReturn<Message> | number;
  885. export declare function translate<Context extends CoreContext<Message, {}, {}, {}>, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources<DefineCoreLocaleMessage> = RemovedIndexResources<DefineCoreLocaleMessage>, CoreMessages = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  886. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  887. }> : never, ContextMessages = IsEmptyObject<Context['messages']> extends false ? PickupKeys<Context['messages']> : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever<CoreMessages> extends false ? IsNever<ContextMessages> extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever<ContextMessages> extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction<Message>): MessageFunctionReturn<Message> | number;
  888. export declare function translate<Context extends CoreContext<Message, {}, {}, {}>, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources<DefineCoreLocaleMessage> = RemovedIndexResources<DefineCoreLocaleMessage>, CoreMessages = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  889. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  890. }> : never, ContextMessages = IsEmptyObject<Context['messages']> extends false ? PickupKeys<Context['messages']> : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever<CoreMessages> extends false ? IsNever<ContextMessages> extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever<ContextMessages> extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction<Message>, plural: number): MessageFunctionReturn<Message> | number;
  891. export declare function translate<Context extends CoreContext<Message, {}, {}, {}>, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources<DefineCoreLocaleMessage> = RemovedIndexResources<DefineCoreLocaleMessage>, CoreMessages = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  892. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  893. }> : never, ContextMessages = IsEmptyObject<Context['messages']> extends false ? PickupKeys<Context['messages']> : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever<CoreMessages> extends false ? IsNever<ContextMessages> extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever<ContextMessages> extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction<Message>, plural: number, options: TranslateOptions<Context['locale']>): MessageFunctionReturn<Message> | number;
  894. export declare function translate<Context extends CoreContext<Message, {}, {}, {}>, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources<DefineCoreLocaleMessage> = RemovedIndexResources<DefineCoreLocaleMessage>, CoreMessages = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  895. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  896. }> : never, ContextMessages = IsEmptyObject<Context['messages']> extends false ? PickupKeys<Context['messages']> : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever<CoreMessages> extends false ? IsNever<ContextMessages> extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever<ContextMessages> extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction<Message>, defaultMsg: string): MessageFunctionReturn<Message> | number;
  897. export declare function translate<Context extends CoreContext<Message, {}, {}, {}>, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources<DefineCoreLocaleMessage> = RemovedIndexResources<DefineCoreLocaleMessage>, CoreMessages = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  898. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  899. }> : never, ContextMessages = IsEmptyObject<Context['messages']> extends false ? PickupKeys<Context['messages']> : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever<CoreMessages> extends false ? IsNever<ContextMessages> extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever<ContextMessages> extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction<Message>, defaultMsg: string, options: TranslateOptions<Context['locale']>): MessageFunctionReturn<Message> | number;
  900. export declare function translate<Context extends CoreContext<Message, {}, {}, {}>, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources<DefineCoreLocaleMessage> = RemovedIndexResources<DefineCoreLocaleMessage>, CoreMessages = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  901. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  902. }> : never, ContextMessages = IsEmptyObject<Context['messages']> extends false ? PickupKeys<Context['messages']> : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever<CoreMessages> extends false ? IsNever<ContextMessages> extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever<ContextMessages> extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction<Message>, list: unknown[]): MessageFunctionReturn<Message> | number;
  903. export declare function translate<Context extends CoreContext<Message, {}, {}, {}>, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources<DefineCoreLocaleMessage> = RemovedIndexResources<DefineCoreLocaleMessage>, CoreMessages = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  904. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  905. }> : never, ContextMessages = IsEmptyObject<Context['messages']> extends false ? PickupKeys<Context['messages']> : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever<CoreMessages> extends false ? IsNever<ContextMessages> extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever<ContextMessages> extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction<Message>, list: unknown[], plural: number): MessageFunctionReturn<Message> | number;
  906. export declare function translate<Context extends CoreContext<Message, {}, {}, {}>, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources<DefineCoreLocaleMessage> = RemovedIndexResources<DefineCoreLocaleMessage>, CoreMessages = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  907. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  908. }> : never, ContextMessages = IsEmptyObject<Context['messages']> extends false ? PickupKeys<Context['messages']> : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever<CoreMessages> extends false ? IsNever<ContextMessages> extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever<ContextMessages> extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction<Message>, list: unknown[], defaultMsg: string): MessageFunctionReturn<Message> | number;
  909. export declare function translate<Context extends CoreContext<Message, {}, {}, {}>, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources<DefineCoreLocaleMessage> = RemovedIndexResources<DefineCoreLocaleMessage>, CoreMessages = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  910. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  911. }> : never, ContextMessages = IsEmptyObject<Context['messages']> extends false ? PickupKeys<Context['messages']> : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever<CoreMessages> extends false ? IsNever<ContextMessages> extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever<ContextMessages> extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction<Message>, list: unknown[], options: TranslateOptions<Context['locale']>): MessageFunctionReturn<Message> | number;
  912. export declare function translate<Context extends CoreContext<Message, {}, {}, {}>, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources<DefineCoreLocaleMessage> = RemovedIndexResources<DefineCoreLocaleMessage>, CoreMessages = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  913. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  914. }> : never, ContextMessages = IsEmptyObject<Context['messages']> extends false ? PickupKeys<Context['messages']> : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever<CoreMessages> extends false ? IsNever<ContextMessages> extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever<ContextMessages> extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction<Message>, named: NamedValue): MessageFunctionReturn<Message> | number;
  915. export declare function translate<Context extends CoreContext<Message, {}, {}, {}>, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources<DefineCoreLocaleMessage> = RemovedIndexResources<DefineCoreLocaleMessage>, CoreMessages = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  916. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  917. }> : never, ContextMessages = IsEmptyObject<Context['messages']> extends false ? PickupKeys<Context['messages']> : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever<CoreMessages> extends false ? IsNever<ContextMessages> extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever<ContextMessages> extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction<Message>, named: NamedValue, plural: number): MessageFunctionReturn<Message> | number;
  918. export declare function translate<Context extends CoreContext<Message, {}, {}, {}>, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources<DefineCoreLocaleMessage> = RemovedIndexResources<DefineCoreLocaleMessage>, CoreMessages = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  919. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  920. }> : never, ContextMessages = IsEmptyObject<Context['messages']> extends false ? PickupKeys<Context['messages']> : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever<CoreMessages> extends false ? IsNever<ContextMessages> extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever<ContextMessages> extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction<Message>, named: NamedValue, defaultMsg: string): MessageFunctionReturn<Message> | number;
  921. export declare function translate<Context extends CoreContext<Message, {}, {}, {}>, Key extends string = string, DefinedLocaleMessage extends RemovedIndexResources<DefineCoreLocaleMessage> = RemovedIndexResources<DefineCoreLocaleMessage>, CoreMessages = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  922. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  923. }> : never, ContextMessages = IsEmptyObject<Context['messages']> extends false ? PickupKeys<Context['messages']> : never, ResourceKeys extends CoreMessages | ContextMessages = IsNever<CoreMessages> extends false ? IsNever<ContextMessages> extends false ? CoreMessages | ContextMessages : CoreMessages : IsNever<ContextMessages> extends false ? ContextMessages : never, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction<Message>, named: NamedValue, options: TranslateOptions<Context['locale']>): MessageFunctionReturn<Message> | number;
  924. export declare const translateDevTools: (payloads: IntlifyDevToolsHookPayloads[IntlifyDevToolsHooks]) => void | null;
  925. /**
  926. * # translate
  927. *
  928. * ## usages:
  929. * // for example, locale messages key
  930. * { 'foo.bar': 'hi {0} !' or 'hi {name} !' }
  931. *
  932. * // no argument, context & path only
  933. * translate(context, 'foo.bar')
  934. *
  935. * // list argument
  936. * translate(context, 'foo.bar', ['kazupon'])
  937. *
  938. * // named argument
  939. * translate(context, 'foo.bar', { name: 'kazupon' })
  940. *
  941. * // plural choice number
  942. * translate(context, 'foo.bar', 2)
  943. *
  944. * // plural choice number with name argument
  945. * translate(context, 'foo.bar', { name: 'kazupon' }, 2)
  946. *
  947. * // default message argument
  948. * translate(context, 'foo.bar', 'this is default message')
  949. *
  950. * // default message with named argument
  951. * translate(context, 'foo.bar', { name: 'kazupon' }, 'Hello {name} !')
  952. *
  953. * // use key as default message
  954. * translate(context, 'hi {0} !', ['kazupon'], { default: true })
  955. *
  956. * // locale option, override context.locale
  957. * translate(context, 'foo.bar', { name: 'kazupon' }, { locale: 'ja' })
  958. *
  959. * // suppress localize miss warning option, override context.missingWarn
  960. * translate(context, 'foo.bar', { name: 'kazupon' }, { missingWarn: false })
  961. *
  962. * // suppress localize fallback warning option, override context.fallbackWarn
  963. * translate(context, 'foo.bar', { name: 'kazupon' }, { fallbackWarn: false })
  964. *
  965. * // escape parameter option, override context.escapeParameter
  966. * translate(context, 'foo.bar', { name: 'kazupon' }, { escapeParameter: true })
  967. */
  968. /**
  969. * Translate Options
  970. *
  971. * @remarks
  972. * Options for Translation API
  973. *
  974. * @VueI18nGeneral
  975. */
  976. export declare interface TranslateOptions<Locales = Locale> extends LocaleOptions<Locales> {
  977. /**
  978. * @remarks
  979. * List interpolation
  980. */
  981. list?: unknown[];
  982. /**
  983. * @remarks
  984. * Named interpolation
  985. */
  986. named?: NamedValue;
  987. /**
  988. * @remarks
  989. * Plulralzation choice number
  990. */
  991. plural?: number;
  992. /**
  993. * @remarks
  994. * Default message when is occurred translation missing
  995. */
  996. default?: string | boolean;
  997. /**
  998. * @remarks
  999. * Whether suppress warnings outputted when localization fails
  1000. */
  1001. missingWarn?: boolean;
  1002. /**
  1003. * @remarks
  1004. * Whether do template interpolation on translation keys when your language lacks a translation for a key
  1005. */
  1006. fallbackWarn?: boolean;
  1007. /**
  1008. * @remarks
  1009. * Whether do escape parameter for list or named interpolation values
  1010. */
  1011. escapeParameter?: boolean;
  1012. /**
  1013. * @remarks
  1014. * Whether the message has been resolved
  1015. */
  1016. resolvedMessage?: boolean;
  1017. }
  1018. export declare type UnionToIntersection<U> = (U extends any ? (arg: U) => void : never) extends (arg: infer I) => void ? I : never;
  1019. export declare type UnionToTuple<U, Last = LastInUnion<U>> = [U] extends [never] ? [] : [...UnionToTuple<Exclude<U, Last>>, Last];
  1020. /* Excluded from this release type: updateFallbackLocale */
  1021. /* Excluded from this release type: VERSION */
  1022. declare type VueDevToolsEmitter = Emittable<VueDevToolsEmitterEvents>;
  1023. declare type VueDevToolsEmitterEvents = {
  1024. [VueDevToolsTimelineEvents.COMPILE_ERROR]: VueDevToolsTimelineEventPayloads[VueDevToolsTimelineEvents.COMPILE_ERROR];
  1025. [VueDevToolsTimelineEvents.MISSING]: VueDevToolsTimelineEventPayloads[VueDevToolsTimelineEvents.MISSING];
  1026. [VueDevToolsTimelineEvents.FALBACK]: VueDevToolsTimelineEventPayloads[VueDevToolsTimelineEvents.FALBACK];
  1027. [VueDevToolsTimelineEvents.MESSAGE_RESOLVE]: VueDevToolsTimelineEventPayloads[VueDevToolsTimelineEvents.MESSAGE_RESOLVE];
  1028. [VueDevToolsTimelineEvents.MESSAGE_COMPILATION]: VueDevToolsTimelineEventPayloads[VueDevToolsTimelineEvents.MESSAGE_COMPILATION];
  1029. [VueDevToolsTimelineEvents.MESSAGE_EVALUATION]: VueDevToolsTimelineEventPayloads[VueDevToolsTimelineEvents.MESSAGE_EVALUATION];
  1030. };
  1031. declare type VueDevToolsTimelineEventPayloads = {
  1032. [VueDevToolsTimelineEvents.COMPILE_ERROR]: {
  1033. message: string;
  1034. error: string;
  1035. start?: number;
  1036. end?: number;
  1037. groupId?: string;
  1038. };
  1039. [VueDevToolsTimelineEvents.MISSING]: {
  1040. locale: Locale_2;
  1041. key: Path_2;
  1042. type: CoreMissingType_2;
  1043. groupId?: string;
  1044. };
  1045. [VueDevToolsTimelineEvents.FALBACK]: {
  1046. key: Path_2;
  1047. type: CoreMissingType_2;
  1048. from?: Locale_2;
  1049. to: Locale_2 | 'global';
  1050. groupId?: string;
  1051. };
  1052. [VueDevToolsTimelineEvents.MESSAGE_RESOLVE]: {
  1053. type: VueDevToolsTimelineEvents.MESSAGE_RESOLVE;
  1054. key: Path_2;
  1055. message: PathValue_2;
  1056. time: number;
  1057. groupId?: string;
  1058. };
  1059. [VueDevToolsTimelineEvents.MESSAGE_COMPILATION]: {
  1060. type: VueDevToolsTimelineEvents.MESSAGE_COMPILATION;
  1061. message: string | ResourceNode_2 | MessageFunction_2;
  1062. time: number;
  1063. groupId?: string;
  1064. };
  1065. [VueDevToolsTimelineEvents.MESSAGE_EVALUATION]: {
  1066. type: VueDevToolsTimelineEvents.MESSAGE_EVALUATION;
  1067. value: unknown;
  1068. time: number;
  1069. groupId?: string;
  1070. };
  1071. };
  1072. declare const enum VueDevToolsTimelineEvents {
  1073. COMPILE_ERROR = "compile-error",
  1074. MISSING = "missing",
  1075. FALBACK = "fallback",
  1076. MESSAGE_RESOLVE = "message-resolve",
  1077. MESSAGE_COMPILATION = "message-compilation",
  1078. MESSAGE_EVALUATION = "message-evaluation"
  1079. }
  1080. export { }