vue-i18n.d.ts 156 KB

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