vue-i18n.d.ts 155 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314
  1. import type { App } from 'vue';
  2. import { CompileError } from '@intlify/core-base';
  3. import type { ComponentInternalInstance } from 'vue';
  4. import type { ComputedRef } from 'vue';
  5. import { DateTimeOptions } from '@intlify/core-base';
  6. import { FallbackLocale } from '@intlify/core-base';
  7. import type { FallbackLocales } from '@intlify/core-base';
  8. import { InjectionKey } from 'vue';
  9. import { DateTimeFormat as IntlDateTimeFormat } from '@intlify/core-base';
  10. import { DateTimeFormats as IntlDateTimeFormats } from '@intlify/core-base';
  11. import { FormatMatcher as IntlFormatMatcher } from '@intlify/core-base';
  12. import { LocaleMatcher as IntlLocaleMatcher } from '@intlify/core-base';
  13. import { NumberFormat as IntlNumberFormat } from '@intlify/core-base';
  14. import { NumberFormats as IntlNumberFormats } from '@intlify/core-base';
  15. import { IsEmptyObject } from '@intlify/core-base';
  16. import { IsNever } from '@intlify/core-base';
  17. import { LinkedModifiers } from '@intlify/core-base';
  18. import { Locale } from '@intlify/core-base';
  19. import type { LocaleMessage } from '@intlify/core-base';
  20. import { LocaleMessageDictionary } from '@intlify/core-base';
  21. import { LocaleMessages } from '@intlify/core-base';
  22. import { LocaleMessageType } from '@intlify/core-base';
  23. import { LocaleMessageValue } from '@intlify/core-base';
  24. import type { LocaleParams } from '@intlify/core-base';
  25. import { MessageCompiler } from '@intlify/core-base';
  26. import { MessageCompilerContext } from '@intlify/core-base';
  27. import { MessageContext } from '@intlify/core-base';
  28. import { MessageFunction } from '@intlify/core-base';
  29. import { MessageFunctions } from '@intlify/core-base';
  30. import { MessageResolver } from '@intlify/core-base';
  31. import { NamedValue } from '@intlify/core-base';
  32. import { NumberOptions } from '@intlify/core-base';
  33. import type { ObjectDirective } from 'vue';
  34. import { Path } from '@intlify/core-base';
  35. import { PathValue } from '@intlify/core-base';
  36. import type { PickupFormatKeys } from '@intlify/core-base';
  37. import { PickupFormatPathKeys } from '@intlify/core-base';
  38. import { PickupKeys } from '@intlify/core-base';
  39. import type { PickupLocales } from '@intlify/core-base';
  40. import { PickupPaths } from '@intlify/core-base';
  41. import { PluralizationRule } from '@intlify/core-base';
  42. import type { PluralizationRules } from '@intlify/core-base';
  43. import { PostTranslationHandler } from '@intlify/core-base';
  44. import type { RemoveIndexSignature } from '@intlify/core-base';
  45. import type { ResourceNode } from '@intlify/core-base';
  46. import type { ResourcePath } from '@intlify/core-base';
  47. import type { ResourceValue } from '@intlify/core-base';
  48. import type { SchemaParams } from '@intlify/core-base';
  49. import { TranslateOptions } from '@intlify/core-base';
  50. import type { VNode } from 'vue';
  51. import type { VNodeProps } from 'vue';
  52. import type { WritableComputedRef } from 'vue';
  53. /**
  54. * BaseFormat Props for Components that is offered Vue I18n
  55. *
  56. * @remarks
  57. * The interface definitions of the underlying props of components such as Translation, DatetimeFormat, and NumberFormat.
  58. *
  59. * @VueI18nComponent
  60. */
  61. export declare interface BaseFormatProps {
  62. /**
  63. * @remarks
  64. * Used to wrap the content that is distribute in the slot. If omitted, the slot content is treated as Fragments.
  65. *
  66. * You can specify a string-based tag name, such as `p`, or the object for which the component is defined.
  67. */
  68. tag?: string | object;
  69. /**
  70. * @remarks
  71. * Specifies the locale to be used for the component.
  72. *
  73. * If specified, the global scope or the locale of the parent scope of the target component will not be overridden and the specified locale will be used.
  74. */
  75. locale?: Locale;
  76. /**
  77. * @remarks
  78. * Specifies the scope to be used in the target component.
  79. *
  80. * You can specify either `global` or `parent`.
  81. *
  82. * If `global` is specified, global scope is used, else then `parent` is specified, the scope of the parent of the target component is used.
  83. *
  84. * If the parent is a global scope, the global scope is used, if it's a local scope, the local scope is used.
  85. */
  86. scope?: ComponentI18nScope;
  87. /**
  88. * @remarks
  89. * A composer instance with an existing scope.
  90. *
  91. * This option takes precedence over the `scope` option.
  92. */
  93. i18n?: Composer;
  94. }
  95. /**
  96. * Cast to VueI18n legacy compatible type
  97. *
  98. * @remarks
  99. * This API is provided only with [vue-i18n-bridge](https://vue-i18n.intlify.dev/guide/migration/ways.html#what-is-vue-i18n-bridge).
  100. *
  101. * The purpose of this function is to convert an {@link I18n} instance created with {@link createI18n | createI18n(legacy: true)} into a `vue-i18n@v8.x` compatible instance of `new VueI18n` in a TypeScript environment.
  102. *
  103. * @param i18n - An instance of {@link I18n}
  104. * @returns A i18n instance which is casted to {@link VueI18n} type
  105. *
  106. * @VueI18nTip
  107. * :new: provided by **vue-i18n-bridge only**
  108. *
  109. * @VueI18nGeneral
  110. */
  111. export declare const castToVueI18n: (i18n: I18n) => VueI18n<{}, {}, {}, string, never, string, Composer<{}, {}, {}, string, never, string>> & {
  112. install: (Vue: any, options?: any) => void;
  113. };
  114. export declare type Choice = number;
  115. export { CompileError }
  116. export declare type ComponentI18nScope = Exclude<I18nScope, 'local'>;
  117. /**
  118. * Composer interfaces
  119. *
  120. * @remarks
  121. * This is the interface for being used for Vue 3 Composition API.
  122. *
  123. * @VueI18nComposition
  124. */
  125. export declare interface Composer<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 = OptionLocale extends Locale ? [ResourceLocales] extends [never] ? Locale : ResourceLocales : OptionLocale | ResourceLocales> extends ComposerCustom {
  126. /**
  127. * @remarks
  128. * Instance ID.
  129. */
  130. id: number;
  131. /**
  132. * @remarks
  133. * The current locale this Composer instance is using.
  134. *
  135. * If the locale contains a territory and a dialect, this locale contains an implicit fallback.
  136. *
  137. * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope)
  138. */
  139. locale: WritableComputedRef<Locales>;
  140. /**
  141. * @remarks
  142. * The current fallback locales this Composer instance is using.
  143. *
  144. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  145. */
  146. fallbackLocale: WritableComputedRef<FallbackLocales<Locales>>;
  147. /**
  148. * @remarks
  149. * Whether inherit the root level locale to the component localization locale.
  150. *
  151. * @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-2)
  152. */
  153. inheritLocale: boolean;
  154. /**
  155. * @remarks
  156. * The list of available locales in `messages` in lexical order.
  157. */
  158. readonly availableLocales: Locales[];
  159. /**
  160. * @remarks
  161. * The locale messages of localization.
  162. *
  163. * @VueI18nSee [Getting Started](../guide/)
  164. */
  165. readonly messages: ComputedRef<{
  166. [K in keyof Messages]: Messages[K];
  167. }>;
  168. /**
  169. * @remarks
  170. * The datetime formats of localization.
  171. *
  172. * @VueI18nSee [Datetime Formatting](../guide/essentials/datetime)
  173. */
  174. readonly datetimeFormats: ComputedRef<{
  175. [K in keyof DateTimeFormats]: DateTimeFormats[K];
  176. }>;
  177. /**
  178. * @remarks
  179. * The number formats of localization.
  180. *
  181. * @VueI18nSee [Number Formatting](../guide/essentials/number)
  182. */
  183. readonly numberFormats: ComputedRef<{
  184. [K in keyof NumberFormats]: NumberFormats[K];
  185. }>;
  186. /**
  187. * @remarks
  188. * Custom Modifiers for linked messages.
  189. *
  190. * @VueI18nSee [Custom Modifiers](../guide/essentials/syntax#custom-modifiers)
  191. */
  192. readonly modifiers: LinkedModifiers<VueMessageType>;
  193. /**
  194. * @remarks
  195. * A set of rules for word pluralization
  196. *
  197. * @VueI18nSee [Custom Pluralization](../guide/essentials/pluralization#custom-pluralization)
  198. */
  199. readonly pluralRules: PluralizationRules;
  200. /**
  201. * @remarks
  202. * Whether this composer instance is global or not
  203. */
  204. readonly isGlobal: boolean;
  205. /**
  206. * @remarks
  207. * Whether suppress warnings outputted when localization fails.
  208. *
  209. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  210. */
  211. missingWarn: boolean | RegExp;
  212. /**
  213. * @remarks
  214. * Whether suppress fall back warnings when localization fails.
  215. *
  216. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  217. */
  218. fallbackWarn: boolean | RegExp;
  219. /**
  220. * @remarks
  221. * Whether to fall back to root level (global scope) localization when localization fails.
  222. *
  223. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  224. */
  225. fallbackRoot: boolean;
  226. /**
  227. * @remarks
  228. * Whether suppress warnings when falling back to either `fallbackLocale` or root.
  229. *
  230. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  231. */
  232. fallbackFormat: boolean;
  233. /**
  234. * @remarks
  235. * Whether to allow the use locale messages of HTML formatting.
  236. *
  237. * If you set `false`, will check the locale messages on the Composer instance.
  238. *
  239. * If you are specified `true`, a warning will be output at console.
  240. *
  241. * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message)
  242. * @VueI18nSee [Change `warnHtmlInMessage` option default value](../guide/migration/breaking#change-warnhtmlinmessage-option-default-value)
  243. */
  244. warnHtmlMessage: boolean;
  245. /**
  246. * @remarks
  247. * Whether interpolation parameters are escaped before the message is translated.
  248. *
  249. * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message)
  250. */
  251. escapeParameter: boolean;
  252. /**
  253. * Locale message translation
  254. *
  255. * @remarks
  256. * About details functions, See the {@link ComposerTranslation}
  257. */
  258. t: ComposerTranslation<Messages, Locales, RemoveIndexSignature<{
  259. [K in keyof DefineLocaleMessage]: DefineLocaleMessage[K];
  260. }>>;
  261. /**
  262. * Resolve locale message translation
  263. *
  264. * @remarks
  265. * About details functions, See the {@link ComposerResolveLocaleMessageTranslation}
  266. */
  267. rt: ComposerResolveLocaleMessageTranslation<Locales>;
  268. /**
  269. * Datetime formatting
  270. *
  271. * @remarks
  272. * About details functions, See the {@link ComposerDateTimeFormatting}
  273. */
  274. d: ComposerDateTimeFormatting<DateTimeFormats, Locales, RemoveIndexSignature<{
  275. [K in keyof DefineDateTimeFormat]: DefineDateTimeFormat[K];
  276. }>>;
  277. /**
  278. * Number Formatting
  279. *
  280. * @remarks
  281. * About details functions, See the {@link ComposerNumberFormatting}
  282. */
  283. n: ComposerNumberFormatting<NumberFormats, Locales, RemoveIndexSignature<{
  284. [K in keyof DefineNumberFormat]: DefineNumberFormat[K];
  285. }>>;
  286. /**
  287. * Translation locale message exist
  288. *
  289. * @remarks
  290. * whether do exist locale message on Composer instance [messages](composition#messages).
  291. *
  292. * If you specified `locale`, check the locale messages of `locale`.
  293. *
  294. * @param key - A target locale message key
  295. * @param locale - A locale, it will be used over than global scope or local scope
  296. *
  297. * @returns If found locale message, `true`, else `false`
  298. */
  299. te<Str extends string, Key extends PickupKeys<Messages> = PickupKeys<Messages>>(key: Str | Key, locale?: Locales): boolean;
  300. /**
  301. * Locale messages getter
  302. *
  303. * @remarks
  304. * If [UseI18nScope](general#usei18nscope) `'local'` or Some [UseI18nOptions](composition#usei18noptions) are specified at `useI18n`, it’s translated in preferentially local scope locale messages than global scope locale messages.
  305. *
  306. * Based on the current `locale`, locale messages will be returned from Composer instance messages.
  307. *
  308. * If you change the `locale`, the locale messages returned will also correspond to the locale.
  309. *
  310. * If there are no locale messages for the given `key` in the composer instance messages, they will be returned with [fallbacking](../guide/essentials/fallback).
  311. *
  312. * @VueI18nWarning
  313. * You need to use `rt` for the locale message returned by `tm`. see the [rt](composition#rt-message) details.
  314. *
  315. * @example
  316. * template block:
  317. * ```html
  318. * <div class="container">
  319. * <template v-for="content in tm('contents')">
  320. * <h2>{{ rt(content.title) }}</h2>
  321. * <p v-for="paragraph in content.paragraphs">
  322. * {{ rt(paragraph) }}
  323. * </p>
  324. * </template>
  325. * </div>
  326. * ```
  327. * script block:
  328. * ```js
  329. * import { defineComponent } from 'vue
  330. * import { useI18n } from 'vue-i18n'
  331. *
  332. * export default defineComponent({
  333. * setup() {
  334. * const { rt, tm } = useI18n({
  335. * messages: {
  336. * en: {
  337. * contents: [
  338. * {
  339. * title: 'Title1',
  340. * // ...
  341. * paragraphs: [
  342. * // ...
  343. * ]
  344. * }
  345. * ]
  346. * }
  347. * }
  348. * // ...
  349. * })
  350. * // ...
  351. * return { ... , rt, tm }
  352. * }
  353. * })
  354. * ```
  355. *
  356. * @param key - A target locale message key
  357. *
  358. * @return Locale messages
  359. */
  360. tm<Key extends string, ResourceKeys extends PickupKeys<Messages> = PickupKeys<Messages>, Locale extends PickupLocales<NonNullable<Messages>> = PickupLocales<NonNullable<Messages>>, Target = IsEmptyObject<Messages> extends false ? NonNullable<Messages>[Locale] : RemoveIndexSignature<{
  361. [K in keyof DefineLocaleMessage]: DefineLocaleMessage[K];
  362. }>, Return = ResourceKeys extends ResourcePath<Target> ? ResourceValue<Target, ResourceKeys> : Record<string, any>>(key: Key | ResourceKeys): Return;
  363. /**
  364. * Get locale message
  365. *
  366. * @remarks
  367. * get locale message from Composer instance [messages](composition#messages).
  368. *
  369. * @param locale - A target locale
  370. *
  371. * @typeParam MessageSchema - The locale message schema, default `never`
  372. *
  373. * @returns Locale messages
  374. */
  375. getLocaleMessage<MessageSchema extends LocaleMessage<VueMessageType> = never, LocaleSchema extends string = string, Locale extends PickupLocales<NonNullable<Messages>> = PickupLocales<NonNullable<Messages>>, Return = IsNever<MessageSchema> extends true ? IsEmptyObject<Messages> extends true ? RemoveIndexSignature<{
  376. [K in keyof DefineLocaleMessage]: DefineLocaleMessage[K];
  377. }> : NonNullable<Messages>[Locale] : MessageSchema>(locale: LocaleSchema | Locale): Return;
  378. /**
  379. * Set locale message
  380. *
  381. * @remarks
  382. * Set locale message to Composer instance [messages](composition#messages).
  383. *
  384. * @param locale - A target locale
  385. * @param message - A message
  386. *
  387. * @typeParam MessageSchema - The locale message schema, default `never`
  388. */
  389. setLocaleMessage<MessageSchema extends LocaleMessage<VueMessageType> = never, LocaleSchema extends string = string, Locale extends PickupLocales<NonNullable<Messages>> = PickupLocales<NonNullable<Messages>>, MessageType = IsNever<MessageSchema> extends true ? IsEmptyObject<Messages> extends true ? RemoveIndexSignature<{
  390. [K in keyof DefineLocaleMessage]: DefineLocaleMessage[K];
  391. }> : NonNullable<Messages>[Locale] : MessageSchema, Message extends MessageType = MessageType>(locale: LocaleSchema | Locale, message: Message): void;
  392. /**
  393. * Merge locale message
  394. *
  395. * @remarks
  396. * Merge locale message to Composer instance [messages](composition#messages).
  397. *
  398. * @param locale - A target locale
  399. * @param message - A message
  400. *
  401. * @typeParam MessageSchema - The locale message schema, default `never`
  402. */
  403. mergeLocaleMessage<MessageSchema extends LocaleMessage<VueMessageType> = never, LocaleSchema extends string = string, Locale extends PickupLocales<NonNullable<Messages>> = PickupLocales<NonNullable<Messages>>, Message = IsNever<MessageSchema> extends true ? Record<string, any> : MessageSchema>(locale: LocaleSchema | Locale, message: Message): void;
  404. /**
  405. * Get datetime format
  406. *
  407. * @remarks
  408. * get datetime format from Composer instance [datetimeFormats](composition#datetimeformats).
  409. *
  410. * @param locale - A target locale
  411. *
  412. * @typeParam DateTimeSchema - The datetime format schema, default `never`
  413. *
  414. * @returns Datetime format
  415. */
  416. getDateTimeFormat<DateTimeSchema extends Record<string, any> = never, LocaleSchema extends string = string, Locale extends PickupLocales<NonNullable<DateTimeFormats>> = PickupLocales<NonNullable<DateTimeFormats>>, Return = IsNever<DateTimeSchema> extends true ? IsEmptyObject<DateTimeFormats> extends true ? RemoveIndexSignature<{
  417. [K in keyof DefineDateTimeFormat]: DefineDateTimeFormat[K];
  418. }> : NonNullable<DateTimeFormats>[Locale] : DateTimeSchema>(locale: LocaleSchema | Locale): Return;
  419. /**
  420. * Set datetime format
  421. *
  422. * @remarks
  423. * Set datetime format to Composer instance [datetimeFormats](composition#datetimeformats).
  424. *
  425. * @param locale - A target locale
  426. * @param format - A target datetime format
  427. *
  428. * @typeParam DateTimeSchema - The datetime format schema, default `never`
  429. */
  430. setDateTimeFormat<DateTimeSchema extends Record<string, any> = never, LocaleSchema extends string = string, Locale extends PickupLocales<NonNullable<DateTimeFormats>> = PickupLocales<NonNullable<DateTimeFormats>>, FormatsType = IsNever<DateTimeSchema> extends true ? IsEmptyObject<DateTimeFormats> extends true ? RemoveIndexSignature<{
  431. [K in keyof DefineDateTimeFormat]: DefineDateTimeFormat[K];
  432. }> : NonNullable<DateTimeFormats>[Locale] : DateTimeSchema, Formats extends FormatsType = FormatsType>(locale: LocaleSchema | Locale, format: Formats): void;
  433. /**
  434. * Merge datetime format
  435. *
  436. * @remarks
  437. * Merge datetime format to Composer instance [datetimeFormats](composition#datetimeformats).
  438. *
  439. * @param locale - A target locale
  440. * @param format - A target datetime format
  441. *
  442. * @typeParam DateTimeSchema - The datetime format schema, default `never`
  443. */
  444. mergeDateTimeFormat<DateTimeSchema extends Record<string, any> = never, LocaleSchema extends string = string, Locale extends PickupLocales<NonNullable<DateTimeFormats>> = PickupLocales<NonNullable<DateTimeFormats>>, Formats = IsNever<DateTimeSchema> extends true ? Record<string, any> : DateTimeSchema>(locale: LocaleSchema | Locale, format: Formats): void;
  445. /**
  446. * Get number format
  447. *
  448. * @remarks
  449. * get number format from Composer instance [numberFormats](composition#numberFormats).
  450. *
  451. * @param locale - A target locale
  452. *
  453. * @typeParam NumberSchema - The number format schema, default `never`
  454. *
  455. * @returns Number format
  456. */
  457. getNumberFormat<NumberSchema extends Record<string, any> = never, LocaleSchema extends string = string, Locale extends PickupLocales<NonNullable<NumberFormats>> = PickupLocales<NonNullable<NumberFormats>>, Return = IsNever<NumberSchema> extends true ? IsEmptyObject<NumberFormats> extends true ? RemoveIndexSignature<{
  458. [K in keyof DefineNumberFormat]: DefineNumberFormat[K];
  459. }> : NonNullable<NumberFormats>[Locale] : NumberSchema>(locale: LocaleSchema | Locale): Return;
  460. /**
  461. * Set number format
  462. *
  463. * @remarks
  464. * Set number format to Composer instance [numberFormats](composition#numberFormats).
  465. *
  466. * @param locale - A target locale
  467. * @param format - A target number format
  468. *
  469. * @typeParam NumberSchema - The number format schema, default `never`
  470. */
  471. setNumberFormat<NumberSchema extends Record<string, any> = never, LocaleSchema extends string = string, Locale extends PickupLocales<NonNullable<NumberFormats>> = PickupLocales<NonNullable<NumberFormats>>, FormatsType = IsNever<NumberSchema> extends true ? IsEmptyObject<NumberFormats> extends true ? RemoveIndexSignature<{
  472. [K in keyof DefineNumberFormat]: DefineNumberFormat[K];
  473. }> : NonNullable<NumberFormats>[Locale] : NumberSchema, Formats extends FormatsType = FormatsType>(locale: LocaleSchema | Locale, format: Formats): void;
  474. /**
  475. * Merge number format
  476. *
  477. * @remarks
  478. * Merge number format to Composer instance [numberFormats](composition#numberFormats).
  479. *
  480. * @param locale - A target locale
  481. * @param format - A target number format
  482. *
  483. * @typeParam NumberSchema - The number format schema, default `never`
  484. */
  485. mergeNumberFormat<NumberSchema extends Record<string, any> = never, LocaleSchema extends string = string, Locale extends PickupLocales<NonNullable<NumberFormats>> = PickupLocales<NonNullable<NumberFormats>>, Formats = IsNever<NumberSchema> extends true ? Record<string, any> : NumberSchema>(locale: LocaleSchema | Locale, format: Formats): void;
  486. /**
  487. * Get post translation handler
  488. *
  489. * @returns {@link PostTranslationHandler}
  490. *
  491. * @VueI18nSee [missing](composition#posttranslation)
  492. */
  493. getPostTranslationHandler(): PostTranslationHandler<VueMessageType> | null;
  494. /**
  495. * Set post translation handler
  496. *
  497. * @param handler - A {@link PostTranslationHandler}
  498. *
  499. * @VueI18nSee [missing](composition#posttranslation)
  500. */
  501. setPostTranslationHandler(handler: PostTranslationHandler<VueMessageType> | null): void;
  502. /**
  503. * Get missing handler
  504. *
  505. * @returns {@link MissingHandler}
  506. *
  507. * @VueI18nSee [missing](composition#missing)
  508. */
  509. getMissingHandler(): MissingHandler | null;
  510. /**
  511. * Set missing handler
  512. *
  513. * @param handler - A {@link MissingHandler}
  514. *
  515. * @VueI18nSee [missing](composition#missing)
  516. */
  517. setMissingHandler(handler: MissingHandler | null): void;
  518. }
  519. /**
  520. * Composer additional options for `useI18n`
  521. *
  522. * @remarks
  523. * `ComposerAdditionalOptions` is extend for {@link ComposerOptions}, so you can specify these options.
  524. *
  525. * @VueI18nSee [useI18n](composition#usei18n)
  526. *
  527. * @VueI18nComposition
  528. */
  529. export declare interface ComposerAdditionalOptions {
  530. useScope?: I18nScope;
  531. }
  532. /**
  533. * The type custom definition of Composer
  534. *
  535. * @remarks
  536. *
  537. * The interface that can extend Composer.
  538. *
  539. * The type defined by 3rd party (e.g. nuxt/i18n)
  540. *
  541. * @example
  542. * ```ts
  543. * // vue-i18n.d.ts (`.d.ts` file at your app)
  544. *
  545. * declare module 'vue-i18n' {
  546. * interface ComposerCustom {
  547. * localeCodes: string[]
  548. * }
  549. * }
  550. * ```
  551. *
  552. * @VueI18nComposition
  553. */
  554. export declare interface ComposerCustom {
  555. }
  556. /**
  557. * Datetime formatting functions
  558. *
  559. * @remarks
  560. * This is the interface for {@link Composer}
  561. *
  562. * @VueI18nComposition
  563. */
  564. export declare interface ComposerDateTimeFormatting<DateTimeFormats extends Record<string, any> = {}, Locales = 'en-US', DefinedDateTimeFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>, C = IsEmptyObject<DefinedDateTimeFormat> extends false ? PickupFormatPathKeys<{
  565. [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K];
  566. }> : 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> {
  567. /**
  568. * Datetime formatting
  569. *
  570. * @remarks
  571. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  572. *
  573. * If [UseI18nScope](general#usei18nscope) `'local'` or Some [UseI18nOptions](composition#usei18noptions) are specified at `useI18n`, it’s translated in preferentially local scope datetime formats than global scope datetime formats.
  574. *
  575. * If not, then it’s formatted with global scope datetime formats.
  576. *
  577. * @param value - A value, timestamp number or `Date` instance or ISO 8601 string
  578. *
  579. * @returns Formatted value
  580. *
  581. * @VueI18nSee [Datetime formatting](../guide/essentials/datetime)
  582. */
  583. (value: number | Date | string): string;
  584. /**
  585. * Datetime formatting
  586. *
  587. * @remarks
  588. * Overloaded `d`. About details, see the [call signature](composition#value-number-date-string-string) details.
  589. *
  590. * In this overloaded `d`, format in datetime format for a key registered in datetime formats.
  591. *
  592. * @param value - A value, timestamp number or `Date` instance or ISO 8601 string
  593. * @param keyOrOptions - A key of datetime formats, or additional {@link DateTimeOptions | options} for datetime formatting
  594. *
  595. * @returns Formatted value
  596. */
  597. <Value extends number | Date | string = number, Key extends string = string>(value: Value, keyOrOptions: Key | ResourceKeys | DateTimeOptions<Key | ResourceKeys, Locales>): string;
  598. /**
  599. * Datetime formatting
  600. *
  601. * @remarks
  602. * Overloaded `d`. About details, see the [call signature](composition#value-number-date-string-string) details.
  603. *
  604. * In this overloaded `d`, format in datetime format for a key registered in datetime formats at target locale
  605. *
  606. * @param value - A value, timestamp number or `Date` instance or ISO 8601 string
  607. * @param keyOrOptions - A key of datetime formats, or additional {@link DateTimeOptions | options} for datetime formatting
  608. * @param locale - A locale, it will be used over than global scope or local scope.
  609. *
  610. * @returns Formatted value
  611. */
  612. <Value extends number | Date | string = number, Key extends string = string>(value: Value, keyOrOptions: Key | ResourceKeys | DateTimeOptions<Key | ResourceKeys, Locales>, locale: Locales): string;
  613. }
  614. export declare type ComposerExtender = (composer: Composer) => Disposer | undefined;
  615. /**
  616. * Number formatting functions
  617. *
  618. * @remarks
  619. * This is the interface for {@link Composer}
  620. *
  621. * @VueI18nComposition
  622. */
  623. export declare interface ComposerNumberFormatting<NumberFormats extends Record<string, any> = {}, Locales = 'en-US', DefinedNumberFormat extends RemovedIndexResources<DefineNumberFormat> = RemovedIndexResources<DefineNumberFormat>, C = IsEmptyObject<DefinedNumberFormat> extends false ? PickupFormatPathKeys<{
  624. [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K];
  625. }> : 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> {
  626. /**
  627. * Number Formatting
  628. *
  629. * @remarks
  630. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  631. *
  632. * If [UseI18nScope](general#usei18nscope) `'local'` or Some [UseI18nOptions](composition#usei18noptions) are specified at `useI18n`, it’s translated in preferentially local scope datetime formats than global scope datetime formats.
  633. *
  634. * If not, then it’s formatted with global scope number formats.
  635. *
  636. * @param value - A number value
  637. *
  638. * @returns Formatted value
  639. *
  640. * @VueI18nSee [Number formatting](../guide/essentials/number)
  641. */
  642. (value: number): string;
  643. /**
  644. * Number Formatting
  645. *
  646. * @remarks
  647. * Overloaded `n`. About details, see the [call signature](composition#value-number-string) details.
  648. *
  649. * In this overloaded `n`, format in number format for a key registered in number formats.
  650. *
  651. * @param value - A number value
  652. * @param keyOrOptions - A key of number formats, or additional {@link NumberOptions | options} for number formatting
  653. *
  654. * @returns Formatted value
  655. */
  656. <Key extends string = string>(value: number, keyOrOptions: Key | ResourceKeys | NumberOptions<Key | ResourceKeys, Locales>): string;
  657. /**
  658. * Number Formatting
  659. *
  660. * @remarks
  661. * Overloaded `n`. About details, see the [call signature](composition#value-number-string) details.
  662. *
  663. * In this overloaded `n`, format in number format for a key registered in number formats at target locale.
  664. *
  665. * @param value - A number value
  666. * @param keyOrOptions - A key of number formats, or additional {@link NumberOptions | options} for number formatting
  667. * @param locale - A locale, it will be used over than global scope or local scope.
  668. *
  669. * @returns Formatted value
  670. */
  671. <Key extends string = string>(value: number, keyOrOptions: Key | ResourceKeys | NumberOptions<Key | ResourceKeys, Locales>, locale: Locales): string;
  672. }
  673. /**
  674. * Composer Options
  675. *
  676. * @remarks
  677. * This is options to create composer.
  678. *
  679. * @VueI18nComposition
  680. */
  681. export declare interface ComposerOptions<Schema extends {
  682. message?: unknown;
  683. datetime?: unknown;
  684. number?: unknown;
  685. } = {
  686. message: DefaultLocaleMessageSchema;
  687. datetime: DefaultDateTimeFormatSchema;
  688. number: DefaultNumberFormatSchema;
  689. }, Locales extends {
  690. messages: unknown;
  691. datetimeFormats: unknown;
  692. numberFormats: unknown;
  693. } | string = Locale, MessagesLocales = Locales extends {
  694. messages: infer M;
  695. } ? M : Locales extends string ? Locales : Locale, DateTimeFormatsLocales = Locales extends {
  696. datetimeFormats: infer D;
  697. } ? D : Locales extends string ? Locales : Locale, NumberFormatsLocales = Locales extends {
  698. numberFormats: infer N;
  699. } ? N : Locales extends string ? Locales : Locale, MessageSchema = Schema extends {
  700. message: infer M;
  701. } ? M : DefaultLocaleMessageSchema, DateTimeSchema = Schema extends {
  702. datetime: infer D;
  703. } ? D : DefaultDateTimeFormatSchema, NumberSchema = Schema extends {
  704. number: infer N;
  705. } ? N : DefaultNumberFormatSchema, _Messages extends LocaleMessages<MessageSchema, MessagesLocales, VueMessageType> = LocaleMessages<MessageSchema, MessagesLocales, VueMessageType>, _DateTimeFormats extends IntlDateTimeFormats<DateTimeSchema, DateTimeFormatsLocales> = IntlDateTimeFormats<DateTimeSchema, DateTimeFormatsLocales>, _NumberFormats extends IntlNumberFormats<NumberSchema, NumberFormatsLocales> = IntlNumberFormats<NumberSchema, NumberFormatsLocales>> {
  706. /**
  707. * @remarks
  708. * The locale of localization.
  709. *
  710. * If the locale contains a territory and a dialect, this locale contains an implicit fallback.
  711. *
  712. * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope)
  713. *
  714. * @defaultValue `'en-US'`
  715. */
  716. locale?: Locale;
  717. /**
  718. * @remarks
  719. * The locale of fallback localization.
  720. *
  721. * For more complex fallback definitions see fallback.
  722. *
  723. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  724. *
  725. * @defaultValue The default `'en-US'` for the `locale` if it's not specified, or it's `locale` value
  726. */
  727. fallbackLocale?: FallbackLocale;
  728. /**
  729. * @remarks
  730. * Whether inheritance the root level locale to the component localization locale.
  731. *
  732. * If `false`, regardless of the root level locale, localize for each component locale.
  733. *
  734. * @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-2)
  735. *
  736. * @defaultValue `true`
  737. */
  738. inheritLocale?: boolean;
  739. /**
  740. * @remarks
  741. * The locale messages of localization.
  742. *
  743. * @VueI18nSee [Getting Started](../guide/)
  744. *
  745. * @defaultValue `{}`
  746. */
  747. messages?: {
  748. [K in keyof _Messages]: MessageSchema;
  749. };
  750. /**
  751. * @remarks
  752. * Allow use flat json messages or not
  753. *
  754. * @defaultValue `false`
  755. */
  756. flatJson?: boolean;
  757. /**
  758. * @remarks
  759. * The datetime formats of localization.
  760. *
  761. * @VueI18nSee [Datetime Formatting](../guide/essentials/datetime)
  762. *
  763. * @defaultValue `{}`
  764. */
  765. datetimeFormats?: {
  766. [K in keyof _DateTimeFormats]: DateTimeSchema;
  767. };
  768. /**
  769. * @remarks
  770. * The number formats of localization.
  771. *
  772. * @VueI18nSee [Number Formatting](../guide/essentials/number)
  773. *
  774. * @defaultValue `{}`
  775. */
  776. numberFormats?: {
  777. [K in keyof _NumberFormats]: NumberSchema;
  778. };
  779. /**
  780. * @remarks
  781. * Custom Modifiers for linked messages.
  782. *
  783. * @VueI18nSee [Custom Modifiers](../guide/essentials/syntax#custom-modifiers)
  784. */
  785. modifiers?: LinkedModifiers<VueMessageType>;
  786. /**
  787. * @remarks
  788. * A set of rules for word pluralization
  789. *
  790. * @VueI18nSee [Custom Pluralization](../guide/essentials/pluralization#custom-pluralization)
  791. *
  792. * @defaultValue `{}`
  793. */
  794. pluralRules?: PluralizationRules;
  795. /**
  796. * @remarks
  797. * A handler for localization missing.
  798. *
  799. * The handler gets called with the localization target locale, localization path key, the Vue instance and values.
  800. *
  801. * If missing handler is assigned, and occurred localization missing, it's not warned.
  802. *
  803. * @defaultValue `null`
  804. */
  805. missing?: MissingHandler;
  806. /**
  807. * @remarks
  808. * Whether suppress warnings outputted when localization fails.
  809. *
  810. * If `false`, suppress localization fail warnings.
  811. *
  812. * If you use regular expression, you can suppress localization fail warnings that it match with translation key (e.g. `t`).
  813. *
  814. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  815. *
  816. * @defaultValue `true`
  817. */
  818. missingWarn?: boolean | RegExp;
  819. /**
  820. * @remarks
  821. * Whether suppress warnings when falling back to either `fallbackLocale` or root.
  822. *
  823. * If `false`, suppress fall back warnings.
  824. *
  825. * If you use regular expression, you can suppress fallback warnings that it match with translation key (e.g. `t`).
  826. *
  827. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  828. *
  829. * @defaultValue `true`
  830. */
  831. fallbackWarn?: boolean | RegExp;
  832. /**
  833. * @remarks
  834. * In the component localization, whether to fallback to root level (global scope) localization when localization fails.
  835. *
  836. * If `false`, it's not fallback to root.
  837. *
  838. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  839. *
  840. * @defaultValue `true`
  841. */
  842. fallbackRoot?: boolean;
  843. /**
  844. * @remarks
  845. * Whether do template interpolation on translation keys when your language lacks a translation for a key.
  846. *
  847. * If `true`, skip writing templates for your "base" language; the keys are your templates.
  848. *
  849. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  850. *
  851. * @defaultValue `false`
  852. */
  853. fallbackFormat?: boolean;
  854. /**
  855. * @remarks
  856. * A handler for post processing of translation.
  857. *
  858. * The handler gets after being called with the `t`.
  859. *
  860. * This handler is useful if you want to filter on translated text such as space trimming.
  861. *
  862. * @defaultValue `null`
  863. */
  864. postTranslation?: PostTranslationHandler<VueMessageType>;
  865. /**
  866. * @remarks
  867. * Whether to allow the use locale messages of HTML formatting.
  868. *
  869. * See the warnHtmlMessage property.
  870. *
  871. * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message)
  872. * @VueI18nSee [Change `warnHtmlInMessage` option default value](../guide/migration/breaking#change-warnhtmlinmessage-option-default-value)
  873. *
  874. * @defaultValue `'off'`
  875. */
  876. warnHtmlMessage?: boolean;
  877. /**
  878. * @remarks
  879. * If `escapeParameter` is configured as true then interpolation parameters are escaped before the message is translated.
  880. *
  881. * This is useful when translation output is used in `v-html` and the translation resource contains html markup (e.g. <b> around a user provided value).
  882. *
  883. * This usage pattern mostly occurs when passing precomputed text strings into UI components.
  884. *
  885. * The escape process involves replacing the following symbols with their respective HTML character entities: `<`, `>`, `"`, `'`.
  886. *
  887. * Setting `escapeParameter` as true should not break existing functionality but provides a safeguard against a subtle type of XSS attack vectors.
  888. *
  889. * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message)
  890. *
  891. * @defaultValue `false`
  892. */
  893. escapeParameter?: boolean;
  894. /**
  895. * @remarks
  896. * A message resolver to resolve [`messages`](composition#messages).
  897. *
  898. * If not specified, the vue-i18n internal message resolver will be used by default.
  899. *
  900. * You need to implement a message resolver yourself that supports the following requirements:
  901. *
  902. * - Resolve the message using the locale message of [`locale`](composition#locale) passed as the first argument of the message resolver, and the path passed as the second argument.
  903. *
  904. * - If the message could not be resolved, you need to return `null`.
  905. *
  906. * - If you will be returned `null`, the message resolver will also be called on fallback if [`fallbackLocale`](composition#fallbacklocale-2) is enabled, so the message will need to be resolved as well.
  907. *
  908. * The message resolver is called indirectly by the following APIs:
  909. *
  910. * - [`t`](composition#t-key)
  911. *
  912. * - [`te`](composition#te-key-locale)
  913. *
  914. * - [`tm`](composition#tm-key)
  915. *
  916. * - [Translation component](component#translation)
  917. *
  918. * @example
  919. * Here is an example of how to set it up using your `createI18n`:
  920. * ```js
  921. * import { createI18n } from 'vue-i18n'
  922. *
  923. * // your message resolver
  924. * function messageResolver(obj, path) {
  925. * // simple message resolving!
  926. * const msg = obj[path]
  927. * return msg != null ? msg : null
  928. * }
  929. *
  930. * // call with I18n option
  931. * const i18n = createI18n({
  932. * legacy: false,
  933. * locale: 'ja',
  934. * messageResolver, // set your message resolver
  935. * messages: {
  936. * en: { ... },
  937. * ja: { ... }
  938. * }
  939. * })
  940. *
  941. * // the below your something to do ...
  942. * // ...
  943. * ```
  944. *
  945. * @VueI18nTip
  946. * :new: v9.2+
  947. *
  948. * @VueI18nWarning
  949. * If you use the message resolver, the [`flatJson`](composition#flatjson) setting will be ignored. That is, you need to resolve the flat JSON by yourself.
  950. *
  951. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  952. *
  953. * @defaultValue `undefined`
  954. */
  955. messageResolver?: MessageResolver;
  956. /**
  957. * @remarks
  958. * A compiler for custom message format.
  959. *
  960. * If not specified, the vue-i18n default message compiler will be used.
  961. *
  962. * You will need to implement your own message compiler that returns Message Functions
  963. *
  964. * @example
  965. * Here is an example of how to custom message compiler with `intl-messageformat`
  966. *
  967. * ```js
  968. * import { createI18n } from 'vue-i18n'
  969. * import IntlMessageFormat from 'intl-messageformat'
  970. *
  971. * function messageCompiler(message, { locale, key, onError }) {
  972. * if (typeof message === 'string') {
  973. * // You can tune your message compiler performance more with your cache strategy or also memoization at here
  974. * const formatter = new IntlMessageFormat(message, locale)
  975. * return ctx => formatter.format(ctx.values)
  976. * } else {
  977. * // If you would like to support it for AST,
  978. * // You need to transform locale mesages such as `json`, `yaml`, etc. with the bundle plugin.
  979. * onError && onError(new Error('not support for AST'))
  980. * return () => key // return default with `key`
  981. * }
  982. * }
  983. *
  984. * // call with I18n option
  985. * const i18n = createI18n({
  986. * legacy: false,
  987. * locale: 'ja',
  988. * messageCompiler, // set your message compiler
  989. * messages: {
  990. * en: {
  991. * hello: 'hello world!',
  992. * greeting: 'hi, {name}!',
  993. * // ICU Message format
  994. * photo: `You have {numPhotos, plural,
  995. * =0 {no photos.}
  996. * =1 {one photo.}
  997. * other {# photos.}
  998. * }`
  999. * },
  1000. * }
  1001. * })
  1002. *
  1003. * // the below your something to do ...
  1004. * // ...
  1005. * ```
  1006. *
  1007. * @VueI18nTip
  1008. * :new: v9.3+
  1009. *
  1010. * @VueI18nWarning
  1011. * The Custom Message Format is an experimental feature. It may receive breaking changes or be removed in the future.
  1012. *
  1013. * @VueI18nSee [Custom Message Format](../guide/advanced/format)
  1014. *
  1015. * @defaultValue `undefined`
  1016. */
  1017. messageCompiler?: MessageCompiler;
  1018. }
  1019. /**
  1020. * Resolve locale message translation functions
  1021. *
  1022. * @remarks
  1023. * This is the interface for {@link Composer}
  1024. *
  1025. * @VueI18nComposition
  1026. */
  1027. export declare interface ComposerResolveLocaleMessageTranslation<Locales = 'en-US'> {
  1028. /**
  1029. * Resolve locale message translation
  1030. *
  1031. * @remarks
  1032. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  1033. *
  1034. * If [UseI18nScope](general#usei18nscope) `'local'` or Some [UseI18nOptions](composition#usei18noptions) are specified at `useI18n`, it’s translated in preferentially local scope locale messages than global scope locale messages.
  1035. *
  1036. * If not, then it’s translated with global scope locale messages.
  1037. *
  1038. * @VueI18nTip
  1039. * The use-case for `rt` is for programmatic locale messages translation with using `tm`, `v-for`, javascript `for` statement.
  1040. *
  1041. * @VueI18nWarning
  1042. * `rt` differs from `t` in that it processes the locale message directly, not the key of the locale message. There is no internal fallback with `rt`. You need to understand and use the structure of the locale messge returned by `tm`.
  1043. *
  1044. * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `tm`.
  1045. *
  1046. * @returns Translated message
  1047. *
  1048. * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope)
  1049. */
  1050. (message: MessageFunction<VueMessageType> | VueMessageType): string;
  1051. /**
  1052. * Resolve locale message translation for plurals
  1053. *
  1054. * @remarks
  1055. * Overloaded `rt`. About details, see the [call signature](composition#message-messagefunction-message-message-string) details.
  1056. *
  1057. * In this overloaded `rt`, return a pluralized translation message.
  1058. *
  1059. * @VueI18nTip
  1060. * The use-case for `rt` is for programmatic locale messages translation with using `tm`, `v-for`, javascript `for` statement.
  1061. *
  1062. * @VueI18nWarning
  1063. * `rt` differs from `t` in that it processes the locale message directly, not the key of the locale message. There is no internal fallback with `rt`. You need to understand and use the structure of the locale messge returned by `tm`.
  1064. *
  1065. * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `tm`.
  1066. * @param plural - Which plural string to get. 1 returns the first one.
  1067. * @param options - Additional {@link TranslateOptions | options} for translation
  1068. *
  1069. * @returns Translated message
  1070. *
  1071. * @VueI18nSee [Pluralization](../guide/essentials/pluralization)
  1072. */
  1073. (message: MessageFunction<VueMessageType> | VueMessageType, plural: number, options?: TranslateOptions<Locales>): string;
  1074. /**
  1075. * Resolve locale message translation for list interpolations
  1076. *
  1077. * @remarks
  1078. * Overloaded `rt`. About details, see the [call signature](composition#message-messagefunction-message-message-string) details.
  1079. *
  1080. * In this overloaded `rt`, return a pluralized translation message.
  1081. *
  1082. * @VueI18nTip
  1083. * The use-case for `rt` is for programmatic locale messages translation with using `tm`, `v-for`, javascript `for` statement.
  1084. *
  1085. * @VueI18nWarning
  1086. * `rt` differs from `t` in that it processes the locale message directly, not the key of the locale message. There is no internal fallback with `rt`. You need to understand and use the structure of the locale messge returned by `tm`.
  1087. *
  1088. * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `tm`.
  1089. * @param list - A values of list interpolation.
  1090. * @param options - Additional {@link TranslateOptions | options} for translation
  1091. *
  1092. * @returns Translated message
  1093. *
  1094. * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation)
  1095. */
  1096. (message: MessageFunction<VueMessageType> | VueMessageType, list: unknown[], options?: TranslateOptions<Locales>): string;
  1097. /**
  1098. * Resolve locale message translation for named interpolations
  1099. *
  1100. * @remarks
  1101. * Overloaded `rt`. About details, see the [call signature](composition#message-messagefunction-message-message-string) details.
  1102. *
  1103. * In this overloaded `rt`, for each placeholder x, the locale messages should contain a `{x}` token.
  1104. *
  1105. * @VueI18nTip
  1106. * The use-case for `rt` is for programmatic locale messages translation with using `tm`, `v-for`, javascript `for` statement.
  1107. *
  1108. * @VueI18nWarning
  1109. * `rt` differs from `t` in that it processes the locale message directly, not the key of the locale message. There is no internal fallback with `rt`. You need to understand and use the structure of the locale messge returned by `tm`.
  1110. *
  1111. * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `tm`.
  1112. * @param named - A values of named interpolation.
  1113. * @param options - Additional {@link TranslateOptions | options} for translation
  1114. *
  1115. * @returns Translated message
  1116. *
  1117. * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation)
  1118. */
  1119. (message: MessageFunction<VueMessageType> | VueMessageType, named: NamedValue, options?: TranslateOptions<Locales>): string;
  1120. }
  1121. /**
  1122. * Locale message translation functions
  1123. *
  1124. * @remarks
  1125. * This is the interface for {@link Composer}
  1126. *
  1127. * @VueI18nComposition
  1128. */
  1129. export declare interface ComposerTranslation<Messages extends Record<string, any> = {}, Locales = 'en-US', DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>, C = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  1130. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  1131. }> : 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> {
  1132. /**
  1133. * Locale message translation
  1134. *
  1135. * @remarks
  1136. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  1137. *
  1138. * If [UseI18nScope](general#usei18nscope) `'local'` or Some [UseI18nOptions](composition#usei18noptions) are specified at `useI18n`, it’s translated in preferentially local scope locale messages than global scope locale messages.
  1139. *
  1140. * If not, then it’s translated with global scope locale messages.
  1141. *
  1142. * @param key - A target locale message key
  1143. *
  1144. * @returns Translated message
  1145. *
  1146. * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope)
  1147. */
  1148. <Key extends string>(key: Key | ResourceKeys | number): string;
  1149. /**
  1150. * Locale message translation for plurals
  1151. *
  1152. * @remarks
  1153. * Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details.
  1154. *
  1155. * In this overloaded `t`, return a pluralized translation message.
  1156. *
  1157. * You can also suppress the warning, when the translation missing according to the options.
  1158. *
  1159. * About details of options, see the {@link TranslateOptions}.
  1160. *
  1161. * @param key - A target locale message key
  1162. * @param plural - Which plural string to get. 1 returns the first one.
  1163. * @param options - Additional {@link TranslateOptions | options} for translation
  1164. *
  1165. * @returns Translated message
  1166. *
  1167. * @VueI18nSee [Pluralization](../guide/essentials/pluralization)
  1168. */
  1169. <Key extends string>(key: Key | ResourceKeys | number, plural: number, options?: TranslateOptions<Locales>): string;
  1170. /**
  1171. * Locale message translation for missing default message
  1172. *
  1173. * @remarks
  1174. * Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details.
  1175. *
  1176. * In this overloaded `t`, if no translation was found, return a default message.
  1177. *
  1178. * You can also suppress the warning, when the translation missing according to the options.
  1179. *
  1180. * About details of options, see the {@link TranslateOptions}.
  1181. *
  1182. * @param key - A target locale message key
  1183. * @param defaultMsg - A default message to return if no translation was found
  1184. * @param options - Additional {@link TranslateOptions | options} for translation
  1185. *
  1186. * @returns Translated message
  1187. */
  1188. <Key extends string>(key: Key | ResourceKeys | number, defaultMsg: string, options?: TranslateOptions<Locales>): string;
  1189. /**
  1190. * Locale message translation for list interpolations
  1191. *
  1192. * @remarks
  1193. * Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details.
  1194. *
  1195. * In this overloaded `t`, the locale messages should contain a `{0}`, `{1}`, … for each placeholder in the list.
  1196. *
  1197. * You can also suppress the warning, when the translation missing according to the options.
  1198. *
  1199. * About details of options, see the {@link TranslateOptions}.
  1200. *
  1201. * @param key - A target locale message key
  1202. * @param list - A values of list interpolation
  1203. * @param options - Additional {@link TranslateOptions | options} for translation
  1204. *
  1205. * @returns Translated message
  1206. *
  1207. * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation)
  1208. */
  1209. <Key extends string>(key: Key | ResourceKeys | number, list: unknown[], options?: TranslateOptions<Locales>): string;
  1210. /**
  1211. * Locale message translation for list interpolations and plurals
  1212. *
  1213. * @remarks
  1214. * Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details.
  1215. *
  1216. * In this overloaded `t`, the locale messages should contain a `{0}`, `{1}`, … for each placeholder in the list, and return a pluralized translation message.
  1217. *
  1218. * @param key - A target locale message key
  1219. * @param list - A values of list interpolation
  1220. * @param plural - Which plural string to get. 1 returns the first one.
  1221. *
  1222. * @returns Translated message
  1223. *
  1224. * @VueI18nSee [Pluralization](../guide/essentials/pluralization)
  1225. * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation)
  1226. */
  1227. <Key extends string>(key: Key | ResourceKeys | number, list: unknown[], plural: number): string;
  1228. /**
  1229. * Locale message translation for list interpolations and missing default message
  1230. *
  1231. * @remarks
  1232. * Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details.
  1233. *
  1234. * 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.
  1235. *
  1236. * @param key - A target locale message key
  1237. * @param list - A values of list interpolation
  1238. * @param defaultMsg - A default message to return if no translation was found
  1239. *
  1240. * @returns Translated message
  1241. *
  1242. * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation)
  1243. */
  1244. <Key extends string>(key: Key | ResourceKeys | number, list: unknown[], defaultMsg: string): string;
  1245. /**
  1246. * Locale message translation for named interpolations
  1247. *
  1248. * @remarks
  1249. * Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details.
  1250. *
  1251. * In this overloaded `t`, for each placeholder x, the locale messages should contain a `{x}` token.
  1252. *
  1253. * You can also suppress the warning, when the translation missing according to the options.
  1254. *
  1255. * About details of options, see the {@link TranslateOptions}.
  1256. *
  1257. * @param key - A target locale message key
  1258. * @param named - A values of named interpolation
  1259. * @param options - Additional {@link TranslateOptions | options} for translation
  1260. *
  1261. * @returns Translated message
  1262. *
  1263. * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation)
  1264. */
  1265. <Key extends string>(key: Key | ResourceKeys | number, named: NamedValue, options?: TranslateOptions<Locales>): string;
  1266. /**
  1267. * Locale message translation for named interpolations and plurals
  1268. *
  1269. * @remarks
  1270. * Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details.
  1271. *
  1272. * In this overloaded `t`, for each placeholder x, the locale messages should contain a `{x}` token, and return a pluralized translation message.
  1273. *
  1274. * @param key - A target locale message key
  1275. * @param named - A values of named interpolation
  1276. * @param plural - Which plural string to get. 1 returns the first one.
  1277. *
  1278. * @returns Translated message
  1279. *
  1280. * @VueI18nSee [Pluralization](../guide/essentials/pluralization)
  1281. * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation)
  1282. */
  1283. <Key extends string>(key: Key | ResourceKeys | number, named: NamedValue, plural: number): string;
  1284. /**
  1285. * Locale message translation for named interpolations and plurals
  1286. *
  1287. * @remarks
  1288. * Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details.
  1289. *
  1290. * 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.
  1291. *
  1292. * @param key - A target locale message key
  1293. * @param named - A values of named interpolation
  1294. * @param defaultMsg - A default message to return if no translation was found
  1295. *
  1296. * @returns Translated message
  1297. *
  1298. * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation)
  1299. */
  1300. <Key extends string>(key: Key | ResourceKeys | number, named: NamedValue, defaultMsg: string): string;
  1301. }
  1302. export declare function createI18n<Legacy extends boolean = true, Options extends I18nOptions = I18nOptions, Messages extends Record<string, unknown> = Options['messages'] extends Record<string, unknown> ? Options['messages'] : {}, DateTimeFormats extends Record<string, unknown> = Options['datetimeFormats'] extends Record<string, unknown> ? Options['datetimeFormats'] : {}, NumberFormats extends Record<string, unknown> = Options['numberFormats'] extends Record<string, unknown> ? Options['numberFormats'] : {}, OptionLocale = Options['locale'] extends string ? Options['locale'] : Locale>(options: Options, LegacyVueI18n?: any): (typeof options)['legacy'] extends true ? I18n<Messages, DateTimeFormats, NumberFormats, OptionLocale, true> : (typeof options)['legacy'] extends false ? I18n<Messages, DateTimeFormats, NumberFormats, OptionLocale, false> : I18n<Messages, DateTimeFormats, NumberFormats, OptionLocale, Legacy>;
  1303. /**
  1304. * Vue I18n factory
  1305. *
  1306. * @param options - An options, see the {@link I18nOptions}
  1307. *
  1308. * @typeParam Schema - The i18n resources (messages, datetimeFormats, numberFormats) schema, default {@link LocaleMessage}
  1309. * @typeParam Locales - The locales of i18n resource schema, default `en-US`
  1310. * @typeParam Legacy - Whether legacy mode is enabled or disabled, default `true`
  1311. *
  1312. * @returns {@link I18n} instance
  1313. *
  1314. * @remarks
  1315. * If you use Legacy API mode, you need to specify {@link VueI18nOptions} and `legacy: true` option.
  1316. *
  1317. * If you use composition API mode, you need to specify {@link ComposerOptions}.
  1318. *
  1319. * @VueI18nSee [Getting Started](../guide/)
  1320. * @VueI18nSee [Composition API](../guide/advanced/composition)
  1321. *
  1322. * @example
  1323. * case: for Legacy API
  1324. * ```js
  1325. * import { createApp } from 'vue'
  1326. * import { createI18n } from 'vue-i18n'
  1327. *
  1328. * // call with I18n option
  1329. * const i18n = createI18n({
  1330. * locale: 'ja',
  1331. * messages: {
  1332. * en: { ... },
  1333. * ja: { ... }
  1334. * }
  1335. * })
  1336. *
  1337. * const App = {
  1338. * // ...
  1339. * }
  1340. *
  1341. * const app = createApp(App)
  1342. *
  1343. * // install!
  1344. * app.use(i18n)
  1345. * app.mount('#app')
  1346. * ```
  1347. *
  1348. * @example
  1349. * case: for composition API
  1350. * ```js
  1351. * import { createApp } from 'vue'
  1352. * import { createI18n, useI18n } from 'vue-i18n'
  1353. *
  1354. * // call with I18n option
  1355. * const i18n = createI18n({
  1356. * legacy: false, // you must specify 'legacy: false' option
  1357. * locale: 'ja',
  1358. * messages: {
  1359. * en: { ... },
  1360. * ja: { ... }
  1361. * }
  1362. * })
  1363. *
  1364. * const App = {
  1365. * setup() {
  1366. * // ...
  1367. * const { t } = useI18n({ ... })
  1368. * return { ... , t }
  1369. * }
  1370. * }
  1371. *
  1372. * const app = createApp(App)
  1373. *
  1374. * // install!
  1375. * app.use(i18n)
  1376. * app.mount('#app')
  1377. * ```
  1378. *
  1379. * @VueI18nGeneral
  1380. */
  1381. export declare function createI18n<Schema extends object = DefaultLocaleMessageSchema, Locales extends string | object = 'en-US', Legacy extends boolean = true, Options extends I18nOptions<SchemaParams<Schema, VueMessageType>, LocaleParams<Locales>> = I18nOptions<SchemaParams<Schema, VueMessageType>, LocaleParams<Locales>>, Messages extends Record<string, unknown> = NonNullable<Options['messages']> extends Record<string, unknown> ? NonNullable<Options['messages']> : {}, DateTimeFormats extends Record<string, unknown> = NonNullable<Options['datetimeFormats']> extends Record<string, unknown> ? NonNullable<Options['datetimeFormats']> : {}, NumberFormats extends Record<string, unknown> = NonNullable<Options['numberFormats']> extends Record<string, unknown> ? NonNullable<Options['numberFormats']> : {}, OptionLocale = Options['locale'] extends string ? Options['locale'] : Locale>(options: Options, LegacyVueI18n?: any): (typeof options)['legacy'] extends true ? I18n<Messages, DateTimeFormats, NumberFormats, OptionLocale, true> : (typeof options)['legacy'] extends false ? I18n<Messages, DateTimeFormats, NumberFormats, OptionLocale, false> : I18n<Messages, DateTimeFormats, NumberFormats, OptionLocale, Legacy>;
  1382. export declare interface CustomBlock<Message = VueMessageType> {
  1383. locale: Locale;
  1384. resource: LocaleMessages<Message>;
  1385. }
  1386. export declare type CustomBlocks<Message = VueMessageType> = Array<CustomBlock<Message>>;
  1387. /**
  1388. * Datetime Format Component
  1389. *
  1390. * @remarks
  1391. * See the following items for property about details
  1392. *
  1393. * @VueI18nSee [FormattableProps](component#formattableprops)
  1394. * @VueI18nSee [BaseFormatProps](component#baseformatprops)
  1395. * @VueI18nSee [Custom Formatting](../guide/essentials/datetime#custom-formatting)
  1396. *
  1397. * @VueI18nDanger
  1398. * Not supported IE, due to no support `Intl.DateTimeFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/formatToParts)
  1399. *
  1400. * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-datetimeformat)
  1401. *
  1402. * @VueI18nComponent
  1403. */
  1404. export declare const DatetimeFormat: new () => {
  1405. $props: VNodeProps & DatetimeFormatProps & BaseFormatProps;
  1406. };
  1407. /**
  1408. * DatetimeFormat Component Props
  1409. *
  1410. * @VueI18nComponent
  1411. */
  1412. export declare type DatetimeFormatProps = FormattableProps<number | Date, Intl.DateTimeFormatOptions>;
  1413. /** @VueI18nLegacy */
  1414. export declare type DateTimeFormatResult = string;
  1415. export { DateTimeOptions }
  1416. export declare type DefaultDateTimeFormatSchema<Schema = RemoveIndexSignature<{
  1417. [K in keyof DefineDateTimeFormat]: DefineDateTimeFormat[K];
  1418. }>> = IsEmptyObject<Schema> extends true ? IntlDateTimeFormat : Schema;
  1419. export declare type DefaultLocaleMessageSchema<Schema = RemoveIndexSignature<{
  1420. [K in keyof DefineLocaleMessage]: DefineLocaleMessage[K];
  1421. }>> = IsEmptyObject<Schema> extends true ? LocaleMessage<VueMessageType> : Schema;
  1422. export declare type DefaultNumberFormatSchema<Schema = RemoveIndexSignature<{
  1423. [K in keyof DefineNumberFormat]: DefineNumberFormat[K];
  1424. }>> = IsEmptyObject<Schema> extends true ? IntlNumberFormat : Schema;
  1425. /**
  1426. * The type definition of datetime format
  1427. *
  1428. * @remarks
  1429. * The typealias is used to strictly define the type of the Datetime format.
  1430. *
  1431. * The type defined by this can be used in the global scope.
  1432. *
  1433. * @example
  1434. * ```ts
  1435. * // type.d.ts (`.d.ts` file at your app)
  1436. * import { DefineDateTimeFormat } from 'vue-i18n'
  1437. *
  1438. * declare module 'vue-i18n' {
  1439. * export interface DefineDateTimeFormat {
  1440. * short: {
  1441. * hour: 'numeric'
  1442. * timezone: string
  1443. * }
  1444. * }
  1445. * }
  1446. * ```
  1447. *
  1448. * @VueI18nGeneral
  1449. */
  1450. export declare interface DefineDateTimeFormat extends IntlDateTimeFormat {
  1451. }
  1452. /**
  1453. * The type definition of Locale Message
  1454. *
  1455. * @remarks
  1456. * The typealias is used to strictly define the type of the Locale message.
  1457. *
  1458. * The type defined by this can be used in the global scope.
  1459. *
  1460. * @example
  1461. * ```ts
  1462. * // type.d.ts (`.d.ts` file at your app)
  1463. * import { DefineLocaleMessage } from 'vue-i18n'
  1464. *
  1465. * declare module 'vue-i18n' {
  1466. * export interface DefineLocaleMessage {
  1467. * title: string
  1468. * menu: {
  1469. * login: string
  1470. * }
  1471. * }
  1472. * }
  1473. * ```
  1474. *
  1475. * @VueI18nGeneral
  1476. */
  1477. export declare interface DefineLocaleMessage extends LocaleMessage<VueMessageType> {
  1478. }
  1479. /**
  1480. * The type definition of number format
  1481. *
  1482. * @remarks
  1483. * The typealias is used to strictly define the type of the Number format.
  1484. *
  1485. * The type defined by this can be used in the global scope.
  1486. *
  1487. * @example
  1488. * ```ts
  1489. * // type.d.ts (`.d.ts` file at your app)
  1490. * import { DefineNumberFormat } from 'vue-i18n'
  1491. *
  1492. * declare module 'vue-i18n' {
  1493. * export interface DefineNumberFormat {
  1494. * currency: {
  1495. * style: 'currency'
  1496. * currencyDisplay: 'symbol'
  1497. * currency: string
  1498. * }
  1499. * }
  1500. * }
  1501. * ```
  1502. *
  1503. * @VueI18nGeneral
  1504. */
  1505. export declare interface DefineNumberFormat extends IntlNumberFormat {
  1506. }
  1507. export declare type Disposer = () => void;
  1508. /**
  1509. * Exported global composer instance
  1510. *
  1511. * @remarks
  1512. * This interface is the [global composer](general#global) that is provided interface that is injected into each component with `app.config.globalProperties`.
  1513. *
  1514. * @VueI18nGeneral
  1515. */
  1516. export declare interface ExportedGlobalComposer {
  1517. /**
  1518. * Locale
  1519. *
  1520. * @remarks
  1521. * This property is proxy-like property for `Composer#locale`. About details, see the [Composer#locale](composition#locale)
  1522. */
  1523. locale: Locale;
  1524. /**
  1525. * Fallback locale
  1526. *
  1527. * @remarks
  1528. * This property is proxy-like property for `Composer#fallbackLocale`. About details, see the [Composer#fallbackLocale](composition#fallbacklocale)
  1529. */
  1530. fallbackLocale: FallbackLocale;
  1531. /**
  1532. * Available locales
  1533. *
  1534. * @remarks
  1535. * This property is proxy-like property for `Composer#availableLocales`. About details, see the [Composer#availableLocales](composition#availablelocales)
  1536. */
  1537. readonly availableLocales: Locale[];
  1538. }
  1539. export { FallbackLocale }
  1540. /**
  1541. * Formattable Props
  1542. *
  1543. * @remarks
  1544. * The props used in DatetimeFormat, or NumberFormat component
  1545. *
  1546. * @VueI18nComponent
  1547. */
  1548. export declare interface FormattableProps<Value, Format> extends BaseFormatProps {
  1549. /**
  1550. * @remarks
  1551. * The value specified for the target component
  1552. */
  1553. value: Value;
  1554. /**
  1555. * @remarks
  1556. * The format to use in the target component.
  1557. *
  1558. * Specify the format key string or the format as defined by the Intl API in ECMA 402.
  1559. */
  1560. format?: string | Format;
  1561. }
  1562. export declare interface Formatter {
  1563. interpolate(message: string, values: any, path: string): Array<any> | null;
  1564. }
  1565. /**
  1566. * I18n instance
  1567. *
  1568. * @remarks
  1569. * The instance required for installation as the Vue plugin
  1570. *
  1571. * @VueI18nGeneral
  1572. */
  1573. export declare interface I18n<Messages extends Record<string, unknown> = {}, DateTimeFormats extends Record<string, unknown> = {}, NumberFormats extends Record<string, unknown> = {}, OptionLocale = Locale, Legacy = boolean> {
  1574. /**
  1575. * Vue I18n API mode
  1576. *
  1577. * @remarks
  1578. * If you specified `legacy: true` option in `createI18n`, return `legacy`, else `composition`
  1579. *
  1580. * @defaultValue `'legacy'`
  1581. */
  1582. readonly mode: I18nMode;
  1583. /**
  1584. * The property accessible to the global Composer instance or VueI18n instance
  1585. *
  1586. * @remarks
  1587. * If the [I18n#mode](general#mode) is `'legacy'`, then you can access to a global {@link VueI18n} instance, else then [I18n#mode](general#mode) is `'composition' `, you can access to the global {@link Composer} instance.
  1588. *
  1589. * An instance of this property is **global scope***.
  1590. */
  1591. readonly global: Legacy extends true ? VueI18n<Messages, DateTimeFormats, NumberFormats, OptionLocale> : Legacy extends false ? Composer<Messages, DateTimeFormats, NumberFormats, OptionLocale> : unknown;
  1592. /**
  1593. * The property whether or not the Composition API is available
  1594. *
  1595. * @remarks
  1596. * If you specified `allowComposition: true` option in Legacy API mode, return `true`, else `false`. else you use the Composition API mode, this property will always return `true`.
  1597. */
  1598. readonly allowComposition: boolean;
  1599. /**
  1600. * Install entry point
  1601. *
  1602. * @param app - A target Vue app instance
  1603. * @param options - An install options
  1604. */
  1605. install(app: App, ...options: unknown[]): void;
  1606. /**
  1607. * Release global scope resource
  1608. */
  1609. dispose(): void;
  1610. }
  1611. /**
  1612. * I18n Additional Options
  1613. *
  1614. * @remarks
  1615. * Specific options for {@link createI18n}
  1616. *
  1617. * @VueI18nGeneral
  1618. */
  1619. export declare interface I18nAdditionalOptions {
  1620. /**
  1621. * Whether vue-i18n Legacy API mode use on your Vue App
  1622. *
  1623. * @remarks
  1624. * The default is to use the Legacy API mode. If you want to use the Composition API mode, you need to set it to `false`.
  1625. *
  1626. * @VueI18nSee [Composition API](../guide/advanced/composition)
  1627. *
  1628. * @defaultValue `true`
  1629. */
  1630. legacy?: boolean;
  1631. /**
  1632. * Whether to inject global properties & functions into for each component.
  1633. *
  1634. * @remarks
  1635. * If set to `true`, then properties and methods prefixed with `$` are injected into Vue Component.
  1636. *
  1637. * @VueI18nSee [Implicit with injected properties and functions](../guide/advanced/composition#implicit-with-injected-properties-and-functions)
  1638. * @VueI18nSee [ComponentCustomProperties](injection#componentcustomproperties)
  1639. *
  1640. * @defaultValue `true`
  1641. */
  1642. globalInjection?: boolean;
  1643. /**
  1644. * Whether to allow the Composition API to be used in Legacy API mode.
  1645. *
  1646. * @remarks
  1647. * If this option is enabled, you can use {@link useI18n} in Legacy API mode. This option is supported to support the migration from Legacy API mode to Composition API mode.
  1648. *
  1649. * @VueI18nWarning Note that the Composition API made available with this option doesn't work on SSR.
  1650. * @VueI18nSee [Composition API](../guide/advanced/composition)
  1651. *
  1652. * @defaultValue `false`
  1653. */
  1654. allowComposition?: boolean;
  1655. }
  1656. export declare const I18nD: new () => {
  1657. $props: VNodeProps & DatetimeFormatProps & BaseFormatProps;
  1658. };
  1659. /**
  1660. * Injection key for {@link useI18n}
  1661. *
  1662. * @remarks
  1663. * The global injection key for I18n instances with `useI18n`. this injection key is used in Web Components.
  1664. * Specify the i18n instance created by {@link createI18n} together with `provide` function.
  1665. *
  1666. * @VueI18nGeneral
  1667. */
  1668. export declare const I18nInjectionKey: InjectionKey<I18n> | string;
  1669. /**
  1670. * Vue I18n API mode
  1671. *
  1672. * @VueI18nSee [I18n#mode](general#mode)
  1673. *
  1674. * @VueI18nGeneral
  1675. */
  1676. export declare type I18nMode = 'legacy' | 'composition';
  1677. export declare const I18nN: new () => {
  1678. $props: VNodeProps & NumberFormatProps & BaseFormatProps;
  1679. };
  1680. /**
  1681. * I18n Options for `createI18n`
  1682. *
  1683. * @remarks
  1684. * `I18nOptions` is inherited {@link I18nAdditionalOptions}, {@link ComposerOptions} and {@link VueI18nOptions},
  1685. * so you can specify these options.
  1686. *
  1687. * @VueI18nGeneral
  1688. */
  1689. export declare type I18nOptions<Schema extends {
  1690. message?: unknown;
  1691. datetime?: unknown;
  1692. number?: unknown;
  1693. } = {
  1694. message: DefaultLocaleMessageSchema;
  1695. datetime: DefaultDateTimeFormatSchema;
  1696. number: DefaultNumberFormatSchema;
  1697. }, Locales extends {
  1698. messages: unknown;
  1699. datetimeFormats: unknown;
  1700. numberFormats: unknown;
  1701. } | string = Locale, Options extends ComposerOptions<Schema, Locales> | VueI18nOptions<Schema, Locales> = ComposerOptions<Schema, Locales> | VueI18nOptions<Schema, Locales>> = I18nAdditionalOptions & Options;
  1702. /**
  1703. * Vue I18n plugin options
  1704. *
  1705. * @remarks
  1706. * An options specified when installing Vue I18n as Vue plugin with using `app.use`.
  1707. *
  1708. * @VueI18nGeneral
  1709. */
  1710. export declare interface I18nPluginOptions {
  1711. /**
  1712. * Whether to use the tag name `i18n` for Translation Component
  1713. *
  1714. * @remarks
  1715. * This option is used for compatibility with Vue I18n v8.x.
  1716. *
  1717. * If you can't migrate right away, you can temporarily enable this option, and you can work Translation Component.
  1718. *
  1719. * @defaultValue `false`
  1720. */
  1721. useI18nComponentName?: boolean;
  1722. /**
  1723. * Whether to globally install the components that is offered by Vue I18n
  1724. *
  1725. * @remarks
  1726. * If this option is enabled, the components will be installed globally at `app.use` time.
  1727. *
  1728. * If you want to install manually in the `import` syntax, you can set it to `false` to install when needed.
  1729. *
  1730. * @defaultValue `true`
  1731. */
  1732. globalInstall?: boolean;
  1733. }
  1734. /**
  1735. * I18n Scope
  1736. *
  1737. * @VueI18nSee [ComposerAdditionalOptions#useScope](composition#usescope)
  1738. * @VueI18nSee [useI18n](composition#usei18n)
  1739. *
  1740. * @VueI18nGeneral
  1741. */
  1742. export declare type I18nScope = 'local' | 'parent' | 'global';
  1743. export declare const I18nT: new () => {
  1744. $props: VNodeProps & TranslationProps;
  1745. };
  1746. export { IntlDateTimeFormat }
  1747. export { IntlDateTimeFormats }
  1748. export { IntlFormatMatcher }
  1749. export { IntlLocaleMatcher }
  1750. export { IntlNumberFormat }
  1751. export { IntlNumberFormats }
  1752. export { IsEmptyObject }
  1753. export { IsNever }
  1754. export { LinkedModifiers }
  1755. export { Locale }
  1756. export { LocaleMessageDictionary }
  1757. /** @VueI18nLegacy */
  1758. export declare type LocaleMessageObject<Message = string> = LocaleMessageDictionary<Message>;
  1759. export { LocaleMessages }
  1760. export { LocaleMessageType }
  1761. export { LocaleMessageValue }
  1762. export { MessageCompiler }
  1763. export { MessageCompilerContext }
  1764. export { MessageContext }
  1765. export { MessageFunction }
  1766. export { MessageFunctions }
  1767. export { MessageResolver }
  1768. /** @VueI18nComposition */
  1769. export declare type MissingHandler = (locale: Locale, key: Path, instance?: ComponentInternalInstance, type?: string) => string | void;
  1770. export { NamedValue }
  1771. /**
  1772. * Number Format Component
  1773. *
  1774. * @remarks
  1775. * See the following items for property about details
  1776. *
  1777. * @VueI18nSee [FormattableProps](component#formattableprops)
  1778. * @VueI18nSee [BaseFormatProps](component#baseformatprops)
  1779. * @VueI18nSee [Custom Formatting](../guide/essentials/number#custom-formatting)
  1780. *
  1781. * @VueI18nDanger
  1782. * Not supported IE, due to no support `Intl.NumberFormat#formatToParts` in [IE](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/formatToParts)
  1783. *
  1784. * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-numberformat)
  1785. *
  1786. * @VueI18nComponent
  1787. */
  1788. export declare const NumberFormat: new () => {
  1789. $props: VNodeProps & NumberFormatProps & BaseFormatProps;
  1790. };
  1791. /**
  1792. * NumberFormat Component Props
  1793. *
  1794. * @VueI18nComponent
  1795. */
  1796. export declare type NumberFormatProps = FormattableProps<number, Intl.NumberFormatOptions>;
  1797. /** @VueI18nLegacy */
  1798. export declare type NumberFormatResult = string;
  1799. export { NumberOptions }
  1800. export { Path }
  1801. export { PathValue }
  1802. export { PickupFormatPathKeys }
  1803. export { PickupKeys }
  1804. export { PickupPaths }
  1805. export { PluralizationRule }
  1806. export declare type PluralizationRulesMap = {
  1807. [locale: string]: PluralizationRule;
  1808. };
  1809. export { PostTranslationHandler }
  1810. export declare type RemovedIndexResources<T> = RemoveIndexSignature<{
  1811. [K in keyof T]: T[K];
  1812. }>;
  1813. export { TranslateOptions }
  1814. /** @VueI18nLegacy */
  1815. export declare type TranslateResult = string;
  1816. /**
  1817. * Translation Component
  1818. *
  1819. * @remarks
  1820. * See the following items for property about details
  1821. *
  1822. * @VueI18nSee [TranslationProps](component#translationprops)
  1823. * @VueI18nSee [BaseFormatProps](component#baseformatprops)
  1824. * @VueI18nSee [Component Interpolation](../guide/advanced/component)
  1825. *
  1826. * @example
  1827. * ```html
  1828. * <div id="app">
  1829. * <!-- ... -->
  1830. * <i18n keypath="term" tag="label" for="tos">
  1831. * <a :href="url" target="_blank">{{ $t('tos') }}</a>
  1832. * </i18n>
  1833. * <!-- ... -->
  1834. * </div>
  1835. * ```
  1836. * ```js
  1837. * import { createApp } from 'vue'
  1838. * import { createI18n } from 'vue-i18n'
  1839. *
  1840. * const messages = {
  1841. * en: {
  1842. * tos: 'Term of Service',
  1843. * term: 'I accept xxx {0}.'
  1844. * },
  1845. * ja: {
  1846. * tos: '利用規約',
  1847. * term: '私は xxx の{0}に同意します。'
  1848. * }
  1849. * }
  1850. *
  1851. * const i18n = createI18n({
  1852. * locale: 'en',
  1853. * messages
  1854. * })
  1855. *
  1856. * const app = createApp({
  1857. * data: {
  1858. * url: '/term'
  1859. * }
  1860. * }).use(i18n).mount('#app')
  1861. * ```
  1862. *
  1863. * @VueI18nComponent
  1864. */
  1865. export declare const Translation: new () => {
  1866. $props: VNodeProps & TranslationProps;
  1867. };
  1868. /**
  1869. * Translation Directive (`v-t`)
  1870. *
  1871. * @remarks
  1872. * Update the element `textContent` that localized with locale messages.
  1873. *
  1874. * You can use string syntax or object syntax.
  1875. *
  1876. * String syntax can be specified as a keypath of locale messages.
  1877. *
  1878. * If you can be used object syntax, you need to specify as the object key the following params
  1879. *
  1880. * ```
  1881. * - path: required, key of locale messages
  1882. * - locale: optional, locale
  1883. * - args: optional, for list or named formatting
  1884. * ```
  1885. *
  1886. * @example
  1887. * ```html
  1888. * <!-- string syntax: literal -->
  1889. * <p v-t="'foo.bar'"></p>
  1890. *
  1891. * <!-- string syntax: binding via data or computed props -->
  1892. * <p v-t="msg"></p>
  1893. *
  1894. * <!-- object syntax: literal -->
  1895. * <p v-t="{ path: 'hi', locale: 'ja', args: { name: 'kazupon' } }"></p>
  1896. *
  1897. * <!-- object syntax: binding via data or computed props -->
  1898. * <p v-t="{ path: greeting, args: { name: fullName } }"></p>
  1899. * ```
  1900. *
  1901. * @VueI18nDirective
  1902. */
  1903. export declare type TranslationDirective<T = HTMLElement> = ObjectDirective<T>;
  1904. /**
  1905. * Translation Component Props
  1906. *
  1907. * @VueI18nComponent
  1908. */
  1909. export declare interface TranslationProps extends BaseFormatProps {
  1910. /**
  1911. * @remarks
  1912. * The locale message key can be specified prop
  1913. */
  1914. keypath: string;
  1915. /**
  1916. * @remarks
  1917. * The Plural Choosing the message number prop
  1918. */
  1919. plural?: number | string;
  1920. }
  1921. export declare function useI18n<Options extends UseI18nOptions = UseI18nOptions>(options?: Options): Composer<NonNullable<Options['messages']>, NonNullable<Options['datetimeFormats']>, NonNullable<Options['numberFormats']>, Options['locale'] extends unknown ? string : Options['locale']>;
  1922. /**
  1923. * Use Composition API for Vue I18n
  1924. *
  1925. * @param options - An options, see {@link UseI18nOptions}
  1926. *
  1927. * @typeParam Schema - The i18n resources (messages, datetimeFormats, numberFormats) schema, default {@link LocaleMessage}
  1928. * @typeParam Locales - The locales of i18n resource schema, default `en-US`
  1929. *
  1930. * @returns {@link Composer} instance
  1931. *
  1932. * @remarks
  1933. * This function is mainly used by `setup`.
  1934. *
  1935. * If options are specified, Composer instance is created for each component and you can be localized on the component.
  1936. *
  1937. * If options are not specified, you can be localized using the global Composer.
  1938. *
  1939. * @example
  1940. * case: Component resource base localization
  1941. * ```html
  1942. * <template>
  1943. * <form>
  1944. * <label>{{ t('language') }}</label>
  1945. * <select v-model="locale">
  1946. * <option value="en">en</option>
  1947. * <option value="ja">ja</option>
  1948. * </select>
  1949. * </form>
  1950. * <p>message: {{ t('hello') }}</p>
  1951. * </template>
  1952. *
  1953. * <script>
  1954. * import { useI18n } from 'vue-i18n'
  1955. *
  1956. * export default {
  1957. * setup() {
  1958. * const { t, locale } = useI18n({
  1959. * locale: 'ja',
  1960. * messages: {
  1961. * en: { ... },
  1962. * ja: { ... }
  1963. * }
  1964. * })
  1965. * // Something to do ...
  1966. *
  1967. * return { ..., t, locale }
  1968. * }
  1969. * }
  1970. * </script>
  1971. * ```
  1972. *
  1973. * @VueI18nComposition
  1974. */
  1975. export declare function useI18n<Schema = DefaultLocaleMessageSchema, Locales = 'en-US', Options extends UseI18nOptions<SchemaParams<Schema, VueMessageType>, LocaleParams<Locales>> = UseI18nOptions<SchemaParams<Schema, VueMessageType>, LocaleParams<Locales>>>(options?: Options): Composer<NonNullable<Options['messages']>, NonNullable<Options['datetimeFormats']>, NonNullable<Options['numberFormats']>, Options['locale'] extends unknown ? string : Options['locale']>;
  1976. /**
  1977. * I18n Options for `useI18n`
  1978. *
  1979. * @remarks
  1980. * `UseI18nOptions` is inherited {@link ComposerAdditionalOptions} and {@link ComposerOptions}, so you can specify these options.
  1981. *
  1982. * @VueI18nSee [useI18n](composition#usei18n)
  1983. *
  1984. * @VueI18nComposition
  1985. */
  1986. export declare type UseI18nOptions<Schema extends {
  1987. message?: unknown;
  1988. datetime?: unknown;
  1989. number?: unknown;
  1990. } = {
  1991. message: DefaultLocaleMessageSchema;
  1992. datetime: DefaultDateTimeFormatSchema;
  1993. number: DefaultNumberFormatSchema;
  1994. }, Locales extends {
  1995. messages: unknown;
  1996. datetimeFormats: unknown;
  1997. numberFormats: unknown;
  1998. } | string = Locale, Options extends ComposerOptions<Schema, Locales> = ComposerOptions<Schema, Locales>> = ComposerAdditionalOptions & Options;
  1999. /**
  2000. * Vue I18n Version
  2001. *
  2002. * @remarks
  2003. * Semver format. Same format as the package.json `version` field.
  2004. *
  2005. * @VueI18nGeneral
  2006. */
  2007. export declare const VERSION: string;
  2008. export declare function vTDirective(i18n: I18n): TranslationDirective<HTMLElement>;
  2009. export declare type VTDirectiveValue = {
  2010. path: string;
  2011. locale?: Locale;
  2012. args?: NamedValue;
  2013. choice?: number;
  2014. plural?: number;
  2015. };
  2016. /**
  2017. * VueI18n legacy interfaces
  2018. *
  2019. * @remarks
  2020. * This interface is compatible with interface of `VueI18n` class (offered with Vue I18n v8.x).
  2021. *
  2022. * @VueI18nLegacy
  2023. */
  2024. export declare 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 = OptionLocale extends string ? [ResourceLocales] extends [never] ? Locale : ResourceLocales : OptionLocale | ResourceLocales, Composition extends Composer<Messages, DateTimeFormats, NumberFormats, OptionLocale> = Composer<Messages, DateTimeFormats, NumberFormats, OptionLocale>> {
  2025. /**
  2026. * @remarks
  2027. * Instance ID.
  2028. */
  2029. id: number;
  2030. /**
  2031. * @remarks
  2032. * The current locale this VueI18n instance is using.
  2033. *
  2034. * If the locale contains a territory and a dialect, this locale contains an implicit fallback.
  2035. *
  2036. * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope)
  2037. */
  2038. locale: Locales;
  2039. /**
  2040. * @remarks
  2041. * The current fallback locales this VueI18n instance is using.
  2042. *
  2043. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  2044. */
  2045. fallbackLocale: FallbackLocales<Locales>;
  2046. /**
  2047. * @remarks
  2048. * The list of available locales in `messages` in lexical order.
  2049. */
  2050. readonly availableLocales: Composition['availableLocales'];
  2051. /**
  2052. * @remarks
  2053. * The locale messages of localization.
  2054. *
  2055. * @VueI18nSee [Getting Started](../guide/)
  2056. */
  2057. readonly messages: {
  2058. [K in keyof Messages]: Messages[K];
  2059. };
  2060. /**
  2061. * @remarks
  2062. * The datetime formats of localization.
  2063. *
  2064. * @VueI18nSee [Datetime Formatting](../guide/essentials/datetime)
  2065. */
  2066. readonly datetimeFormats: {
  2067. [K in keyof DateTimeFormats]: DateTimeFormats[K];
  2068. };
  2069. /**
  2070. * @remarks
  2071. * The number formats of localization.
  2072. *
  2073. * @VueI18nSee [Number Formatting](../guide/essentials/number)
  2074. */
  2075. readonly numberFormats: {
  2076. [K in keyof NumberFormats]: NumberFormats[K];
  2077. };
  2078. /**
  2079. * @remarks
  2080. * Custom Modifiers for linked messages.
  2081. *
  2082. * @VueI18nSee [Custom Modifiers](../guide/essentials/syntax#custom-modifiers)
  2083. */
  2084. readonly modifiers: Composition['modifiers'];
  2085. /**
  2086. * @remarks
  2087. * The formatter that implemented with Formatter interface.
  2088. *
  2089. * @deprecated See the [here](../guide/migration/breaking#remove-custom-formatter)
  2090. */
  2091. formatter: Formatter;
  2092. /**
  2093. * @remarks
  2094. * A handler for localization missing.
  2095. */
  2096. missing: MissingHandler | null;
  2097. /**
  2098. * @remarks
  2099. * A handler for post processing of translation.
  2100. */
  2101. postTranslation: PostTranslationHandler<VueMessageType> | null;
  2102. /**
  2103. * @remarks
  2104. * Whether suppress warnings outputted when localization fails.
  2105. *
  2106. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  2107. */
  2108. silentTranslationWarn: Composition['missingWarn'];
  2109. /**
  2110. * @remarks
  2111. * Whether suppress fallback warnings when localization fails.
  2112. */
  2113. silentFallbackWarn: Composition['fallbackWarn'];
  2114. /**
  2115. * @remarks
  2116. * Whether suppress warnings when falling back to either `fallbackLocale` or root.
  2117. *
  2118. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  2119. */
  2120. formatFallbackMessages: Composition['fallbackFormat'];
  2121. /**
  2122. * @remarks
  2123. * Whether synchronize the root level locale to the component localization locale.
  2124. *
  2125. * @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-2)
  2126. */
  2127. sync: Composition['inheritLocale'];
  2128. /**
  2129. * @remarks
  2130. * Whether to allow the use locale messages of HTML formatting.
  2131. *
  2132. * If you set `warn` or` error`, will check the locale messages on the VueI18n instance.
  2133. *
  2134. * If you are specified `warn`, a warning will be output at console.
  2135. *
  2136. * If you are specified `error` will occurred an Error.
  2137. *
  2138. * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message)
  2139. * @VueI18nSee [Change `warnHtmlInMessage` option default value](../guide/migration/breaking#change-warnhtmlinmessage-option-default-value)
  2140. */
  2141. warnHtmlInMessage: WarnHtmlInMessageLevel;
  2142. /**
  2143. * @remarks
  2144. * Whether interpolation parameters are escaped before the message is translated.
  2145. *
  2146. * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message)
  2147. */
  2148. escapeParameterHtml: Composition['escapeParameter'];
  2149. /**
  2150. * @remarks
  2151. * Whether `v-t` directive's element should preserve `textContent` after directive is unbinded.
  2152. *
  2153. * @VueI18nSee [Custom Directive](../guide/advanced/directive)
  2154. * @VueI18nSee [Remove preserveDirectiveContent option](../guide/migration/breaking#remove-preservedirectivecontent-option)
  2155. *
  2156. * @deprecated The `v-t` directive for Vue 3 now preserves the default content. Therefore, this option and its properties have been removed from the VueI18n instance.
  2157. */
  2158. preserveDirectiveContent: boolean;
  2159. /**
  2160. * A set of rules for word pluralization
  2161. *
  2162. * @VueI18nSee [Custom Pluralization](../guide/essentials/pluralization#custom-pluralization)
  2163. */
  2164. pluralizationRules: Composition['pluralRules'];
  2165. /**
  2166. * Locale message translation
  2167. *
  2168. * @remarks
  2169. * About details functions, See the {@link VueI18nTranslation}
  2170. */
  2171. t: VueI18nTranslation<Messages, Locales, RemoveIndexSignature<{
  2172. [K in keyof DefineLocaleMessage]: DefineLocaleMessage[K];
  2173. }>>;
  2174. /**
  2175. * Resolve locale message translation
  2176. *
  2177. * @remarks
  2178. * About details functions, See the {@link VueI18nResolveLocaleMessageTranslation}
  2179. */
  2180. rt: VueI18nResolveLocaleMessageTranslation<Locales>;
  2181. /**
  2182. * Locale message pluralization
  2183. *
  2184. * @remarks
  2185. * About details functions, See the {@link VueI18nTranslationChoice}
  2186. */
  2187. tc: VueI18nTranslationChoice<Messages, Locales, RemoveIndexSignature<{
  2188. [K in keyof DefineLocaleMessage]: DefineLocaleMessage[K];
  2189. }>>;
  2190. /**
  2191. * Translation locale message exist
  2192. *
  2193. * @remarks
  2194. * whether do exist locale message on VueI18n instance [messages](legacy#messages).
  2195. *
  2196. * If you specified `locale`, check the locale messages of `locale`.
  2197. *
  2198. * @param key - A target locale message key
  2199. * @param locale - A target locale
  2200. *
  2201. * @returns If found locale message, `true`, else `false`
  2202. */
  2203. te<Str extends string, Key extends PickupKeys<Messages> = PickupKeys<Messages>>(key: Str | Key, locale?: Locales): boolean;
  2204. /**
  2205. * Locale messages getter
  2206. *
  2207. * @remarks
  2208. * If [i18n component options](injection#i18n) is specified, it’s get in preferentially local scope locale messages than global scope locale messages.
  2209. *
  2210. * If [i18n component options](injection#i18n) isn't specified, it’s get with global scope locale messages.
  2211. *
  2212. * Based on the current `locale`, locale messages will be returned from Composer instance messages.
  2213. *
  2214. * If you change the `locale`, the locale messages returned will also correspond to the locale.
  2215. *
  2216. * If there are no locale messages for the given `key` in the composer instance messages, they will be returned with [fallbacking](../guide/essentials/fallback).
  2217. *
  2218. * @VueI18nWarning
  2219. * You need to use `rt` for the locale message returned by `tm`. see the [rt](legacy#rt-message) details.
  2220. *
  2221. * @example
  2222. * template:
  2223. * ```html
  2224. * <div class="container">
  2225. * <template v-for="content in $tm('contents')">
  2226. * <h2>{{ $rt(content.title) }}</h2>
  2227. * <p v-for="paragraph in content.paragraphs">
  2228. * {{ $rt(paragraph) }}
  2229. * </p>
  2230. * </template>
  2231. * </div>
  2232. * ```
  2233. *
  2234. * ```js
  2235. * import { createI18n } from 'vue-i18n'
  2236. *
  2237. * const i18n = createI18n({
  2238. * messages: {
  2239. * en: {
  2240. * contents: [
  2241. * {
  2242. * title: 'Title1',
  2243. * // ...
  2244. * paragraphs: [
  2245. * // ...
  2246. * ]
  2247. * }
  2248. * ]
  2249. * }
  2250. * }
  2251. * // ...
  2252. * })
  2253. * ```
  2254. * @param key - A target locale message key
  2255. *
  2256. * @return Locale messages
  2257. */
  2258. tm: Composition['tm'];
  2259. /**
  2260. * Get locale message
  2261. *
  2262. * @remarks
  2263. * get locale message from VueI18n instance [messages](legacy#messages).
  2264. *
  2265. * @param locale - A target locale
  2266. *
  2267. * @returns Locale messages
  2268. */
  2269. getLocaleMessage: Composition['getLocaleMessage'];
  2270. /**
  2271. * Set locale message
  2272. *
  2273. * @remarks
  2274. * Set locale message to VueI18n instance [messages](legacy#messages).
  2275. *
  2276. * @param locale - A target locale
  2277. * @param message - A message
  2278. */
  2279. setLocaleMessage: Composition['setLocaleMessage'];
  2280. /**
  2281. * Merge locale message
  2282. *
  2283. * @remarks
  2284. * Merge locale message to VueI18n instance [messages](legacy#messages).
  2285. *
  2286. * @param locale - A target locale
  2287. * @param message - A message
  2288. */
  2289. mergeLocaleMessage: Composition['mergeLocaleMessage'];
  2290. /**
  2291. * Datetime formatting
  2292. *
  2293. * @remarks
  2294. * About details functions, See the {@link VueI18nDateTimeFormatting}
  2295. */
  2296. d: VueI18nDateTimeFormatting<DateTimeFormats, Locales, RemoveIndexSignature<{
  2297. [K in keyof DefineDateTimeFormat]: DefineDateTimeFormat[K];
  2298. }>>;
  2299. /**
  2300. * Get datetime format
  2301. *
  2302. * @remarks
  2303. * get datetime format from VueI18n instance [datetimeFormats](legacy#datetimeformats).
  2304. *
  2305. * @param locale - A target locale
  2306. *
  2307. * @returns Datetime format
  2308. */
  2309. getDateTimeFormat: Composition['getDateTimeFormat'];
  2310. /**
  2311. * Set datetime format
  2312. *
  2313. * @remarks
  2314. * Set datetime format to VueI18n instance [datetimeFormats](legacy#datetimeformats).
  2315. *
  2316. * @param locale - A target locale
  2317. * @param format - A target datetime format
  2318. */
  2319. setDateTimeFormat: Composition['setDateTimeFormat'];
  2320. /**
  2321. * Merge datetime format
  2322. *
  2323. * @remarks
  2324. * Merge datetime format to VueI18n instance [datetimeFormats](legacy#datetimeformats).
  2325. *
  2326. * @param locale - A target locale
  2327. * @param format - A target datetime format
  2328. */
  2329. mergeDateTimeFormat: Composition['mergeDateTimeFormat'];
  2330. /**
  2331. * Number Formatting
  2332. *
  2333. * @remarks
  2334. * About details functions, See the {@link VueI18nNumberFormatting}
  2335. */
  2336. n: VueI18nNumberFormatting<NumberFormats, Locales, RemoveIndexSignature<{
  2337. [K in keyof DefineNumberFormat]: DefineNumberFormat[K];
  2338. }>>;
  2339. /**
  2340. * Get number format
  2341. *
  2342. * @remarks
  2343. * get number format from VueI18n instance [numberFormats](legacy#numberFormats).
  2344. *
  2345. * @param locale - A target locale
  2346. *
  2347. * @returns Number format
  2348. */
  2349. getNumberFormat: Composition['getNumberFormat'];
  2350. /**
  2351. * Set number format
  2352. *
  2353. * @remarks
  2354. * Set number format to VueI18n instance [numberFormats](legacy#numberFormats).
  2355. *
  2356. * @param locale - A target locale
  2357. * @param format - A target number format
  2358. */
  2359. setNumberFormat: Composition['setNumberFormat'];
  2360. /**
  2361. * Merge number format
  2362. *
  2363. * @remarks
  2364. * Merge number format to VueI18n instance [numberFormats](legacy#numberFormats).
  2365. *
  2366. * @param locale - A target locale
  2367. * @param format - A target number format
  2368. */
  2369. mergeNumberFormat: Composition['mergeNumberFormat'];
  2370. /**
  2371. * Get choice index
  2372. *
  2373. * @remarks
  2374. * Get pluralization index for current pluralizing number and a given amount of choices.
  2375. *
  2376. * @deprecated Use `pluralizationRules` option instead of `getChoiceIndex`.
  2377. */
  2378. getChoiceIndex: (choice: Choice, choicesLength: number) => number;
  2379. }
  2380. /**
  2381. * Datetime formatting functions for VueI18n legacy interfaces
  2382. *
  2383. * @remarks
  2384. * This is the interface for {@link VueI18n}
  2385. *
  2386. * @VueI18nLegacy
  2387. */
  2388. export declare interface VueI18nDateTimeFormatting<DateTimeFormats extends Record<string, any> = {}, Locales = 'en-US', DefinedDateTimeFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>, C = IsEmptyObject<DefinedDateTimeFormat> extends false ? PickupFormatPathKeys<{
  2389. [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K];
  2390. }> : 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> {
  2391. /**
  2392. * Datetime formatting
  2393. *
  2394. * @remarks
  2395. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  2396. *
  2397. * If [i18n component options](injection#i18n) is specified, it’s formatted in preferentially local scope datetime formats than global scope locale messages.
  2398. *
  2399. * If [i18n component options](injection#i18n) isn't specified, it’s formatted with global scope datetime formats.
  2400. *
  2401. * @param value - A value, timestamp number or `Date` instance
  2402. *
  2403. * @returns Formatted value
  2404. *
  2405. * @VueI18nSee [Datetime formatting](../guide/essentials/datetime)
  2406. */
  2407. (value: number | Date): DateTimeFormatResult;
  2408. /**
  2409. * Datetime formatting
  2410. *
  2411. * @remarks
  2412. * Overloaded `d`. About details, see the [call signature](legacy#value-number-date-datetimeformatresult) details.
  2413. *
  2414. * @param value - A value, timestamp number or `Date` instance
  2415. * @param key - A key of datetime formats
  2416. *
  2417. * @returns Formatted value
  2418. */
  2419. <Value extends number | Date = number, Key extends string = string>(value: Value, key: Key | ResourceKeys): DateTimeFormatResult;
  2420. /**
  2421. * Datetime formatting
  2422. *
  2423. * @remarks
  2424. * Overloaded `d`. About details, see the [call signature](legacy#value-number-date-datetimeformatresult) details.
  2425. *
  2426. * @param value - A value, timestamp number or `Date` instance
  2427. * @param key - A key of datetime formats
  2428. * @param locale - A locale, it will be used over than global scope or local scope.
  2429. *
  2430. * @returns Formatted value
  2431. */
  2432. <Value extends number | Date = number, Key extends string = string>(value: Value, key: Key | ResourceKeys, locale: Locales): DateTimeFormatResult;
  2433. /**
  2434. * Datetime formatting
  2435. *
  2436. * @remarks
  2437. * Overloaded `d`. About details, see the [call signature](legacy#value-number-date-datetimeformatresult) details.
  2438. *
  2439. * @param value - A value, timestamp number or `Date` instance
  2440. * @param args - An argument values
  2441. *
  2442. * @returns Formatted value
  2443. */
  2444. (value: number | Date, args: {
  2445. [key: string]: string | boolean | number;
  2446. }): DateTimeFormatResult;
  2447. }
  2448. export declare type VueI18nExtender = (vueI18n: VueI18n) => Disposer | undefined;
  2449. /**
  2450. * Number formatting functions for VueI18n legacy interfaces
  2451. *
  2452. * @remarks
  2453. * This is the interface for {@link VueI18n}
  2454. *
  2455. * @VueI18nLegacy
  2456. */
  2457. export declare interface VueI18nNumberFormatting<NumberFormats extends Record<string, any> = {}, Locales = 'en-US', DefinedNumberFormat extends RemovedIndexResources<DefineNumberFormat> = RemovedIndexResources<DefineNumberFormat>, C = IsEmptyObject<DefinedNumberFormat> extends false ? PickupFormatPathKeys<{
  2458. [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K];
  2459. }> : 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> {
  2460. /**
  2461. * Number formatting
  2462. *
  2463. * @remarks
  2464. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  2465. *
  2466. * If [i18n component options](injection#i18n) is specified, it’s formatted in preferentially local scope number formats than global scope locale messages.
  2467. *
  2468. * If [i18n component options](injection#i18n) isn't specified, it’s formatted with global scope number formats.
  2469. *
  2470. * @param value - A number value
  2471. *
  2472. * @returns Formatted value
  2473. *
  2474. * @VueI18nSee [Number formatting](../guide/essentials/number)
  2475. */
  2476. (value: number): NumberFormatResult;
  2477. /**
  2478. * Number formatting
  2479. *
  2480. * @remarks
  2481. * Overloaded `n`. About details, see the [call signature](legacy#value-number-numberformatresult) details.
  2482. *
  2483. * @param value - A number value
  2484. * @param key - A key of number formats
  2485. *
  2486. * @returns Formatted value
  2487. */
  2488. <Key extends string = string>(value: number, key: Key | ResourceKeys): NumberFormatResult;
  2489. /**
  2490. * Number formatting
  2491. *
  2492. * @remarks
  2493. * Overloaded `n`. About details, see the [call signature](legacy#value-number-numberformatresult) details.
  2494. *
  2495. * @param value - A number value
  2496. * @param key - A key of number formats
  2497. * @param locale - A locale, it will be used over than global scope or local scope.
  2498. *
  2499. * @returns Formatted value
  2500. */
  2501. <Key extends string = string>(value: number, key: Key | ResourceKeys, locale: Locales): NumberFormatResult;
  2502. /**
  2503. * Number formatting
  2504. *
  2505. * @remarks
  2506. * Overloaded `n`. About details, see the [call signature](legacy#value-number-numberformatresult) details.
  2507. *
  2508. * @param value - A number value
  2509. * @param args - An argument values
  2510. *
  2511. * @returns Formatted value
  2512. */
  2513. (value: number, args: {
  2514. [key: string]: string | boolean | number;
  2515. }): NumberFormatResult;
  2516. }
  2517. /**
  2518. * VueI18n Options
  2519. *
  2520. * @remarks
  2521. * This option is compatible with `VueI18n` class constructor options (offered with Vue I18n v8.x)
  2522. *
  2523. * @VueI18nLegacy
  2524. */
  2525. export declare interface VueI18nOptions<Schema extends {
  2526. message?: unknown;
  2527. datetime?: unknown;
  2528. number?: unknown;
  2529. } = {
  2530. message: DefaultLocaleMessageSchema;
  2531. datetime: DefaultDateTimeFormatSchema;
  2532. number: DefaultNumberFormatSchema;
  2533. }, Locales extends {
  2534. messages: unknown;
  2535. datetimeFormats: unknown;
  2536. numberFormats: unknown;
  2537. } | string = Locale, Options extends ComposerOptions<Schema, Locales> = ComposerOptions<Schema, Locales>> {
  2538. /**
  2539. * @remarks
  2540. * The locale of localization.
  2541. *
  2542. * If the locale contains a territory and a dialect, this locale contains an implicit fallback.
  2543. *
  2544. * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope)
  2545. *
  2546. * @defaultValue `'en-US'`
  2547. */
  2548. locale?: Options['locale'];
  2549. /**
  2550. * @remarks
  2551. * The locale of fallback localization.
  2552. *
  2553. * For more complex fallback definitions see fallback.
  2554. *
  2555. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  2556. *
  2557. * @defaultValue The default `'en-US'` for the `locale` if it's not specified, or it's `locale` value
  2558. */
  2559. fallbackLocale?: Options['fallbackLocale'];
  2560. /**
  2561. * @remarks
  2562. * The locale messages of localization.
  2563. *
  2564. * @VueI18nSee [Getting Started](../guide/)
  2565. *
  2566. * @defaultValue `{}`
  2567. */
  2568. messages?: Options['messages'];
  2569. /**
  2570. * @remarks
  2571. * Allow use flat json messages or not
  2572. *
  2573. * @defaultValue `false`
  2574. */
  2575. flatJson?: Options['flatJson'];
  2576. /**
  2577. * @remarks
  2578. * The datetime formats of localization.
  2579. *
  2580. * @VueI18nSee [Datetime Formatting](../guide/essentials/datetime)
  2581. *
  2582. * @defaultValue `{}`
  2583. */
  2584. datetimeFormats?: Options['datetimeFormats'];
  2585. /**
  2586. * @remarks
  2587. * The number formats of localization.
  2588. *
  2589. * @VueI18nSee [Number Formatting](../guide/essentials/number)
  2590. *
  2591. * @defaultValue `{}`
  2592. */
  2593. numberFormats?: Options['numberFormats'];
  2594. /**
  2595. * @remarks
  2596. * The list of available locales in messages in lexical order.
  2597. *
  2598. * @defaultValue `[]`
  2599. */
  2600. availableLocales?: Locale[];
  2601. /**
  2602. * @remarks
  2603. * Custom Modifiers for linked messages.
  2604. *
  2605. * @VueI18nSee [Custom Modifiers](../guide/essentials/syntax#custom-modifiers)
  2606. */
  2607. modifiers?: Options['modifiers'];
  2608. /**
  2609. * @remarks
  2610. * The formatter that implemented with Formatter interface.
  2611. *
  2612. * @deprecated See the [here](../guide/migration/breaking#remove-custom-formatter)
  2613. */
  2614. formatter?: Formatter;
  2615. /**
  2616. * @remarks
  2617. * A handler for localization missing.
  2618. *
  2619. * The handler gets called with the localization target locale, localization path key, the Vue instance and values.
  2620. *
  2621. * If missing handler is assigned, and occurred localization missing, it's not warned.
  2622. *
  2623. * @defaultValue `null`
  2624. */
  2625. missing?: Options['missing'];
  2626. /**
  2627. * @remarks
  2628. * In the component localization, whether to fall back to root level (global scope) localization when localization fails.
  2629. *
  2630. * If `false`, it's not fallback to root.
  2631. *
  2632. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  2633. *
  2634. * @defaultValue `true`
  2635. */
  2636. fallbackRoot?: Options['fallbackRoot'];
  2637. /**
  2638. * @remarks
  2639. * Whether suppress warnings outputted when localization fails.
  2640. *
  2641. * If `true`, suppress localization fail warnings.
  2642. *
  2643. * If you use regular expression, you can suppress localization fail warnings that it match with translation key (e.g. `t`).
  2644. *
  2645. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  2646. *
  2647. * @defaultValue `false`
  2648. */
  2649. silentTranslationWarn?: Options['missingWarn'];
  2650. /**
  2651. * @remarks
  2652. * Whether do template interpolation on translation keys when your language lacks a translation for a key.
  2653. *
  2654. * If `true`, skip writing templates for your "base" language; the keys are your templates.
  2655. *
  2656. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  2657. *
  2658. * @defaultValue `false`
  2659. */
  2660. silentFallbackWarn?: Options['fallbackWarn'];
  2661. /**
  2662. * @remarks
  2663. * Whether suppress warnings when falling back to either `fallbackLocale` or root.
  2664. *
  2665. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  2666. *
  2667. * @defaultValue `false`
  2668. */
  2669. formatFallbackMessages?: Options['fallbackFormat'];
  2670. /**
  2671. * @remarks
  2672. * Whether `v-t` directive's element should preserve `textContent` after directive is unbinded.
  2673. *
  2674. * @VueI18nSee [Custom Directive](../guide/advanced/directive)
  2675. * @VueI18nSee [Remove `preserveDirectiveContent` option](../guide/migration/breaking#remove-preservedirectivecontent-option)
  2676. *
  2677. * @defaultValue `false`
  2678. *
  2679. * @deprecated The `v-t` directive for Vue 3 now preserves the default content. Therefore, this option and its properties have been removed from the VueI18n instance.
  2680. */
  2681. preserveDirectiveContent?: boolean;
  2682. /**
  2683. * @remarks
  2684. * Whether to allow the use locale messages of HTML formatting.
  2685. *
  2686. * See the warnHtmlInMessage property.
  2687. *
  2688. * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message)
  2689. * @VueI18nSee [Change `warnHtmlInMessage` option default value](../guide/migration/breaking#change-warnhtmlinmessage-option-default-value)
  2690. *
  2691. * @defaultValue `'off'`
  2692. */
  2693. warnHtmlInMessage?: WarnHtmlInMessageLevel;
  2694. /**
  2695. * @remarks
  2696. * If `escapeParameterHtml` is configured as true then interpolation parameters are escaped before the message is translated.
  2697. *
  2698. * This is useful when translation output is used in `v-html` and the translation resource contains html markup (e.g. <b> around a user provided value).
  2699. *
  2700. * This usage pattern mostly occurs when passing precomputed text strings into UI components.
  2701. *
  2702. * The escape process involves replacing the following symbols with their respective HTML character entities: `<`, `>`, `"`, `'`.
  2703. *
  2704. * Setting `escapeParameterHtml` as true should not break existing functionality but provides a safeguard against a subtle type of XSS attack vectors.
  2705. *
  2706. * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message)
  2707. *
  2708. * @defaultValue `false`
  2709. */
  2710. escapeParameterHtml?: Options['escapeParameter'];
  2711. /**
  2712. * @remarks
  2713. * The shared locale messages of localization for components. More detail see Component based localization.
  2714. *
  2715. * @VueI18nSee [Shared locale messages for components](../guide/essentials/local#shared-locale-messages-for-components)
  2716. *
  2717. * @defaultValue `undefined`
  2718. */
  2719. sharedMessages?: LocaleMessages<VueMessageType>;
  2720. /**
  2721. * @remarks
  2722. * A set of rules for word pluralization
  2723. *
  2724. * @VueI18nSee [Custom Pluralization](../guide/essentials/pluralization#custom-pluralization)
  2725. *
  2726. * @defaultValue `{}`
  2727. */
  2728. pluralizationRules?: Options['pluralRules'];
  2729. /**
  2730. * @remarks
  2731. * A handler for post processing of translation. The handler gets after being called with the `$t`, `t`, `$tc`, and `tc`.
  2732. *
  2733. * This handler is useful if you want to filter on translated text such as space trimming.
  2734. *
  2735. * @defaultValue `null`
  2736. */
  2737. postTranslation?: Options['postTranslation'];
  2738. /**
  2739. * @remarks
  2740. * Whether synchronize the root level locale to the component localization locale.
  2741. *
  2742. * If `false`, regardless of the root level locale, localize for each component locale.
  2743. *
  2744. * @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-2)
  2745. *
  2746. * @defaultValue `true`
  2747. */
  2748. sync?: boolean;
  2749. /**
  2750. * @remarks
  2751. * A message resolver to resolve [`messages`](legacy#messages).
  2752. *
  2753. * If not specified, the vue-i18n internal message resolver will be used by default.
  2754. *
  2755. * You need to implement a message resolver yourself that supports the following requirements:
  2756. *
  2757. * - Resolve the message using the locale message of [`locale`](legacy#locale) passed as the first argument of the message resolver, and the path passed as the second argument.
  2758. *
  2759. * - If the message could not be resolved, you need to return `null`.
  2760. *
  2761. * - If you will be returned `null`, the message resolver will also be called on fallback if [`fallbackLocale`](legacy#fallbacklocale-2) is enabled, so the message will need to be resolved as well.
  2762. *
  2763. * The message resolver is called indirectly by the following APIs:
  2764. *
  2765. * - [`t`](legacy#t-key)
  2766. *
  2767. * - [`tc`](legacy#tc-key)
  2768. *
  2769. * - [`te`](legacy#te-key-locale)
  2770. *
  2771. * - [`tm`](legacy#tm-key)
  2772. *
  2773. * - [Translation component](component#translation)
  2774. *
  2775. * @example
  2776. * Here is an example of how to set it up using your `createI18n`:
  2777. * ```js
  2778. * import { createI18n } from 'vue-i18n'
  2779. *
  2780. * // your message resolver
  2781. * function messageResolver(obj, path) {
  2782. * // simple message resolving!
  2783. * const msg = obj[path]
  2784. * return msg != null ? msg : null
  2785. * }
  2786. *
  2787. * // call with I18n option
  2788. * const i18n = createI18n({
  2789. * locale: 'ja',
  2790. * messageResolver, // set your message resolver
  2791. * messages: {
  2792. * en: { ... },
  2793. * ja: { ... }
  2794. * }
  2795. * })
  2796. *
  2797. * // the below your something to do ...
  2798. * // ...
  2799. * ```
  2800. *
  2801. * @VueI18nTip
  2802. * :new: v9.2+
  2803. *
  2804. * @VueI18nWarning
  2805. * If you use the message resolver, the [`flatJson`](legacy#flatjson) setting will be ignored. That is, you need to resolve the flat JSON by yourself.
  2806. *
  2807. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  2808. *
  2809. * @defaultValue `undefined`
  2810. */
  2811. messageResolver?: MessageResolver;
  2812. }
  2813. /**
  2814. * Resolve locale message translation functions for VueI18n legacy interfaces
  2815. *
  2816. * @remarks
  2817. * This is the interface for {@link VueI18n}. This interface is an alias of {@link ComposerResolveLocaleMessageTranslation}.
  2818. *
  2819. * @VueI18nLegacy
  2820. */
  2821. export declare type VueI18nResolveLocaleMessageTranslation<Locales = 'en-US'> = ComposerResolveLocaleMessageTranslation<Locales>;
  2822. /**
  2823. * Locale message translation functions for VueI18n legacy interfaces
  2824. *
  2825. * @remarks
  2826. * This is the interface for {@link VueI18n}
  2827. *
  2828. * @VueI18nLegacy
  2829. */
  2830. export declare interface VueI18nTranslation<Messages extends Record<string, any> = {}, Locales = 'en-US', DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>, C = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  2831. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  2832. }> : 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> {
  2833. /**
  2834. * Locale message translation.
  2835. *
  2836. * @remarks
  2837. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  2838. *
  2839. * If [i18n component options](injection#i18n) is specified, it’s translated in preferentially local scope locale messages than global scope locale messages.
  2840. *
  2841. * If [i18n component options](injection#i18n) isn't specified, it’s translated with global scope locale messages.
  2842. *
  2843. * @param key - A target locale message key
  2844. *
  2845. * @returns Translated message
  2846. *
  2847. * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope)
  2848. */
  2849. <Key extends string>(key: Key | ResourceKeys): TranslateResult;
  2850. /**
  2851. * Locale message translation.
  2852. *
  2853. * @remarks
  2854. * Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details.
  2855. *
  2856. * @param key - A target locale message key
  2857. * @param locale - A locale, it will be used over than global scope or local scope.
  2858. *
  2859. * @returns Translated message
  2860. */
  2861. <Key extends string>(key: Key | ResourceKeys, locale: Locales | Locale): TranslateResult;
  2862. /**
  2863. * Locale message translation.
  2864. *
  2865. * @remarks
  2866. * Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details.
  2867. *
  2868. * @param key - A target locale message key
  2869. * @param locale - A locale, it will be used over than global scope or local scope.
  2870. * @param list - A values of list interpolation
  2871. *
  2872. * @returns Translated message
  2873. *
  2874. * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation)
  2875. */
  2876. <Key extends string>(key: Key | ResourceKeys, locale: Locales | Locale, list: unknown[]): TranslateResult;
  2877. /**
  2878. * Locale message translation.
  2879. *
  2880. * @remarks
  2881. * Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details.
  2882. *
  2883. * @param key - A target locale message key
  2884. * @param locale - A locale, it will be used over than global scope or local scope.
  2885. * @param named - A values of named interpolation
  2886. *
  2887. * @returns Translated message
  2888. *
  2889. * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation)
  2890. */
  2891. <Key extends string>(key: Key | ResourceKeys, locale: Locales | Locale, named: Record<string, unknown>): TranslateResult;
  2892. /**
  2893. * Locale message translation.
  2894. *
  2895. * @remarks
  2896. * Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details.
  2897. *
  2898. * @param key - A target locale message key
  2899. * @param list - A values of list interpolation
  2900. *
  2901. * @returns Translated message
  2902. *
  2903. * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation)
  2904. */
  2905. <Key extends string>(key: Key | ResourceKeys, list: unknown[]): TranslateResult;
  2906. /**
  2907. * Locale message translation.
  2908. *
  2909. * @remarks
  2910. * Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details.
  2911. *
  2912. * @param key - A target locale message key
  2913. * @param named - A values of named interpolation
  2914. *
  2915. * @returns Translated message
  2916. *
  2917. * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation)
  2918. */
  2919. <Key extends string>(key: Key | ResourceKeys, named: Record<string, unknown>): TranslateResult;
  2920. }
  2921. /**
  2922. * Locale message pluralization functions for VueI18n legacy interfaces
  2923. *
  2924. * @remarks
  2925. * This is the interface for {@link VueI18n}
  2926. *
  2927. * @VueI18nLegacy
  2928. */
  2929. export declare interface VueI18nTranslationChoice<Messages extends Record<string, any> = {}, Locales = 'en-US', DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>, C = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  2930. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  2931. }> : 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> {
  2932. /**
  2933. * Locale message pluralization
  2934. *
  2935. * @remarks
  2936. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  2937. *
  2938. * If [i18n component options](injection#i18n) is specified, it’s pluraled in preferentially local scope locale messages than global scope locale messages.
  2939. *
  2940. * If [i18n component options](injection#i18n) isn't specified, it’s pluraled with global scope locale messages.
  2941. *
  2942. * The plural choice number is handled with default `1`.
  2943. *
  2944. * @param key - A target locale message key
  2945. *
  2946. * @returns Pluraled message
  2947. *
  2948. * @VueI18nSee [Pluralization](../guide/essentials/pluralization)
  2949. */
  2950. <Key extends string = string>(key: Key | ResourceKeys): TranslateResult;
  2951. /**
  2952. * Locale message pluralization
  2953. *
  2954. * @remarks
  2955. * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details.
  2956. *
  2957. * @param key - A target locale message key
  2958. * @param locale - A locale, it will be used over than global scope or local scope.
  2959. *
  2960. * @returns Pluraled message
  2961. */
  2962. <Key extends string = string>(key: Key | ResourceKeys, locale: Locales | Locale): TranslateResult;
  2963. /**
  2964. * Locale message pluralization
  2965. *
  2966. * @remarks
  2967. * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details.
  2968. *
  2969. * @param key - A target locale message key
  2970. * @param list - A values of list interpolation
  2971. *
  2972. * @returns Pluraled message
  2973. */
  2974. <Key extends string>(key: Key | ResourceKeys, list: unknown[]): TranslateResult;
  2975. /**
  2976. * Locale message pluralization
  2977. *
  2978. * @remarks
  2979. * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details.
  2980. *
  2981. * @param key - A target locale message key
  2982. * @param named - A values of named interpolation
  2983. *
  2984. * @returns Pluraled message
  2985. */
  2986. <Key extends string>(key: Key | ResourceKeys, named: Record<string, unknown>): TranslateResult;
  2987. /**
  2988. * Locale message pluralization
  2989. *
  2990. * @remarks
  2991. * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details.
  2992. *
  2993. * @param key - A target locale message key
  2994. * @param choice - Which plural string to get. 1 returns the first one.
  2995. *
  2996. * @returns Pluraled message
  2997. */
  2998. <Key extends string>(key: Key | ResourceKeys, choice: number): TranslateResult;
  2999. /**
  3000. * Locale message pluralization
  3001. *
  3002. * @remarks
  3003. * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details.
  3004. *
  3005. * @param key - A target locale message key
  3006. * @param choice - Which plural string to get. 1 returns the first one.
  3007. * @param locale - A locale, it will be used over than global scope or local scope.
  3008. *
  3009. * @returns Pluraled message
  3010. */
  3011. <Key extends string>(key: Key | ResourceKeys, choice: number, locale: Locales | Locale): TranslateResult;
  3012. /**
  3013. * Locale message pluralization
  3014. *
  3015. * @remarks
  3016. * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details.
  3017. *
  3018. * @param key - A target locale message key
  3019. * @param choice - Which plural string to get. 1 returns the first one.
  3020. * @param list - A values of list interpolation
  3021. *
  3022. * @returns Pluraled message
  3023. */
  3024. <Key extends string>(key: Key | ResourceKeys, choice: number, list: unknown[]): TranslateResult;
  3025. /**
  3026. * Locale message pluralization
  3027. *
  3028. * @remarks
  3029. * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details.
  3030. *
  3031. * @param key - A target locale message key
  3032. * @param choice - Which plural string to get. 1 returns the first one.
  3033. * @param named - A values of named interpolation
  3034. *
  3035. * @returns Pluraled message
  3036. */
  3037. <Key extends string>(key: Key | ResourceKeys, choice: number, named: Record<string, unknown>): TranslateResult;
  3038. }
  3039. /** @VueI18nComposition */
  3040. export declare type VueMessageType = string | ResourceNode | VNode;
  3041. export declare type WarnHtmlInMessageLevel = 'off' | 'warn' | 'error';
  3042. export { }
  3043. declare module '@vue/runtime-core' {
  3044. /**
  3045. * Component Custom Options for Vue I18n
  3046. *
  3047. * @VueI18nInjection
  3048. */
  3049. export interface ComponentCustomOptions {
  3050. /**
  3051. * VueI18n options
  3052. *
  3053. * @remarks
  3054. * See the {@link VueI18nOptions}
  3055. */
  3056. i18n?: VueI18nOptions
  3057. /**
  3058. * For custom blocks options
  3059. * @internal
  3060. */
  3061. __i18n?: CustomBlocks
  3062. /**
  3063. * For devtools
  3064. * @internal
  3065. */
  3066. __INTLIFY_META__?: string
  3067. }
  3068. /**
  3069. * Component Custom Properties for Vue I18n
  3070. *
  3071. * @VueI18nInjection
  3072. */
  3073. export interface ComponentCustomProperties {
  3074. /**
  3075. * Exported Global Composer instance, or global VueI18n instance.
  3076. *
  3077. * @remarks
  3078. * You can get the {@link ExportedGlobalComposer | exported composer instance} which are exported from global {@link Composer | composer instance} created with {@link createI18n}, or global {@link VueI18n | VueI18n instance}.
  3079. * You can get the exported composer instance in {@link I18nMode | Composition API mode}, or the Vuei18n instance in {@link I18nMode | Legacy API mode}, which is the instance you can refer to with this property.
  3080. * The locales, locale messages, and other resources managed by the instance referenced by this property are valid as global scope.
  3081. * If the `i18n` component custom option is not specified, it's the same as the VueI18n instance that can be referenced by the i18n instance {@link I18n.global | global} property.
  3082. */
  3083. $i18n: VueI18n | ExportedGlobalComposer
  3084. /**
  3085. * Locale message translation
  3086. *
  3087. * @remarks
  3088. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  3089. *
  3090. * In {@link I18nMode | Legacy API mode}, the input / output is the same as for VueI18n instance. About that details, see {@link VueI18n#t | `VueI18n#t`}.
  3091. *
  3092. * In {@link I18nMode | Composition API mode}, the `$t` is injected by `app.config.globalProperties`.
  3093. * the input / output is the same as for Composer, and it work on **global scope**. About that details, see {@link Composer#t | `Composer#t` }.
  3094. *
  3095. * @param key - A target locale message key
  3096. *
  3097. * @returns translation message
  3098. */
  3099. $t<
  3100. Key extends string,
  3101. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3102. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3103. ? PickupPaths<{
  3104. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3105. }>
  3106. : never,
  3107. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3108. >(
  3109. key: Key | ResourceKeys | Path
  3110. ): TranslateResult
  3111. /**
  3112. * Locale message translation
  3113. *
  3114. * @remarks
  3115. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3116. *
  3117. * @param key - A target locale message key
  3118. * @param locale - A locale, override locale that global scope or local scope
  3119. *
  3120. * @returns translation message
  3121. */
  3122. $t<
  3123. Key extends string,
  3124. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3125. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3126. ? PickupPaths<{
  3127. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3128. }>
  3129. : never,
  3130. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3131. >(
  3132. key: Key | ResourceKeys | Path
  3133. ): TranslateResult
  3134. /**
  3135. * Locale message translation
  3136. *
  3137. * @remarks
  3138. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3139. *
  3140. * @param key - A target locale message key
  3141. * @param locale - A locale, override locale that global scope or local scope
  3142. * @param list - A values of list interpolation
  3143. *
  3144. * @returns translation message
  3145. */
  3146. $t<
  3147. Key extends string,
  3148. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3149. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3150. ? PickupPaths<{
  3151. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3152. }>
  3153. : never,
  3154. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3155. >(
  3156. key: Key | ResourceKeys | Path,
  3157. locale: Locale,
  3158. list: unknown[]
  3159. ): TranslateResult
  3160. /**
  3161. * Locale message translation
  3162. *
  3163. * @remarks
  3164. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3165. *
  3166. * @param key - A target locale message key
  3167. * @param locale - A locale, override locale that global scope or local scope
  3168. * @param named - A values of named interpolation
  3169. *
  3170. * @returns translation message
  3171. */
  3172. $t<
  3173. Key extends string,
  3174. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3175. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3176. ? PickupPaths<{
  3177. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3178. }>
  3179. : never,
  3180. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3181. >(
  3182. key: Key | ResourceKeys | Path,
  3183. locale: Locale,
  3184. named: object
  3185. ): TranslateResult
  3186. /**
  3187. * Locale message translation
  3188. *
  3189. * @remarks
  3190. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3191. *
  3192. * @param key - A target locale message key
  3193. * @param list - A values of list interpolation
  3194. *
  3195. * @returns translation message
  3196. */
  3197. $t<
  3198. Key extends string,
  3199. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3200. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3201. ? PickupPaths<{
  3202. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3203. }>
  3204. : never,
  3205. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3206. >(
  3207. key: Key | ResourceKeys | Path,
  3208. list: unknown[]
  3209. ): TranslateResult
  3210. /**
  3211. * Locale message translation
  3212. *
  3213. * @remarks
  3214. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3215. *
  3216. * @param key - A target locale message key
  3217. * @param named - A values of named interpolation
  3218. *
  3219. * @returns translation message
  3220. */
  3221. $t<
  3222. Key extends string,
  3223. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3224. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3225. ? PickupPaths<{
  3226. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3227. }>
  3228. : never,
  3229. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3230. >(
  3231. key: Key | ResourceKeys | Path,
  3232. named: Record<string, unknown>
  3233. ): TranslateResult
  3234. /**
  3235. * Locale message translation
  3236. *
  3237. * @remarks
  3238. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3239. *
  3240. * @param key - A target locale message key
  3241. *
  3242. * @returns translation message
  3243. */
  3244. $t<
  3245. Key extends string,
  3246. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3247. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3248. ? PickupPaths<{
  3249. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3250. }>
  3251. : never,
  3252. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3253. >(
  3254. key: Key | ResourceKeys | Path
  3255. ): string
  3256. /**
  3257. * Locale message translation
  3258. *
  3259. * @remarks
  3260. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3261. *
  3262. * @param key - A target locale message key
  3263. * @param plural - A choice number of plural
  3264. *
  3265. * @returns translation message
  3266. */
  3267. $t<
  3268. Key extends string,
  3269. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3270. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3271. ? PickupPaths<{
  3272. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3273. }>
  3274. : never,
  3275. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3276. >(
  3277. key: Key | ResourceKeys | Path,
  3278. plural: number
  3279. ): string
  3280. /**
  3281. * Locale message translation
  3282. *
  3283. * @remarks
  3284. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3285. *
  3286. * @param key - A target locale message key
  3287. * @param plural - Which plural string to get. 1 returns the first one.
  3288. * @param options - An options, see the {@link TranslateOptions}
  3289. *
  3290. * @returns translation message
  3291. */
  3292. $t<
  3293. Key extends string,
  3294. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3295. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3296. ? PickupPaths<{
  3297. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3298. }>
  3299. : never,
  3300. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3301. >(
  3302. key: Key | ResourceKeys | Path,
  3303. plural: number,
  3304. options: TranslateOptions
  3305. ): string
  3306. /**
  3307. * Locale message translation
  3308. *
  3309. * @remarks
  3310. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3311. *
  3312. * @param key - A target locale message key
  3313. * @param defaultMsg - A default message to return if no translation was found
  3314. *
  3315. * @returns translation message
  3316. */
  3317. $t<
  3318. Key extends string,
  3319. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3320. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3321. ? PickupPaths<{
  3322. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3323. }>
  3324. : never,
  3325. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3326. >(
  3327. key: Key | ResourceKeys | Path,
  3328. defaultMsg: string
  3329. ): string
  3330. /**
  3331. * Locale message translation
  3332. *
  3333. * @remarks
  3334. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3335. *
  3336. * @param key - A target locale message key
  3337. * @param defaultMsg - A default message to return if no translation was found
  3338. * @param options - An options, see the {@link TranslateOptions}
  3339. *
  3340. * @returns translation message
  3341. */
  3342. $t<
  3343. Key extends string,
  3344. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3345. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3346. ? PickupPaths<{
  3347. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3348. }>
  3349. : never,
  3350. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3351. >(
  3352. key: Key | ResourceKeys | Path,
  3353. defaultMsg: string,
  3354. options: TranslateOptions
  3355. ): string
  3356. /**
  3357. * Locale message translation
  3358. *
  3359. * @remarks
  3360. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3361. *
  3362. * @param key - A target locale message key
  3363. * @param list - A values of list interpolation
  3364. *
  3365. * @returns translation message
  3366. */
  3367. $t<
  3368. Key extends string,
  3369. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3370. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3371. ? PickupPaths<{
  3372. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3373. }>
  3374. : never,
  3375. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3376. >(
  3377. key: Key | ResourceKeys | Path,
  3378. list: unknown[]
  3379. ): string
  3380. /**
  3381. * Locale message translation
  3382. *
  3383. * @remarks
  3384. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3385. *
  3386. * @param key - A target locale message key
  3387. * @param list - A values of list interpolation
  3388. * @param plural - A choice number of plural
  3389. *
  3390. * @returns translation message
  3391. */
  3392. $t<
  3393. Key extends string,
  3394. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3395. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3396. ? PickupPaths<{
  3397. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3398. }>
  3399. : never,
  3400. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3401. >(
  3402. key: Key | ResourceKeys | Path,
  3403. list: unknown[],
  3404. plural: number
  3405. ): string
  3406. /**
  3407. * Locale message translation
  3408. *
  3409. * @remarks
  3410. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3411. *
  3412. * @param key - A target locale message key
  3413. * @param list - A values of list interpolation
  3414. * @param defaultMsg - A default message to return if no translation was found
  3415. *
  3416. * @returns translation message
  3417. */
  3418. $t<
  3419. Key extends string,
  3420. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3421. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3422. ? PickupPaths<{
  3423. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3424. }>
  3425. : never,
  3426. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3427. >(
  3428. key: Key | ResourceKeys | Path,
  3429. list: unknown[],
  3430. defaultMsg: string
  3431. ): string
  3432. /**
  3433. * Locale message translation
  3434. *
  3435. * @remarks
  3436. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3437. *
  3438. * @param key - A target locale message key
  3439. * @param list - A values of list interpolation
  3440. * @param options - An options, see the {@link TranslateOptions}
  3441. *
  3442. * @returns translation message
  3443. */
  3444. $t<
  3445. Key extends string,
  3446. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3447. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3448. ? PickupPaths<{
  3449. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3450. }>
  3451. : never,
  3452. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3453. >(
  3454. key: Key | ResourceKeys | Path,
  3455. list: unknown[],
  3456. options: TranslateOptions
  3457. ): string
  3458. /**
  3459. * Locale message translation
  3460. *
  3461. * @remarks
  3462. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3463. *
  3464. * @param key - A target locale message key
  3465. * @param named - A values of named interpolation
  3466. *
  3467. * @returns translation message
  3468. */
  3469. $t<
  3470. Key extends string,
  3471. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3472. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3473. ? PickupPaths<{
  3474. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3475. }>
  3476. : never,
  3477. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3478. >(
  3479. key: Key | ResourceKeys | Path,
  3480. named: NamedValue
  3481. ): string
  3482. /**
  3483. * Locale message translation
  3484. *
  3485. * @remarks
  3486. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3487. *
  3488. * @param key - A target locale message key
  3489. * @param named - A values of named interpolation
  3490. * @param plural - A choice number of plural
  3491. *
  3492. * @returns translation message
  3493. */
  3494. $t<
  3495. Key extends string,
  3496. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3497. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3498. ? PickupPaths<{
  3499. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3500. }>
  3501. : never,
  3502. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3503. >(
  3504. key: Key | ResourceKeys | Path,
  3505. named: NamedValue,
  3506. plural: number
  3507. ): string
  3508. /**
  3509. * Locale message translation
  3510. *
  3511. * @remarks
  3512. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3513. *
  3514. * @param key - A target locale message key
  3515. * @param named - A values of named interpolation
  3516. * @param defaultMsg - A default message to return if no translation was found
  3517. *
  3518. * @returns translation message
  3519. */
  3520. $t<
  3521. Key extends string,
  3522. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3523. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3524. ? PickupPaths<{
  3525. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3526. }>
  3527. : never,
  3528. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3529. >(
  3530. key: Key | ResourceKeys | Path,
  3531. named: NamedValue,
  3532. defaultMsg: string
  3533. ): string
  3534. /**
  3535. * Locale message translation
  3536. *
  3537. * @remarks
  3538. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3539. *
  3540. * @param key - A target locale message key
  3541. * @param named - A values of named interpolation
  3542. * @param options - An options, see the {@link TranslateOptions}
  3543. *
  3544. * @returns translation message
  3545. */
  3546. $t<
  3547. Key extends string,
  3548. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3549. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3550. ? PickupPaths<{
  3551. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3552. }>
  3553. : never,
  3554. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3555. >(
  3556. key: Key | ResourceKeys | Path,
  3557. named: NamedValue,
  3558. options: TranslateOptions
  3559. ): string
  3560. /**
  3561. * Resolve locale message translation
  3562. *
  3563. * @remarks
  3564. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  3565. *
  3566. * 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`}.
  3567. *
  3568. * In {@link I18nMode | Composition API mode}, the `$rt` is injected by `app.config.globalProperties`.
  3569. * the input / output is the same as for Composer, and it work on **global scope**. About that details, see {@link Composer#rt | `Composer#rt` }.
  3570. *
  3571. * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `$tm`.
  3572. *
  3573. * @returns translated message
  3574. */
  3575. $rt(message: MessageFunction<VueMessageType> | VueMessageType): string
  3576. /**
  3577. * Resolve locale message translation for plurals
  3578. *
  3579. * @remarks
  3580. * Overloaded `$rt`. About details, see the {@link $rt} remarks.
  3581. *
  3582. * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `$tm`.
  3583. * @param plural - Which plural string to get. 1 returns the first one.
  3584. * @param options - Additional {@link TranslateOptions | options} for translation
  3585. *
  3586. * @returns Translated message
  3587. */
  3588. $rt(
  3589. message: MessageFunction<VueMessageType> | VueMessageType,
  3590. plural: number,
  3591. options?: TranslateOptions
  3592. ): string
  3593. /**
  3594. * Resolve locale message translation for list interpolations
  3595. *
  3596. * @remarks
  3597. * Overloaded `$rt`. About details, see the {@link $rt} remarks.
  3598. *
  3599. * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `$tm`.
  3600. * @param list - A values of list interpolation.
  3601. * @param options - Additional {@link TranslateOptions | options} for translation
  3602. *
  3603. * @returns Translated message
  3604. */
  3605. $rt(
  3606. message: MessageFunction<VueMessageType> | VueMessageType,
  3607. list: unknown[],
  3608. options?: TranslateOptions
  3609. ): string
  3610. /**
  3611. * Resolve locale message translation for named interpolations
  3612. *
  3613. * @remarks
  3614. * Overloaded `$rt`. About details, see the {@link $rt} remarks.
  3615. *
  3616. * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `$tm`.
  3617. * @param named - A values of named interpolation.
  3618. * @param options - Additional {@link TranslateOptions | options} for translation
  3619. *
  3620. * @returns Translated message
  3621. */
  3622. $rt(
  3623. message: MessageFunction<VueMessageType> | VueMessageType,
  3624. named: NamedValue,
  3625. options?: TranslateOptions
  3626. ): string
  3627. /**
  3628. * Locale message pluralization
  3629. *
  3630. * @remarks
  3631. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  3632. *
  3633. * The input / output is the same as for VueI18n instance. About that details, see {@link VueI18n#tc | `VueI18n#tc` }.
  3634. * The value of plural is handled with default `1`.
  3635. * Supported for Legacy API mode only.
  3636. *
  3637. * @param key - A target locale message key
  3638. *
  3639. * @returns translation message that is pluraled
  3640. */
  3641. $tc<
  3642. Key extends string,
  3643. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3644. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3645. ? PickupPaths<{
  3646. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3647. }>
  3648. : never,
  3649. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3650. >(
  3651. key: Key | ResourceKeys | Path
  3652. ): TranslateResult
  3653. /**
  3654. * Locale message pluralization
  3655. *
  3656. * @remarks
  3657. * Overloaded `$tc`. About details, see the {@link $tc} remarks.
  3658. * Supported for Legacy API mode only.
  3659. *
  3660. * @param key - A target locale message key
  3661. * @param locale - A locale, override locale that global scope or local scope
  3662. *
  3663. * @returns translation message that is pluraled
  3664. */
  3665. $tc<
  3666. Key extends string,
  3667. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3668. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3669. ? PickupPaths<{
  3670. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3671. }>
  3672. : never,
  3673. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3674. >(
  3675. key: Key | ResourceKeys | Path,
  3676. locale: Locale
  3677. ): TranslateResult
  3678. /**
  3679. * Locale message pluralization
  3680. *
  3681. * @remarks
  3682. * Overloaded `$tc`. About details, see the {@link $tc} remarks.
  3683. * Supported for Legacy API mode only.
  3684. *
  3685. * @param key - A target locale message key
  3686. * @param list - A values of list interpolation
  3687. *
  3688. * @returns translation message that is pluraled
  3689. */
  3690. $tc<
  3691. Key extends string,
  3692. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3693. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3694. ? PickupPaths<{
  3695. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3696. }>
  3697. : never,
  3698. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3699. >(
  3700. key: Key | ResourceKeys | Path,
  3701. list: unknown[]
  3702. ): TranslateResult
  3703. /**
  3704. * Locale message pluralization
  3705. * Supported for Legacy API mode only.
  3706. *
  3707. * @remarks
  3708. * Overloaded `$tc`. About details, see the {@link $tc} remarks.
  3709. * Supported for Legacy API mode only.
  3710. *
  3711. * @param key - A target locale message key
  3712. * @param named - A values of named interpolation
  3713. *
  3714. * @returns translation message that is pluraled
  3715. */
  3716. $tc<
  3717. Key extends string,
  3718. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3719. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3720. ? PickupPaths<{
  3721. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3722. }>
  3723. : never,
  3724. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3725. >(
  3726. key: Key | ResourceKeys | Path,
  3727. named: Record<string, unknown>
  3728. ): TranslateResult
  3729. /**
  3730. * Locale message pluralization
  3731. * Supported for Legacy API mode only.
  3732. *
  3733. * @remarks
  3734. * Overloaded `$tc`. About details, see the {@link $tc} remarks.
  3735. * Supported for Legacy API mode only.
  3736. *
  3737. * @param key - A target locale message key
  3738. * @param choice - Which plural string to get. 1 returns the first one.
  3739. *
  3740. * @returns translation message that is pluraled
  3741. */
  3742. $tc<
  3743. Key extends string,
  3744. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3745. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3746. ? PickupPaths<{
  3747. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3748. }>
  3749. : never,
  3750. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3751. >(
  3752. key: Key | ResourceKeys | Path,
  3753. choice: number
  3754. ): TranslateResult
  3755. /**
  3756. * Locale message pluralization
  3757. * Supported for Legacy API mode only.
  3758. *
  3759. * @remarks
  3760. * Overloaded `$tc`. About details, see the {@link $tc} remarks.
  3761. * Supported for Legacy API mode only.
  3762. *
  3763. * @param key - A target locale message key
  3764. * @param choice - Which plural string to get. 1 returns the first one.
  3765. * @param locale - A locale, override locale that global scope or local scope
  3766. *
  3767. * @returns translation message that is pluraled
  3768. */
  3769. $tc<
  3770. Key extends string,
  3771. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3772. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3773. ? PickupPaths<{
  3774. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3775. }>
  3776. : never,
  3777. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3778. >(
  3779. key: Key | ResourceKeys | Path,
  3780. choice: number,
  3781. locale: Locale
  3782. ): TranslateResult
  3783. /**
  3784. * Locale message pluralization
  3785. * Supported for Legacy API mode only.
  3786. *
  3787. * @remarks
  3788. * Overloaded `$tc`. About details, see the {@link $tc} remarks.
  3789. * Supported for Legacy API mode only.
  3790. *
  3791. * @param key - A target locale message key
  3792. * @param choice - Which plural string to get. 1 returns the first one.
  3793. * @param list - A values of list interpolation
  3794. *
  3795. * @returns translation message that is pluraled
  3796. */
  3797. $tc<
  3798. Key extends string,
  3799. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3800. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3801. ? PickupPaths<{
  3802. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3803. }>
  3804. : never,
  3805. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3806. >(
  3807. key: Key | ResourceKeys | Path,
  3808. choice: number,
  3809. list: unknown[]
  3810. ): TranslateResult
  3811. /**
  3812. * Locale message pluralization
  3813. * Supported for Legacy API mode only.
  3814. *
  3815. * @remarks
  3816. * Overloaded `$tc`. About details, see the {@link $tc} remarks.
  3817. * Supported for Legacy API mode only.
  3818. *
  3819. * @param key - A target locale message key
  3820. * @param choice - Which plural string to get. 1 returns the first one.
  3821. * @param named - A values of named interpolation
  3822. *
  3823. * @returns translation message that is pluraled
  3824. */
  3825. $tc<
  3826. Key extends string,
  3827. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3828. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3829. ? PickupPaths<{
  3830. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3831. }>
  3832. : never,
  3833. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3834. >(
  3835. key: Key | ResourceKeys | Path,
  3836. choice: number,
  3837. named: Record<string, unknown>
  3838. ): TranslateResult
  3839. /**
  3840. * Translation message exist
  3841. *
  3842. * @remarks
  3843. * About that details, see {@link VueI18n#te | `VueI18n#te` } or {@link Composer#te | `Composer#te`}.
  3844. *
  3845. * @param key - A target locale message key
  3846. * @param locale - A locale, optional, override locale that global scope or local scope
  3847. *
  3848. * @returns if found locale message, `true`, else `false`
  3849. */
  3850. $te<
  3851. Key extends string,
  3852. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3853. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3854. ? PickupPaths<{
  3855. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3856. }>
  3857. : never,
  3858. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3859. >(
  3860. key: Key | ResourceKeys | Path,
  3861. locale?: Locale
  3862. ): boolean
  3863. /**
  3864. * Datetime formatting
  3865. *
  3866. * @remarks
  3867. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  3868. *
  3869. * 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` }.
  3870. *
  3871. * In {@link I18nMode | Composition API mode}, the `$d` is injected by `app.config.globalProperties`.
  3872. * 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` }.
  3873. *
  3874. * @param value - A value, timestamp number or `Date` instance
  3875. *
  3876. * @returns formatted value
  3877. */
  3878. $d(value: number | Date): DateTimeFormatResult
  3879. /**
  3880. * Datetime formatting
  3881. *
  3882. * @remarks
  3883. * Overloaded `$d`. About details, see the {@link $d} remarks.
  3884. *
  3885. * @param value - A value, timestamp number or `Date` instance
  3886. * @param key - A key of datetime formats
  3887. *
  3888. * @returns formatted value
  3889. */
  3890. $d<
  3891. Value extends number | Date = number,
  3892. Key extends string = string,
  3893. DefinedDateTimeFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>,
  3894. Keys = IsEmptyObject<DefinedDateTimeFormat> extends false
  3895. ? PickupFormatPathKeys<{
  3896. [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K]
  3897. }>
  3898. : never,
  3899. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3900. >(
  3901. value: Value,
  3902. key: Key | ResourceKeys
  3903. ): DateTimeFormatResult
  3904. /**
  3905. * Datetime formatting
  3906. *
  3907. * @remarks
  3908. * Overloaded `$d`. About details, see the {@link $d} remarks.
  3909. *
  3910. * @param value - A value, timestamp number or `Date` instance
  3911. * @param key - A key of datetime formats
  3912. * @param locale - A locale, optional, override locale that global scope or local scope
  3913. *
  3914. * @returns formatted value
  3915. */
  3916. $d<
  3917. Value extends number | Date = number,
  3918. Key extends string = string,
  3919. DefinedDateTimeFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>,
  3920. Keys = IsEmptyObject<DefinedDateTimeFormat> extends false
  3921. ? PickupFormatPathKeys<{
  3922. [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K]
  3923. }>
  3924. : never,
  3925. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3926. >(
  3927. value: Value,
  3928. key: Key | ResourceKeys,
  3929. locale: Locale
  3930. ): DateTimeFormatResult
  3931. /**
  3932. * Datetime formatting
  3933. *
  3934. * @remarks
  3935. * Overloaded `$d`. About details, see the {@link $d} remarks.
  3936. *
  3937. * @param value - A value, timestamp number or `Date` instance
  3938. * @param args - An argument values
  3939. *
  3940. * @returns formatted value
  3941. */
  3942. $d(
  3943. value: number | Date,
  3944. args: { [key: string]: string }
  3945. ): DateTimeFormatResult
  3946. /**
  3947. * Datetime formatting
  3948. *
  3949. * @remarks
  3950. * Overloaded `$d`. About details, see the {@link $d} remarks.
  3951. *
  3952. * @param value - A value, timestamp number or `Date` instance
  3953. *
  3954. * @returns formatted value
  3955. */
  3956. $d(value: number | Date): string
  3957. /**
  3958. * Datetime formatting
  3959. *
  3960. * @remarks
  3961. * Overloaded `$d`. About details, see the {@link $d} remarks.
  3962. *
  3963. * @param value - A value, timestamp number or `Date` instance
  3964. * @param key - A key of datetime formats
  3965. *
  3966. * @returns formatted value
  3967. */
  3968. $d<
  3969. Value extends number | Date = number,
  3970. Key extends string = string,
  3971. DefinedDateTimeFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>,
  3972. Keys = IsEmptyObject<DefinedDateTimeFormat> extends false
  3973. ? PickupFormatPathKeys<{
  3974. [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K]
  3975. }>
  3976. : never,
  3977. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3978. >(
  3979. value: Value,
  3980. key: Key | ResourceKeys
  3981. ): string
  3982. /**
  3983. * Datetime formatting
  3984. *
  3985. * @remarks
  3986. * Overloaded `$d`. About details, see the {@link $d} remarks.
  3987. *
  3988. * @param value - A value, timestamp number or `Date` instance
  3989. * @param key - A key of datetime formats
  3990. * @param locale - A locale, optional, override locale that global scope or local scope
  3991. *
  3992. * @returns formatted value
  3993. */
  3994. $d<
  3995. Value extends number | Date = number,
  3996. Key extends string = string,
  3997. DefinedDateTimeFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>,
  3998. Keys = IsEmptyObject<DefinedDateTimeFormat> extends false
  3999. ? PickupFormatPathKeys<{
  4000. [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K]
  4001. }>
  4002. : never,
  4003. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  4004. >(
  4005. value: Value,
  4006. key: Key | ResourceKeys,
  4007. locale: Locale
  4008. ): string
  4009. /**
  4010. * Datetime formatting
  4011. *
  4012. * @remarks
  4013. * Overloaded `$d`. About details, see the {@link $d} remarks.
  4014. *
  4015. * @param value - A value, timestamp number or `Date` instance
  4016. * @param options - An options, see the {@link DateTimeOptions}
  4017. *
  4018. * @returns formatted value
  4019. */
  4020. $d(value: number | Date, options: DateTimeOptions): string
  4021. /**
  4022. * Number formatting
  4023. *
  4024. * @remarks
  4025. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  4026. *
  4027. * 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` }.
  4028. *
  4029. * In {@link I18nMode | Composition API mode}, the `$n` is injected by `app.config.globalProperties`.
  4030. * 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` }.
  4031. *
  4032. * @param value - A number value
  4033. *
  4034. * @returns formatted value
  4035. */
  4036. $n(value: number): NumberFormatResult
  4037. /**
  4038. * Number formatting
  4039. *
  4040. * @remarks
  4041. * Overloaded `$n`. About details, see the {@link $n} remarks.
  4042. *
  4043. * @param value - A number value
  4044. * @param key - A key of number formats
  4045. *
  4046. * @returns formatted value
  4047. */
  4048. $n<
  4049. Key extends string = string,
  4050. DefinedNumberFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>,
  4051. Keys = IsEmptyObject<DefinedNumberFormat> extends false
  4052. ? PickupFormatPathKeys<{
  4053. [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K]
  4054. }>
  4055. : never,
  4056. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  4057. >(
  4058. value: number,
  4059. key: Key | ResourceKeys
  4060. ): NumberFormatResult
  4061. /**
  4062. * Number formatting
  4063. *
  4064. * @remarks
  4065. * Overloaded `$n`. About details, see the {@link $n} remarks.
  4066. *
  4067. * @param value - A number value
  4068. * @param key - A key of number formats
  4069. * @param locale - A locale, optional, override locale that global scope or local scope
  4070. *
  4071. * @returns formatted value
  4072. */
  4073. $n<
  4074. Key extends string = string,
  4075. DefinedNumberFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>,
  4076. Keys = IsEmptyObject<DefinedNumberFormat> extends false
  4077. ? PickupFormatPathKeys<{
  4078. [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K]
  4079. }>
  4080. : never,
  4081. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  4082. >(
  4083. value: number,
  4084. key: Key | ResourceKeys,
  4085. locale: Locale
  4086. ): NumberFormatResult
  4087. /**
  4088. * Number formatting
  4089. *
  4090. * @remarks
  4091. * Overloaded `$n`. About details, see the {@link $n} remarks.
  4092. *
  4093. * @param value - A number value
  4094. * @param args - An argument values
  4095. *
  4096. * @returns formatted value
  4097. */
  4098. $n(
  4099. value: number,
  4100. args: { [key: string]: string | boolean | number }
  4101. ): NumberFormatResult
  4102. /**
  4103. * Number formatting
  4104. *
  4105. * @remarks
  4106. * Overloaded `$n`. About details, see the {@link $n} remarks.
  4107. *
  4108. * @param value - A number value
  4109. * @param key - A key of number formats
  4110. * @param args - An argument values
  4111. *
  4112. * @returns formatted value
  4113. */
  4114. $n(
  4115. value: number,
  4116. key: string,
  4117. args: { [key: string]: string | boolean | number }
  4118. ): NumberFormatResult
  4119. /**
  4120. * Number formatting
  4121. *
  4122. * @remarks
  4123. * Overloaded `$n`. About details, see the {@link $n} remarks.
  4124. *
  4125. * @param value - A number value
  4126. * @param key - A key of number formats
  4127. * @param locale - A locale, optional, override locale that global scope or local scope
  4128. * @param args - An argument values
  4129. *
  4130. * @returns formatted value
  4131. */
  4132. $n(
  4133. value: number,
  4134. key: string,
  4135. locale: Locale,
  4136. args: { [key: string]: string | boolean | number }
  4137. ): NumberFormatResult
  4138. /**
  4139. * Number formatting
  4140. *
  4141. * @remarks
  4142. * Overloaded `$n`. About details, see the {@link $n} remarks.
  4143. *
  4144. * @param value - A number value
  4145. *
  4146. * @returns formatted value
  4147. */
  4148. $n(value: number): string
  4149. /**
  4150. * Number formatting
  4151. *
  4152. * @remarks
  4153. * Overloaded `$n`. About details, see the {@link $n} remarks.
  4154. *
  4155. * @param value - A number value
  4156. * @param key - A key of number formats
  4157. *
  4158. * @returns formatted value
  4159. */
  4160. $n<
  4161. Key extends string = string,
  4162. DefinedNumberFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>,
  4163. Keys = IsEmptyObject<DefinedNumberFormat> extends false
  4164. ? PickupFormatPathKeys<{
  4165. [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K]
  4166. }>
  4167. : never,
  4168. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  4169. >(
  4170. value: number,
  4171. key: Key | ResourceKeys
  4172. ): string
  4173. /**
  4174. * Number formatting
  4175. *
  4176. * @remarks
  4177. * Overloaded `$n`. About details, see the {@link $n} remarks.
  4178. *
  4179. * @param value - A number value
  4180. * @param key - A key of number formats
  4181. * @param locale - A locale, optional, override locale that global scope or local scope
  4182. *
  4183. * @returns formatted value
  4184. */
  4185. $n<
  4186. Key extends string = string,
  4187. DefinedNumberFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>,
  4188. Keys = IsEmptyObject<DefinedNumberFormat> extends false
  4189. ? PickupFormatPathKeys<{
  4190. [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K]
  4191. }>
  4192. : never,
  4193. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  4194. >(
  4195. value: number,
  4196. key: Key | ResourceKeys,
  4197. locale: Locale
  4198. ): string
  4199. /**
  4200. * Number formatting
  4201. *
  4202. * @remarks
  4203. * Overloaded `$n`. About details, see the {@link $n} remarks.
  4204. *
  4205. * @param value - A number value
  4206. * @param options - An options, see the {@link NumberOptions}
  4207. *
  4208. * @returns formatted value
  4209. */
  4210. $n(value: number, options: NumberOptions): string
  4211. /**
  4212. * Locale messages getter
  4213. *
  4214. * 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` }.
  4215. *
  4216. * @remarks
  4217. * In {@link I18nMode | Composition API mode}, the `$tm` is injected by `app.config.globalProperties`.
  4218. * 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` }.
  4219. * Based on the current `locale`, locale messages will be returned from Composer instance messages.
  4220. * If you change the `locale`, the locale messages returned will also correspond to the locale.
  4221. * If there are no locale messages for the given `key` in the composer instance messages, they will be returned with fallbacking.
  4222. *
  4223. * @param key - A target locale message key
  4224. *
  4225. * @returns locale messages
  4226. */
  4227. $tm<
  4228. Key extends string,
  4229. Messages extends object = {},
  4230. ResourceKeys extends PickupKeys<Messages> = PickupKeys<Messages>
  4231. >(
  4232. key: Key | ResourceKeys
  4233. ): LocaleMessageValue<VueMessageType> | {}
  4234. }
  4235. export interface GlobalComponents {
  4236. ['i18n-t']: typeof Translation
  4237. ['i18n-d']: typeof DatetimeFormat
  4238. ['i18n-n']: typeof NumberFormat
  4239. ['I18nT']: typeof Translation
  4240. ['I18nD']: typeof DatetimeFormat
  4241. ['I18nN']: typeof NumberFormat
  4242. }
  4243. }