vue-i18n.d.ts 155 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314
  1. import type { App } from 'vue';
  2. import { CompileError } from '@intlify/core-base';
  3. import type { ComponentInternalInstance } from 'vue';
  4. import type { ComputedRef } from 'vue';
  5. import { DateTimeOptions } from '@intlify/core-base';
  6. import { FallbackLocale } from '@intlify/core-base';
  7. import type { FallbackLocales } from '@intlify/core-base';
  8. import { InjectionKey } from 'vue';
  9. import { DateTimeFormat as IntlDateTimeFormat } from '@intlify/core-base';
  10. import { DateTimeFormats as IntlDateTimeFormats } from '@intlify/core-base';
  11. import { FormatMatcher as IntlFormatMatcher } from '@intlify/core-base';
  12. import { LocaleMatcher as IntlLocaleMatcher } from '@intlify/core-base';
  13. import { NumberFormat as IntlNumberFormat } from '@intlify/core-base';
  14. import { NumberFormats as IntlNumberFormats } from '@intlify/core-base';
  15. import { IsEmptyObject } from '@intlify/core-base';
  16. import { IsNever } from '@intlify/core-base';
  17. import { LinkedModifiers } from '@intlify/core-base';
  18. import { Locale } from '@intlify/core-base';
  19. import type { LocaleMessage } from '@intlify/core-base';
  20. import { LocaleMessageDictionary } from '@intlify/core-base';
  21. import { LocaleMessages } from '@intlify/core-base';
  22. import { LocaleMessageType } from '@intlify/core-base';
  23. import { LocaleMessageValue } from '@intlify/core-base';
  24. import type { LocaleParams } from '@intlify/core-base';
  25. import { MessageCompiler } from '@intlify/core-base';
  26. import { MessageCompilerContext } from '@intlify/core-base';
  27. import { MessageContext } from '@intlify/core-base';
  28. import { MessageFunction } from '@intlify/core-base';
  29. import { MessageFunctions } from '@intlify/core-base';
  30. import { MessageResolver } from '@intlify/core-base';
  31. import { NamedValue } from '@intlify/core-base';
  32. import { NumberOptions } from '@intlify/core-base';
  33. import type { ObjectDirective } from 'vue';
  34. import { Path } from '@intlify/core-base';
  35. import { PathValue } from '@intlify/core-base';
  36. import type { PickupFormatKeys } from '@intlify/core-base';
  37. import { PickupFormatPathKeys } from '@intlify/core-base';
  38. import { PickupKeys } from '@intlify/core-base';
  39. import type { PickupLocales } from '@intlify/core-base';
  40. import { PickupPaths } from '@intlify/core-base';
  41. import { PluralizationRule } from '@intlify/core-base';
  42. import type { PluralizationRules } from '@intlify/core-base';
  43. import { PostTranslationHandler } from '@intlify/core-base';
  44. import { 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/)
  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`
  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/)
  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. /**
  1021. * Resolve locale message translation functions
  1022. *
  1023. * @remarks
  1024. * This is the interface for {@link Composer}
  1025. *
  1026. * @VueI18nComposition
  1027. */
  1028. export declare interface ComposerResolveLocaleMessageTranslation<Locales = 'en-US'> {
  1029. /**
  1030. * Resolve locale message translation
  1031. *
  1032. * @remarks
  1033. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  1034. *
  1035. * 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.
  1036. *
  1037. * If not, then it’s translated with global scope locale messages.
  1038. *
  1039. * @VueI18nTip
  1040. * The use-case for `rt` is for programmatic locale messages translation with using `tm`, `v-for`, javascript `for` statement.
  1041. *
  1042. * @VueI18nWarning
  1043. * `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`.
  1044. *
  1045. * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `tm`.
  1046. *
  1047. * @returns Translated message
  1048. *
  1049. * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope)
  1050. */
  1051. (message: MessageFunction<VueMessageType> | VueMessageType): string;
  1052. /**
  1053. * Resolve locale message translation for plurals
  1054. *
  1055. * @remarks
  1056. * Overloaded `rt`. About details, see the [call signature](composition#message-messagefunction-message-message-string) details.
  1057. *
  1058. * In this overloaded `rt`, return a pluralized translation message.
  1059. *
  1060. * @VueI18nTip
  1061. * The use-case for `rt` is for programmatic locale messages translation with using `tm`, `v-for`, javascript `for` statement.
  1062. *
  1063. * @VueI18nWarning
  1064. * `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`.
  1065. *
  1066. * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `tm`.
  1067. * @param plural - Which plural string to get. 1 returns the first one.
  1068. * @param options - Additional {@link TranslateOptions | options} for translation
  1069. *
  1070. * @returns Translated message
  1071. *
  1072. * @VueI18nSee [Pluralization](../guide/essentials/pluralization)
  1073. */
  1074. (message: MessageFunction<VueMessageType> | VueMessageType, plural: number, options?: TranslateOptions<Locales>): string;
  1075. /**
  1076. * Resolve locale message translation for list interpolations
  1077. *
  1078. * @remarks
  1079. * Overloaded `rt`. About details, see the [call signature](composition#message-messagefunction-message-message-string) details.
  1080. *
  1081. * In this overloaded `rt`, return a pluralized translation message.
  1082. *
  1083. * @VueI18nTip
  1084. * The use-case for `rt` is for programmatic locale messages translation with using `tm`, `v-for`, javascript `for` statement.
  1085. *
  1086. * @VueI18nWarning
  1087. * `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`.
  1088. *
  1089. * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `tm`.
  1090. * @param list - A values of list interpolation.
  1091. * @param options - Additional {@link TranslateOptions | options} for translation
  1092. *
  1093. * @returns Translated message
  1094. *
  1095. * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation)
  1096. */
  1097. (message: MessageFunction<VueMessageType> | VueMessageType, list: unknown[], options?: TranslateOptions<Locales>): string;
  1098. /**
  1099. * Resolve locale message translation for named interpolations
  1100. *
  1101. * @remarks
  1102. * Overloaded `rt`. About details, see the [call signature](composition#message-messagefunction-message-message-string) details.
  1103. *
  1104. * In this overloaded `rt`, for each placeholder x, the locale messages should contain a `{x}` token.
  1105. *
  1106. * @VueI18nTip
  1107. * The use-case for `rt` is for programmatic locale messages translation with using `tm`, `v-for`, javascript `for` statement.
  1108. *
  1109. * @VueI18nWarning
  1110. * `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`.
  1111. *
  1112. * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `tm`.
  1113. * @param named - A values of named interpolation.
  1114. * @param options - Additional {@link TranslateOptions | options} for translation
  1115. *
  1116. * @returns Translated message
  1117. *
  1118. * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation)
  1119. */
  1120. (message: MessageFunction<VueMessageType> | VueMessageType, named: NamedValue, options?: TranslateOptions<Locales>): string;
  1121. }
  1122. /**
  1123. * Locale message translation functions
  1124. *
  1125. * @remarks
  1126. * This is the interface for {@link Composer}
  1127. *
  1128. * @VueI18nComposition
  1129. */
  1130. export declare interface ComposerTranslation<Messages extends Record<string, any> = {}, Locales = 'en-US', DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>, C = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  1131. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  1132. }> : 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> {
  1133. /**
  1134. * Locale message translation
  1135. *
  1136. * @remarks
  1137. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  1138. *
  1139. * 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.
  1140. *
  1141. * If not, then it’s translated with global scope locale messages.
  1142. *
  1143. * @param key - A target locale message key
  1144. *
  1145. * @returns Translated message
  1146. *
  1147. * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope)
  1148. */
  1149. <Key extends string>(key: Key | ResourceKeys | number): string;
  1150. /**
  1151. * Locale message translation for plurals
  1152. *
  1153. * @remarks
  1154. * Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details.
  1155. *
  1156. * In this overloaded `t`, return a pluralized translation message.
  1157. *
  1158. * You can also suppress the warning, when the translation missing according to the options.
  1159. *
  1160. * About details of options, see the {@link TranslateOptions}.
  1161. *
  1162. * @param key - A target locale message key
  1163. * @param plural - Which plural string to get. 1 returns the first one.
  1164. * @param options - Additional {@link TranslateOptions | options} for translation
  1165. *
  1166. * @returns Translated message
  1167. *
  1168. * @VueI18nSee [Pluralization](../guide/essentials/pluralization)
  1169. */
  1170. <Key extends string>(key: Key | ResourceKeys | number, plural: number, options?: TranslateOptions<Locales>): string;
  1171. /**
  1172. * Locale message translation for missing default message
  1173. *
  1174. * @remarks
  1175. * Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details.
  1176. *
  1177. * In this overloaded `t`, if no translation was found, return a default message.
  1178. *
  1179. * You can also suppress the warning, when the translation missing according to the options.
  1180. *
  1181. * About details of options, see the {@link TranslateOptions}.
  1182. *
  1183. * @param key - A target locale message key
  1184. * @param defaultMsg - A default message to return if no translation was found
  1185. * @param options - Additional {@link TranslateOptions | options} for translation
  1186. *
  1187. * @returns Translated message
  1188. */
  1189. <Key extends string>(key: Key | ResourceKeys | number, defaultMsg: string, options?: TranslateOptions<Locales>): string;
  1190. /**
  1191. * Locale message translation for list interpolations
  1192. *
  1193. * @remarks
  1194. * Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details.
  1195. *
  1196. * In this overloaded `t`, the locale messages should contain a `{0}`, `{1}`, … for each placeholder in the list.
  1197. *
  1198. * You can also suppress the warning, when the translation missing according to the options.
  1199. *
  1200. * About details of options, see the {@link TranslateOptions}.
  1201. *
  1202. * @param key - A target locale message key
  1203. * @param list - A values of list interpolation
  1204. * @param options - Additional {@link TranslateOptions | options} for translation
  1205. *
  1206. * @returns Translated message
  1207. *
  1208. * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation)
  1209. */
  1210. <Key extends string>(key: Key | ResourceKeys | number, list: unknown[], options?: TranslateOptions<Locales>): string;
  1211. /**
  1212. * Locale message translation for list interpolations and plurals
  1213. *
  1214. * @remarks
  1215. * Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details.
  1216. *
  1217. * In this overloaded `t`, the locale messages should contain a `{0}`, `{1}`, … for each placeholder in the list, and return a pluralized translation message.
  1218. *
  1219. * @param key - A target locale message key
  1220. * @param list - A values of list interpolation
  1221. * @param plural - Which plural string to get. 1 returns the first one.
  1222. *
  1223. * @returns Translated message
  1224. *
  1225. * @VueI18nSee [Pluralization](../guide/essentials/pluralization)
  1226. * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation)
  1227. */
  1228. <Key extends string>(key: Key | ResourceKeys | number, list: unknown[], plural: number): string;
  1229. /**
  1230. * Locale message translation for list interpolations and missing default message
  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 if no translation was found, return a default message.
  1236. *
  1237. * @param key - A target locale message key
  1238. * @param list - A values of list interpolation
  1239. * @param defaultMsg - A default message to return if no translation was found
  1240. *
  1241. * @returns Translated message
  1242. *
  1243. * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation)
  1244. */
  1245. <Key extends string>(key: Key | ResourceKeys | number, list: unknown[], defaultMsg: string): string;
  1246. /**
  1247. * Locale message translation for named interpolations
  1248. *
  1249. * @remarks
  1250. * Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details.
  1251. *
  1252. * In this overloaded `t`, for each placeholder x, the locale messages should contain a `{x}` token.
  1253. *
  1254. * You can also suppress the warning, when the translation missing according to the options.
  1255. *
  1256. * About details of options, see the {@link TranslateOptions}.
  1257. *
  1258. * @param key - A target locale message key
  1259. * @param named - A values of named interpolation
  1260. * @param options - Additional {@link TranslateOptions | options} for translation
  1261. *
  1262. * @returns Translated message
  1263. *
  1264. * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation)
  1265. */
  1266. <Key extends string>(key: Key | ResourceKeys | number, named: NamedValue, options?: TranslateOptions<Locales>): string;
  1267. /**
  1268. * Locale message translation for named interpolations and plurals
  1269. *
  1270. * @remarks
  1271. * Overloaded `t`. About details, see the [call signature](composition#key-key-resourcekeys-number-string) details.
  1272. *
  1273. * In this overloaded `t`, for each placeholder x, the locale messages should contain a `{x}` token, and return a pluralized translation message.
  1274. *
  1275. * @param key - A target locale message key
  1276. * @param named - A values of named interpolation
  1277. * @param plural - Which plural string to get. 1 returns the first one.
  1278. *
  1279. * @returns Translated message
  1280. *
  1281. * @VueI18nSee [Pluralization](../guide/essentials/pluralization)
  1282. * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation)
  1283. */
  1284. <Key extends string>(key: Key | ResourceKeys | number, named: NamedValue, plural: number): 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 if no translation was found, return a default message.
  1292. *
  1293. * @param key - A target locale message key
  1294. * @param named - A values of named interpolation
  1295. * @param defaultMsg - A default message to return if no translation was found
  1296. *
  1297. * @returns Translated message
  1298. *
  1299. * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation)
  1300. */
  1301. <Key extends string>(key: Key | ResourceKeys | number, named: NamedValue, defaultMsg: string): string;
  1302. }
  1303. 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>;
  1304. /**
  1305. * Vue I18n factory
  1306. *
  1307. * @param options - An options, see the {@link I18nOptions}
  1308. *
  1309. * @typeParam Schema - The i18n resources (messages, datetimeFormats, numberFormats) schema, default {@link LocaleMessage}
  1310. * @typeParam Locales - The locales of i18n resource schema, default `en-US`
  1311. * @typeParam Legacy - Whether legacy mode is enabled or disabled, default `true`
  1312. *
  1313. * @returns {@link I18n} instance
  1314. *
  1315. * @remarks
  1316. * If you use Legacy API mode, you need to specify {@link VueI18nOptions} and `legacy: true` option.
  1317. *
  1318. * If you use composition API mode, you need to specify {@link ComposerOptions}.
  1319. *
  1320. * @VueI18nSee [Getting Started](../guide/)
  1321. * @VueI18nSee [Composition API](../guide/advanced/composition)
  1322. *
  1323. * @example
  1324. * case: for Legacy API
  1325. * ```js
  1326. * import { createApp } from 'vue'
  1327. * import { createI18n } from 'vue-i18n'
  1328. *
  1329. * // call with I18n option
  1330. * const i18n = createI18n({
  1331. * locale: 'ja',
  1332. * messages: {
  1333. * en: { ... },
  1334. * ja: { ... }
  1335. * }
  1336. * })
  1337. *
  1338. * const App = {
  1339. * // ...
  1340. * }
  1341. *
  1342. * const app = createApp(App)
  1343. *
  1344. * // install!
  1345. * app.use(i18n)
  1346. * app.mount('#app')
  1347. * ```
  1348. *
  1349. * @example
  1350. * case: for composition API
  1351. * ```js
  1352. * import { createApp } from 'vue'
  1353. * import { createI18n, useI18n } from 'vue-i18n'
  1354. *
  1355. * // call with I18n option
  1356. * const i18n = createI18n({
  1357. * legacy: false, // you must specify 'legacy: false' option
  1358. * locale: 'ja',
  1359. * messages: {
  1360. * en: { ... },
  1361. * ja: { ... }
  1362. * }
  1363. * })
  1364. *
  1365. * const App = {
  1366. * setup() {
  1367. * // ...
  1368. * const { t } = useI18n({ ... })
  1369. * return { ... , t }
  1370. * }
  1371. * }
  1372. *
  1373. * const app = createApp(App)
  1374. *
  1375. * // install!
  1376. * app.use(i18n)
  1377. * app.mount('#app')
  1378. * ```
  1379. *
  1380. * @VueI18nGeneral
  1381. */
  1382. 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>;
  1383. export declare interface CustomBlock<Message = VueMessageType> {
  1384. locale: Locale;
  1385. resource: LocaleMessages<Message>;
  1386. }
  1387. export declare type CustomBlocks<Message = VueMessageType> = Array<CustomBlock<Message>>;
  1388. /**
  1389. * Datetime Format Component
  1390. *
  1391. * @remarks
  1392. * See the following items for property about details
  1393. *
  1394. * @VueI18nSee [FormattableProps](component#formattableprops)
  1395. * @VueI18nSee [BaseFormatProps](component#baseformatprops)
  1396. * @VueI18nSee [Custom Formatting](../guide/essentials/datetime#custom-formatting)
  1397. *
  1398. * @VueI18nDanger
  1399. * 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)
  1400. *
  1401. * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-datetimeformat)
  1402. *
  1403. * @VueI18nComponent
  1404. */
  1405. export declare const DatetimeFormat: new () => {
  1406. $props: VNodeProps & DatetimeFormatProps & BaseFormatProps;
  1407. };
  1408. /**
  1409. * DatetimeFormat Component Props
  1410. *
  1411. * @VueI18nComponent
  1412. */
  1413. export declare type DatetimeFormatProps = FormattableProps<number | Date, Intl.DateTimeFormatOptions>;
  1414. /** @VueI18nLegacy */
  1415. export declare type DateTimeFormatResult = string;
  1416. export { DateTimeOptions }
  1417. export declare type DefaultDateTimeFormatSchema<Schema = RemoveIndexSignature<{
  1418. [K in keyof DefineDateTimeFormat]: DefineDateTimeFormat[K];
  1419. }>> = IsEmptyObject<Schema> extends true ? IntlDateTimeFormat : Schema;
  1420. export declare type DefaultLocaleMessageSchema<Schema = RemoveIndexSignature<{
  1421. [K in keyof DefineLocaleMessage]: DefineLocaleMessage[K];
  1422. }>> = IsEmptyObject<Schema> extends true ? LocaleMessage<VueMessageType> : Schema;
  1423. export declare type DefaultNumberFormatSchema<Schema = RemoveIndexSignature<{
  1424. [K in keyof DefineNumberFormat]: DefineNumberFormat[K];
  1425. }>> = IsEmptyObject<Schema> extends true ? IntlNumberFormat : Schema;
  1426. /**
  1427. * The type definition of datetime format
  1428. *
  1429. * @remarks
  1430. * The typealias is used to strictly define the type of the Datetime format.
  1431. *
  1432. * The type defined by this can be used in the global scope.
  1433. *
  1434. * @example
  1435. * ```ts
  1436. * // type.d.ts (`.d.ts` file at your app)
  1437. * import { DefineDateTimeFormat } from 'vue-i18n'
  1438. *
  1439. * declare module 'vue-i18n' {
  1440. * export interface DefineDateTimeFormat {
  1441. * short: {
  1442. * hour: 'numeric'
  1443. * timezone: string
  1444. * }
  1445. * }
  1446. * }
  1447. * ```
  1448. *
  1449. * @VueI18nGeneral
  1450. */
  1451. export declare interface DefineDateTimeFormat extends IntlDateTimeFormat {
  1452. }
  1453. /**
  1454. * The type definition of Locale Message
  1455. *
  1456. * @remarks
  1457. * The typealias is used to strictly define the type of the Locale message.
  1458. *
  1459. * The type defined by this can be used in the global scope.
  1460. *
  1461. * @example
  1462. * ```ts
  1463. * // type.d.ts (`.d.ts` file at your app)
  1464. * import { DefineLocaleMessage } from 'vue-i18n'
  1465. *
  1466. * declare module 'vue-i18n' {
  1467. * export interface DefineLocaleMessage {
  1468. * title: string
  1469. * menu: {
  1470. * login: string
  1471. * }
  1472. * }
  1473. * }
  1474. * ```
  1475. *
  1476. * @VueI18nGeneral
  1477. */
  1478. export declare interface DefineLocaleMessage extends LocaleMessage<VueMessageType> {
  1479. }
  1480. /**
  1481. * The type definition of number format
  1482. *
  1483. * @remarks
  1484. * The typealias is used to strictly define the type of the Number format.
  1485. *
  1486. * The type defined by this can be used in the global scope.
  1487. *
  1488. * @example
  1489. * ```ts
  1490. * // type.d.ts (`.d.ts` file at your app)
  1491. * import { DefineNumberFormat } from 'vue-i18n'
  1492. *
  1493. * declare module 'vue-i18n' {
  1494. * export interface DefineNumberFormat {
  1495. * currency: {
  1496. * style: 'currency'
  1497. * currencyDisplay: 'symbol'
  1498. * currency: string
  1499. * }
  1500. * }
  1501. * }
  1502. * ```
  1503. *
  1504. * @VueI18nGeneral
  1505. */
  1506. export declare interface DefineNumberFormat extends IntlNumberFormat {
  1507. }
  1508. export declare type Disposer = () => void;
  1509. /**
  1510. * Exported global composer instance
  1511. *
  1512. * @remarks
  1513. * This interface is the [global composer](general#global) that is provided interface that is injected into each component with `app.config.globalProperties`.
  1514. *
  1515. * @VueI18nGeneral
  1516. */
  1517. export declare interface ExportedGlobalComposer {
  1518. /**
  1519. * Locale
  1520. *
  1521. * @remarks
  1522. * This property is proxy-like property for `Composer#locale`. About details, see the [Composer#locale](composition#locale)
  1523. */
  1524. locale: Locale;
  1525. /**
  1526. * Fallback locale
  1527. *
  1528. * @remarks
  1529. * This property is proxy-like property for `Composer#fallbackLocale`. About details, see the [Composer#fallbackLocale](composition#fallbacklocale)
  1530. */
  1531. fallbackLocale: FallbackLocale;
  1532. /**
  1533. * Available locales
  1534. *
  1535. * @remarks
  1536. * This property is proxy-like property for `Composer#availableLocales`. About details, see the [Composer#availableLocales](composition#availablelocales)
  1537. */
  1538. readonly availableLocales: Locale[];
  1539. }
  1540. export { FallbackLocale }
  1541. /**
  1542. * Formattable Props
  1543. *
  1544. * @remarks
  1545. * The props used in DatetimeFormat, or NumberFormat component
  1546. *
  1547. * @VueI18nComponent
  1548. */
  1549. export declare interface FormattableProps<Value, Format> extends BaseFormatProps {
  1550. /**
  1551. * @remarks
  1552. * The value specified for the target component
  1553. */
  1554. value: Value;
  1555. /**
  1556. * @remarks
  1557. * The format to use in the target component.
  1558. *
  1559. * Specify the format key string or the format as defined by the Intl API in ECMA 402.
  1560. */
  1561. format?: string | Format;
  1562. }
  1563. export declare interface Formatter {
  1564. interpolate(message: string, values: any, path: string): Array<any> | null;
  1565. }
  1566. /**
  1567. * I18n instance
  1568. *
  1569. * @remarks
  1570. * The instance required for installation as the Vue plugin
  1571. *
  1572. * @VueI18nGeneral
  1573. */
  1574. export declare interface I18n<Messages extends Record<string, unknown> = {}, DateTimeFormats extends Record<string, unknown> = {}, NumberFormats extends Record<string, unknown> = {}, OptionLocale = Locale, Legacy = boolean> {
  1575. /**
  1576. * Vue I18n API mode
  1577. *
  1578. * @remarks
  1579. * If you specified `legacy: true` option in `createI18n`, return `legacy`, else `composition`
  1580. *
  1581. * @defaultValue `'legacy'`
  1582. */
  1583. readonly mode: I18nMode;
  1584. /**
  1585. * The property accessible to the global Composer instance or VueI18n instance
  1586. *
  1587. * @remarks
  1588. * 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.
  1589. *
  1590. * An instance of this property is **global scope***.
  1591. */
  1592. readonly global: Legacy extends true ? VueI18n<Messages, DateTimeFormats, NumberFormats, OptionLocale> : Legacy extends false ? Composer<Messages, DateTimeFormats, NumberFormats, OptionLocale> : unknown;
  1593. /**
  1594. * The property whether or not the Composition API is available
  1595. *
  1596. * @remarks
  1597. * 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`.
  1598. */
  1599. readonly allowComposition: boolean;
  1600. /**
  1601. * Install entry point
  1602. *
  1603. * @param app - A target Vue app instance
  1604. * @param options - An install options
  1605. */
  1606. install(app: App, ...options: unknown[]): void;
  1607. /**
  1608. * Release global scope resource
  1609. */
  1610. dispose(): void;
  1611. }
  1612. /**
  1613. * I18n Additional Options
  1614. *
  1615. * @remarks
  1616. * Specific options for {@link createI18n}
  1617. *
  1618. * @VueI18nGeneral
  1619. */
  1620. export declare interface I18nAdditionalOptions {
  1621. /**
  1622. * Whether vue-i18n Legacy API mode use on your Vue App
  1623. *
  1624. * @remarks
  1625. * 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`.
  1626. *
  1627. * @VueI18nSee [Composition API](../guide/advanced/composition)
  1628. *
  1629. * @defaultValue `true`
  1630. */
  1631. legacy?: boolean;
  1632. /**
  1633. * Whether to inject global properties & functions into for each component.
  1634. *
  1635. * @remarks
  1636. * If set to `true`, then properties and methods prefixed with `$` are injected into Vue Component.
  1637. *
  1638. * @VueI18nSee [Implicit with injected properties and functions](../guide/advanced/composition#implicit-with-injected-properties-and-functions)
  1639. * @VueI18nSee [ComponentCustomProperties](injection#componentcustomproperties)
  1640. *
  1641. * @defaultValue `true`
  1642. */
  1643. globalInjection?: boolean;
  1644. /**
  1645. * Whether to allow the Composition API to be used in Legacy API mode.
  1646. *
  1647. * @remarks
  1648. * 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.
  1649. *
  1650. * @VueI18nWarning Note that the Composition API made available with this option doesn't work on SSR.
  1651. * @VueI18nSee [Composition API](../guide/advanced/composition)
  1652. *
  1653. * @defaultValue `false`
  1654. */
  1655. allowComposition?: boolean;
  1656. }
  1657. export declare const I18nD: new () => {
  1658. $props: VNodeProps & DatetimeFormatProps & BaseFormatProps;
  1659. };
  1660. /**
  1661. * Injection key for {@link useI18n}
  1662. *
  1663. * @remarks
  1664. * The global injection key for I18n instances with `useI18n`. this injection key is used in Web Components.
  1665. * Specify the i18n instance created by {@link createI18n} together with `provide` function.
  1666. *
  1667. * @VueI18nGeneral
  1668. */
  1669. export declare const I18nInjectionKey: InjectionKey<I18n> | string;
  1670. /**
  1671. * Vue I18n API mode
  1672. *
  1673. * @VueI18nSee [I18n#mode](general#mode)
  1674. *
  1675. * @VueI18nGeneral
  1676. */
  1677. export declare type I18nMode = 'legacy' | 'composition';
  1678. export declare const I18nN: new () => {
  1679. $props: VNodeProps & NumberFormatProps & BaseFormatProps;
  1680. };
  1681. /**
  1682. * I18n Options for `createI18n`
  1683. *
  1684. * @remarks
  1685. * `I18nOptions` is inherited {@link I18nAdditionalOptions}, {@link ComposerOptions} and {@link VueI18nOptions},
  1686. * so you can specify these options.
  1687. *
  1688. * @VueI18nGeneral
  1689. */
  1690. export declare type I18nOptions<Schema extends {
  1691. message?: unknown;
  1692. datetime?: unknown;
  1693. number?: unknown;
  1694. } = {
  1695. message: DefaultLocaleMessageSchema;
  1696. datetime: DefaultDateTimeFormatSchema;
  1697. number: DefaultNumberFormatSchema;
  1698. }, Locales extends {
  1699. messages: unknown;
  1700. datetimeFormats: unknown;
  1701. numberFormats: unknown;
  1702. } | string = Locale, Options extends ComposerOptions<Schema, Locales> | VueI18nOptions<Schema, Locales> = ComposerOptions<Schema, Locales> | VueI18nOptions<Schema, Locales>> = I18nAdditionalOptions & Options;
  1703. /**
  1704. * Vue I18n plugin options
  1705. *
  1706. * @remarks
  1707. * An options specified when installing Vue I18n as Vue plugin with using `app.use`.
  1708. *
  1709. * @VueI18nGeneral
  1710. */
  1711. export declare interface I18nPluginOptions {
  1712. /**
  1713. * Whether to use the tag name `i18n` for Translation Component
  1714. *
  1715. * @remarks
  1716. * This option is used for compatibility with Vue I18n v8.x.
  1717. *
  1718. * If you can't migrate right away, you can temporarily enable this option, and you can work Translation Component.
  1719. *
  1720. * @defaultValue `false`
  1721. */
  1722. useI18nComponentName?: boolean;
  1723. /**
  1724. * Whether to globally install the components that is offered by Vue I18n
  1725. *
  1726. * @remarks
  1727. * If this option is enabled, the components will be installed globally at `app.use` time.
  1728. *
  1729. * If you want to install manually in the `import` syntax, you can set it to `false` to install when needed.
  1730. *
  1731. * @defaultValue `true`
  1732. */
  1733. globalInstall?: boolean;
  1734. }
  1735. /**
  1736. * I18n Scope
  1737. *
  1738. * @VueI18nSee [ComposerAdditionalOptions#useScope](composition#usescope)
  1739. * @VueI18nSee [useI18n](composition#usei18n)
  1740. *
  1741. * @VueI18nGeneral
  1742. */
  1743. export declare type I18nScope = 'local' | 'parent' | 'global';
  1744. export declare const I18nT: new () => {
  1745. $props: VNodeProps & TranslationProps;
  1746. };
  1747. export { IntlDateTimeFormat }
  1748. export { IntlDateTimeFormats }
  1749. export { IntlFormatMatcher }
  1750. export { IntlLocaleMatcher }
  1751. export { IntlNumberFormat }
  1752. export { IntlNumberFormats }
  1753. export { IsEmptyObject }
  1754. export { IsNever }
  1755. export { LinkedModifiers }
  1756. export { Locale }
  1757. export { LocaleMessageDictionary }
  1758. /** @VueI18nLegacy */
  1759. export declare type LocaleMessageObject<Message = string> = LocaleMessageDictionary<Message>;
  1760. export { LocaleMessages }
  1761. export { LocaleMessageType }
  1762. export { LocaleMessageValue }
  1763. export { MessageCompiler }
  1764. export { MessageCompilerContext }
  1765. export { MessageContext }
  1766. export { MessageFunction }
  1767. export { MessageFunctions }
  1768. export { MessageResolver }
  1769. /** @VueI18nComposition */
  1770. export declare type MissingHandler = (locale: Locale, key: Path, instance?: ComponentInternalInstance, type?: string) => string | void;
  1771. export { NamedValue }
  1772. /**
  1773. * Number Format Component
  1774. *
  1775. * @remarks
  1776. * See the following items for property about details
  1777. *
  1778. * @VueI18nSee [FormattableProps](component#formattableprops)
  1779. * @VueI18nSee [BaseFormatProps](component#baseformatprops)
  1780. * @VueI18nSee [Custom Formatting](../guide/essentials/number#custom-formatting)
  1781. *
  1782. * @VueI18nDanger
  1783. * 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)
  1784. *
  1785. * If you want to use it, you need to use [polyfill](https://github.com/formatjs/formatjs/tree/main/packages/intl-numberformat)
  1786. *
  1787. * @VueI18nComponent
  1788. */
  1789. export declare const NumberFormat: new () => {
  1790. $props: VNodeProps & NumberFormatProps & BaseFormatProps;
  1791. };
  1792. /**
  1793. * NumberFormat Component Props
  1794. *
  1795. * @VueI18nComponent
  1796. */
  1797. export declare type NumberFormatProps = FormattableProps<number, Intl.NumberFormatOptions>;
  1798. /** @VueI18nLegacy */
  1799. export declare type NumberFormatResult = string;
  1800. export { NumberOptions }
  1801. export { Path }
  1802. export { PathValue }
  1803. export { PickupFormatPathKeys }
  1804. export { PickupKeys }
  1805. export { PickupPaths }
  1806. export { PluralizationRule }
  1807. export declare type PluralizationRulesMap = {
  1808. [locale: string]: PluralizationRule;
  1809. };
  1810. export { PostTranslationHandler }
  1811. export { RemovedIndexResources }
  1812. export { TranslateOptions }
  1813. /** @VueI18nLegacy */
  1814. export declare type TranslateResult = string;
  1815. /**
  1816. * Translation Component
  1817. *
  1818. * @remarks
  1819. * See the following items for property about details
  1820. *
  1821. * @VueI18nSee [TranslationProps](component#translationprops)
  1822. * @VueI18nSee [BaseFormatProps](component#baseformatprops)
  1823. * @VueI18nSee [Component Interpolation](../guide/advanced/component)
  1824. *
  1825. * @example
  1826. * ```html
  1827. * <div id="app">
  1828. * <!-- ... -->
  1829. * <i18n keypath="term" tag="label" for="tos">
  1830. * <a :href="url" target="_blank">{{ $t('tos') }}</a>
  1831. * </i18n>
  1832. * <!-- ... -->
  1833. * </div>
  1834. * ```
  1835. * ```js
  1836. * import { createApp } from 'vue'
  1837. * import { createI18n } from 'vue-i18n'
  1838. *
  1839. * const messages = {
  1840. * en: {
  1841. * tos: 'Term of Service',
  1842. * term: 'I accept xxx {0}.'
  1843. * },
  1844. * ja: {
  1845. * tos: '利用規約',
  1846. * term: '私は xxx の{0}に同意します。'
  1847. * }
  1848. * }
  1849. *
  1850. * const i18n = createI18n({
  1851. * locale: 'en',
  1852. * messages
  1853. * })
  1854. *
  1855. * const app = createApp({
  1856. * data: {
  1857. * url: '/term'
  1858. * }
  1859. * }).use(i18n).mount('#app')
  1860. * ```
  1861. *
  1862. * @VueI18nComponent
  1863. */
  1864. export declare const Translation: new () => {
  1865. $props: VNodeProps & TranslationProps;
  1866. };
  1867. /**
  1868. * Translation Directive (`v-t`)
  1869. *
  1870. * @remarks
  1871. * Update the element `textContent` that localized with locale messages.
  1872. *
  1873. * You can use string syntax or object syntax.
  1874. *
  1875. * String syntax can be specified as a keypath of locale messages.
  1876. *
  1877. * If you can be used object syntax, you need to specify as the object key the following params
  1878. *
  1879. * ```
  1880. * - path: required, key of locale messages
  1881. * - locale: optional, locale
  1882. * - args: optional, for list or named formatting
  1883. * ```
  1884. *
  1885. * @example
  1886. * ```html
  1887. * <!-- string syntax: literal -->
  1888. * <p v-t="'foo.bar'"></p>
  1889. *
  1890. * <!-- string syntax: binding via data or computed props -->
  1891. * <p v-t="msg"></p>
  1892. *
  1893. * <!-- object syntax: literal -->
  1894. * <p v-t="{ path: 'hi', locale: 'ja', args: { name: 'kazupon' } }"></p>
  1895. *
  1896. * <!-- object syntax: binding via data or computed props -->
  1897. * <p v-t="{ path: greeting, args: { name: fullName } }"></p>
  1898. * ```
  1899. *
  1900. * @VueI18nDirective
  1901. */
  1902. export declare type TranslationDirective<T = HTMLElement> = ObjectDirective<T>;
  1903. /**
  1904. * Translation Component Props
  1905. *
  1906. * @VueI18nComponent
  1907. */
  1908. export declare interface TranslationProps extends BaseFormatProps {
  1909. /**
  1910. * @remarks
  1911. * The locale message key can be specified prop
  1912. */
  1913. keypath: string;
  1914. /**
  1915. * @remarks
  1916. * The Plural Choosing the message number prop
  1917. */
  1918. plural?: number | string;
  1919. }
  1920. 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']>;
  1921. /**
  1922. * Use Composition API for Vue I18n
  1923. *
  1924. * @param options - An options, see {@link UseI18nOptions}
  1925. *
  1926. * @typeParam Schema - The i18n resources (messages, datetimeFormats, numberFormats) schema, default {@link LocaleMessage}
  1927. * @typeParam Locales - The locales of i18n resource schema, default `en-US`
  1928. *
  1929. * @returns {@link Composer} instance
  1930. *
  1931. * @remarks
  1932. * This function is mainly used by `setup`.
  1933. *
  1934. * If options are specified, Composer instance is created for each component and you can be localized on the component.
  1935. *
  1936. * If options are not specified, you can be localized using the global Composer.
  1937. *
  1938. * @example
  1939. * case: Component resource base localization
  1940. * ```html
  1941. * <template>
  1942. * <form>
  1943. * <label>{{ t('language') }}</label>
  1944. * <select v-model="locale">
  1945. * <option value="en">en</option>
  1946. * <option value="ja">ja</option>
  1947. * </select>
  1948. * </form>
  1949. * <p>message: {{ t('hello') }}</p>
  1950. * </template>
  1951. *
  1952. * <script>
  1953. * import { useI18n } from 'vue-i18n'
  1954. *
  1955. * export default {
  1956. * setup() {
  1957. * const { t, locale } = useI18n({
  1958. * locale: 'ja',
  1959. * messages: {
  1960. * en: { ... },
  1961. * ja: { ... }
  1962. * }
  1963. * })
  1964. * // Something to do ...
  1965. *
  1966. * return { ..., t, locale }
  1967. * }
  1968. * }
  1969. * </script>
  1970. * ```
  1971. *
  1972. * @VueI18nComposition
  1973. */
  1974. 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']>;
  1975. /**
  1976. * I18n Options for `useI18n`
  1977. *
  1978. * @remarks
  1979. * `UseI18nOptions` is inherited {@link ComposerAdditionalOptions} and {@link ComposerOptions}, so you can specify these options.
  1980. *
  1981. * @VueI18nSee [useI18n](composition#usei18n)
  1982. *
  1983. * @VueI18nComposition
  1984. */
  1985. export declare type UseI18nOptions<Schema extends {
  1986. message?: unknown;
  1987. datetime?: unknown;
  1988. number?: unknown;
  1989. } = {
  1990. message: DefaultLocaleMessageSchema;
  1991. datetime: DefaultDateTimeFormatSchema;
  1992. number: DefaultNumberFormatSchema;
  1993. }, Locales extends {
  1994. messages: unknown;
  1995. datetimeFormats: unknown;
  1996. numberFormats: unknown;
  1997. } | string = Locale, Options extends ComposerOptions<Schema, Locales> = ComposerOptions<Schema, Locales>> = ComposerAdditionalOptions & Options;
  1998. /**
  1999. * Vue I18n Version
  2000. *
  2001. * @remarks
  2002. * Semver format. Same format as the package.json `version` field.
  2003. *
  2004. * @VueI18nGeneral
  2005. */
  2006. export declare const VERSION: string;
  2007. export declare function vTDirective(i18n: I18n): TranslationDirective<HTMLElement>;
  2008. export declare type VTDirectiveValue = {
  2009. path: string;
  2010. locale?: Locale;
  2011. args?: NamedValue;
  2012. choice?: number;
  2013. plural?: number;
  2014. };
  2015. /**
  2016. * VueI18n legacy interfaces
  2017. *
  2018. * @remarks
  2019. * This interface is compatible with interface of `VueI18n` class (offered with Vue I18n v8.x).
  2020. *
  2021. * @VueI18nLegacy
  2022. */
  2023. 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>> {
  2024. /**
  2025. * @remarks
  2026. * Instance ID.
  2027. */
  2028. id: number;
  2029. /**
  2030. * @remarks
  2031. * The current locale this VueI18n instance is using.
  2032. *
  2033. * If the locale contains a territory and a dialect, this locale contains an implicit fallback.
  2034. *
  2035. * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope)
  2036. */
  2037. locale: Locales;
  2038. /**
  2039. * @remarks
  2040. * The current fallback locales this VueI18n instance is using.
  2041. *
  2042. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  2043. */
  2044. fallbackLocale: FallbackLocales<Locales>;
  2045. /**
  2046. * @remarks
  2047. * The list of available locales in `messages` in lexical order.
  2048. */
  2049. readonly availableLocales: Composition['availableLocales'];
  2050. /**
  2051. * @remarks
  2052. * The locale messages of localization.
  2053. *
  2054. * @VueI18nSee [Getting Started](../guide/)
  2055. */
  2056. readonly messages: {
  2057. [K in keyof Messages]: Messages[K];
  2058. };
  2059. /**
  2060. * @remarks
  2061. * The datetime formats of localization.
  2062. *
  2063. * @VueI18nSee [Datetime Formatting](../guide/essentials/datetime)
  2064. */
  2065. readonly datetimeFormats: {
  2066. [K in keyof DateTimeFormats]: DateTimeFormats[K];
  2067. };
  2068. /**
  2069. * @remarks
  2070. * The number formats of localization.
  2071. *
  2072. * @VueI18nSee [Number Formatting](../guide/essentials/number)
  2073. */
  2074. readonly numberFormats: {
  2075. [K in keyof NumberFormats]: NumberFormats[K];
  2076. };
  2077. /**
  2078. * @remarks
  2079. * Custom Modifiers for linked messages.
  2080. *
  2081. * @VueI18nSee [Custom Modifiers](../guide/essentials/syntax#custom-modifiers)
  2082. */
  2083. readonly modifiers: Composition['modifiers'];
  2084. /**
  2085. * @remarks
  2086. * The formatter that implemented with Formatter interface.
  2087. *
  2088. * @deprecated See the [here](../guide/migration/breaking#remove-custom-formatter)
  2089. */
  2090. formatter: Formatter;
  2091. /**
  2092. * @remarks
  2093. * A handler for localization missing.
  2094. */
  2095. missing: MissingHandler | null;
  2096. /**
  2097. * @remarks
  2098. * A handler for post processing of translation.
  2099. */
  2100. postTranslation: PostTranslationHandler<VueMessageType> | null;
  2101. /**
  2102. * @remarks
  2103. * Whether suppress warnings outputted when localization fails.
  2104. *
  2105. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  2106. */
  2107. silentTranslationWarn: Composition['missingWarn'];
  2108. /**
  2109. * @remarks
  2110. * Whether suppress fallback warnings when localization fails.
  2111. */
  2112. silentFallbackWarn: Composition['fallbackWarn'];
  2113. /**
  2114. * @remarks
  2115. * Whether suppress warnings when falling back to either `fallbackLocale` or root.
  2116. *
  2117. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  2118. */
  2119. formatFallbackMessages: Composition['fallbackFormat'];
  2120. /**
  2121. * @remarks
  2122. * Whether synchronize the root level locale to the component localization locale.
  2123. *
  2124. * @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-2)
  2125. */
  2126. sync: Composition['inheritLocale'];
  2127. /**
  2128. * @remarks
  2129. * Whether to allow the use locale messages of HTML formatting.
  2130. *
  2131. * If you set `warn` or` error`, will check the locale messages on the VueI18n instance.
  2132. *
  2133. * If you are specified `warn`, a warning will be output at console.
  2134. *
  2135. * If you are specified `error` will occurred an Error.
  2136. *
  2137. * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message)
  2138. * @VueI18nSee [Change `warnHtmlInMessage` option default value](../guide/migration/breaking#change-warnhtmlinmessage-option-default-value)
  2139. */
  2140. warnHtmlInMessage: WarnHtmlInMessageLevel;
  2141. /**
  2142. * @remarks
  2143. * Whether interpolation parameters are escaped before the message is translated.
  2144. *
  2145. * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message)
  2146. */
  2147. escapeParameterHtml: Composition['escapeParameter'];
  2148. /**
  2149. * @remarks
  2150. * Whether `v-t` directive's element should preserve `textContent` after directive is unbinded.
  2151. *
  2152. * @VueI18nSee [Custom Directive](../guide/advanced/directive)
  2153. * @VueI18nSee [Remove preserveDirectiveContent option](../guide/migration/breaking#remove-preservedirectivecontent-option)
  2154. *
  2155. * @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.
  2156. */
  2157. preserveDirectiveContent: boolean;
  2158. /**
  2159. * A set of rules for word pluralization
  2160. *
  2161. * @VueI18nSee [Custom Pluralization](../guide/essentials/pluralization#custom-pluralization)
  2162. */
  2163. pluralizationRules: Composition['pluralRules'];
  2164. /**
  2165. * Locale message translation
  2166. *
  2167. * @remarks
  2168. * About details functions, See the {@link VueI18nTranslation}
  2169. */
  2170. t: VueI18nTranslation<Messages, Locales, RemoveIndexSignature<{
  2171. [K in keyof DefineLocaleMessage]: DefineLocaleMessage[K];
  2172. }>>;
  2173. /**
  2174. * Resolve locale message translation
  2175. *
  2176. * @remarks
  2177. * About details functions, See the {@link VueI18nResolveLocaleMessageTranslation}
  2178. */
  2179. rt: VueI18nResolveLocaleMessageTranslation<Locales>;
  2180. /**
  2181. * Locale message pluralization
  2182. *
  2183. * @remarks
  2184. * About details functions, See the {@link VueI18nTranslationChoice}
  2185. */
  2186. tc: VueI18nTranslationChoice<Messages, Locales, RemoveIndexSignature<{
  2187. [K in keyof DefineLocaleMessage]: DefineLocaleMessage[K];
  2188. }>>;
  2189. /**
  2190. * Translation locale message exist
  2191. *
  2192. * @remarks
  2193. * whether do exist locale message on VueI18n instance [messages](legacy#messages).
  2194. *
  2195. * If you specified `locale`, check the locale messages of `locale`.
  2196. *
  2197. * @param key - A target locale message key
  2198. * @param locale - A target locale
  2199. *
  2200. * @returns If found locale message, `true`, else `false`
  2201. */
  2202. te<Str extends string, Key extends PickupKeys<Messages> = PickupKeys<Messages>>(key: Str | Key, locale?: Locales): boolean;
  2203. /**
  2204. * Locale messages getter
  2205. *
  2206. * @remarks
  2207. * If [i18n component options](injection#i18n) is specified, it’s get in preferentially local scope locale messages than global scope locale messages.
  2208. *
  2209. * If [i18n component options](injection#i18n) isn't specified, it’s get with global scope locale messages.
  2210. *
  2211. * Based on the current `locale`, locale messages will be returned from Composer instance messages.
  2212. *
  2213. * If you change the `locale`, the locale messages returned will also correspond to the locale.
  2214. *
  2215. * If there are no locale messages for the given `key` in the composer instance messages, they will be returned with [fallbacking](../guide/essentials/fallback).
  2216. *
  2217. * @VueI18nWarning
  2218. * You need to use `rt` for the locale message returned by `tm`. see the [rt](legacy#rt-message) details.
  2219. *
  2220. * @example
  2221. * template:
  2222. * ```html
  2223. * <div class="container">
  2224. * <template v-for="content in $tm('contents')">
  2225. * <h2>{{ $rt(content.title) }}</h2>
  2226. * <p v-for="paragraph in content.paragraphs">
  2227. * {{ $rt(paragraph) }}
  2228. * </p>
  2229. * </template>
  2230. * </div>
  2231. * ```
  2232. *
  2233. * ```js
  2234. * import { createI18n } from 'vue-i18n'
  2235. *
  2236. * const i18n = createI18n({
  2237. * messages: {
  2238. * en: {
  2239. * contents: [
  2240. * {
  2241. * title: 'Title1',
  2242. * // ...
  2243. * paragraphs: [
  2244. * // ...
  2245. * ]
  2246. * }
  2247. * ]
  2248. * }
  2249. * }
  2250. * // ...
  2251. * })
  2252. * ```
  2253. * @param key - A target locale message key
  2254. *
  2255. * @return Locale messages
  2256. */
  2257. tm: Composition['tm'];
  2258. /**
  2259. * Get locale message
  2260. *
  2261. * @remarks
  2262. * get locale message from VueI18n instance [messages](legacy#messages).
  2263. *
  2264. * @param locale - A target locale
  2265. *
  2266. * @returns Locale messages
  2267. */
  2268. getLocaleMessage: Composition['getLocaleMessage'];
  2269. /**
  2270. * Set locale message
  2271. *
  2272. * @remarks
  2273. * Set locale message to VueI18n instance [messages](legacy#messages).
  2274. *
  2275. * @param locale - A target locale
  2276. * @param message - A message
  2277. */
  2278. setLocaleMessage: Composition['setLocaleMessage'];
  2279. /**
  2280. * Merge locale message
  2281. *
  2282. * @remarks
  2283. * Merge locale message to VueI18n instance [messages](legacy#messages).
  2284. *
  2285. * @param locale - A target locale
  2286. * @param message - A message
  2287. */
  2288. mergeLocaleMessage: Composition['mergeLocaleMessage'];
  2289. /**
  2290. * Datetime formatting
  2291. *
  2292. * @remarks
  2293. * About details functions, See the {@link VueI18nDateTimeFormatting}
  2294. */
  2295. d: VueI18nDateTimeFormatting<DateTimeFormats, Locales, RemoveIndexSignature<{
  2296. [K in keyof DefineDateTimeFormat]: DefineDateTimeFormat[K];
  2297. }>>;
  2298. /**
  2299. * Get datetime format
  2300. *
  2301. * @remarks
  2302. * get datetime format from VueI18n instance [datetimeFormats](legacy#datetimeformats).
  2303. *
  2304. * @param locale - A target locale
  2305. *
  2306. * @returns Datetime format
  2307. */
  2308. getDateTimeFormat: Composition['getDateTimeFormat'];
  2309. /**
  2310. * Set datetime format
  2311. *
  2312. * @remarks
  2313. * Set datetime format to VueI18n instance [datetimeFormats](legacy#datetimeformats).
  2314. *
  2315. * @param locale - A target locale
  2316. * @param format - A target datetime format
  2317. */
  2318. setDateTimeFormat: Composition['setDateTimeFormat'];
  2319. /**
  2320. * Merge datetime format
  2321. *
  2322. * @remarks
  2323. * Merge datetime format to VueI18n instance [datetimeFormats](legacy#datetimeformats).
  2324. *
  2325. * @param locale - A target locale
  2326. * @param format - A target datetime format
  2327. */
  2328. mergeDateTimeFormat: Composition['mergeDateTimeFormat'];
  2329. /**
  2330. * Number Formatting
  2331. *
  2332. * @remarks
  2333. * About details functions, See the {@link VueI18nNumberFormatting}
  2334. */
  2335. n: VueI18nNumberFormatting<NumberFormats, Locales, RemoveIndexSignature<{
  2336. [K in keyof DefineNumberFormat]: DefineNumberFormat[K];
  2337. }>>;
  2338. /**
  2339. * Get number format
  2340. *
  2341. * @remarks
  2342. * get number format from VueI18n instance [numberFormats](legacy#numberFormats).
  2343. *
  2344. * @param locale - A target locale
  2345. *
  2346. * @returns Number format
  2347. */
  2348. getNumberFormat: Composition['getNumberFormat'];
  2349. /**
  2350. * Set number format
  2351. *
  2352. * @remarks
  2353. * Set number format to VueI18n instance [numberFormats](legacy#numberFormats).
  2354. *
  2355. * @param locale - A target locale
  2356. * @param format - A target number format
  2357. */
  2358. setNumberFormat: Composition['setNumberFormat'];
  2359. /**
  2360. * Merge number format
  2361. *
  2362. * @remarks
  2363. * Merge number format to VueI18n instance [numberFormats](legacy#numberFormats).
  2364. *
  2365. * @param locale - A target locale
  2366. * @param format - A target number format
  2367. */
  2368. mergeNumberFormat: Composition['mergeNumberFormat'];
  2369. /**
  2370. * Get choice index
  2371. *
  2372. * @remarks
  2373. * Get pluralization index for current pluralizing number and a given amount of choices.
  2374. *
  2375. * @deprecated Use `pluralizationRules` option instead of `getChoiceIndex`.
  2376. */
  2377. getChoiceIndex: (choice: Choice, choicesLength: number) => number;
  2378. }
  2379. /**
  2380. * Datetime formatting functions for VueI18n legacy interfaces
  2381. *
  2382. * @remarks
  2383. * This is the interface for {@link VueI18n}
  2384. *
  2385. * @VueI18nLegacy
  2386. */
  2387. export declare interface VueI18nDateTimeFormatting<DateTimeFormats extends Record<string, any> = {}, Locales = 'en-US', DefinedDateTimeFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>, C = IsEmptyObject<DefinedDateTimeFormat> extends false ? PickupFormatPathKeys<{
  2388. [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K];
  2389. }> : 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> {
  2390. /**
  2391. * Datetime formatting
  2392. *
  2393. * @remarks
  2394. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  2395. *
  2396. * If [i18n component options](injection#i18n) is specified, it’s formatted in preferentially local scope datetime formats than global scope locale messages.
  2397. *
  2398. * If [i18n component options](injection#i18n) isn't specified, it’s formatted with global scope datetime formats.
  2399. *
  2400. * @param value - A value, timestamp number or `Date` instance
  2401. *
  2402. * @returns Formatted value
  2403. *
  2404. * @VueI18nSee [Datetime formatting](../guide/essentials/datetime)
  2405. */
  2406. (value: number | Date): DateTimeFormatResult;
  2407. /**
  2408. * Datetime formatting
  2409. *
  2410. * @remarks
  2411. * Overloaded `d`. About details, see the [call signature](legacy#value-number-date-datetimeformatresult) details.
  2412. *
  2413. * @param value - A value, timestamp number or `Date` instance
  2414. * @param key - A key of datetime formats
  2415. *
  2416. * @returns Formatted value
  2417. */
  2418. <Value extends number | Date = number, Key extends string = string>(value: Value, key: Key | ResourceKeys): DateTimeFormatResult;
  2419. /**
  2420. * Datetime formatting
  2421. *
  2422. * @remarks
  2423. * Overloaded `d`. About details, see the [call signature](legacy#value-number-date-datetimeformatresult) details.
  2424. *
  2425. * @param value - A value, timestamp number or `Date` instance
  2426. * @param key - A key of datetime formats
  2427. * @param locale - A locale, it will be used over than global scope or local scope.
  2428. *
  2429. * @returns Formatted value
  2430. */
  2431. <Value extends number | Date = number, Key extends string = string>(value: Value, key: Key | ResourceKeys, locale: Locales): DateTimeFormatResult;
  2432. /**
  2433. * Datetime formatting
  2434. *
  2435. * @remarks
  2436. * Overloaded `d`. About details, see the [call signature](legacy#value-number-date-datetimeformatresult) details.
  2437. *
  2438. * @param value - A value, timestamp number or `Date` instance
  2439. * @param args - An argument values
  2440. *
  2441. * @returns Formatted value
  2442. */
  2443. (value: number | Date, args: {
  2444. [key: string]: string | boolean | number;
  2445. }): DateTimeFormatResult;
  2446. }
  2447. export declare type VueI18nExtender = (vueI18n: VueI18n) => Disposer | undefined;
  2448. /**
  2449. * Number formatting functions for VueI18n legacy interfaces
  2450. *
  2451. * @remarks
  2452. * This is the interface for {@link VueI18n}
  2453. *
  2454. * @VueI18nLegacy
  2455. */
  2456. export declare interface VueI18nNumberFormatting<NumberFormats extends Record<string, any> = {}, Locales = 'en-US', DefinedNumberFormat extends RemovedIndexResources<DefineNumberFormat> = RemovedIndexResources<DefineNumberFormat>, C = IsEmptyObject<DefinedNumberFormat> extends false ? PickupFormatPathKeys<{
  2457. [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K];
  2458. }> : 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> {
  2459. /**
  2460. * Number formatting
  2461. *
  2462. * @remarks
  2463. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  2464. *
  2465. * If [i18n component options](injection#i18n) is specified, it’s formatted in preferentially local scope number formats than global scope locale messages.
  2466. *
  2467. * If [i18n component options](injection#i18n) isn't specified, it’s formatted with global scope number formats.
  2468. *
  2469. * @param value - A number value
  2470. *
  2471. * @returns Formatted value
  2472. *
  2473. * @VueI18nSee [Number formatting](../guide/essentials/number)
  2474. */
  2475. (value: number): NumberFormatResult;
  2476. /**
  2477. * Number formatting
  2478. *
  2479. * @remarks
  2480. * Overloaded `n`. About details, see the [call signature](legacy#value-number-numberformatresult) details.
  2481. *
  2482. * @param value - A number value
  2483. * @param key - A key of number formats
  2484. *
  2485. * @returns Formatted value
  2486. */
  2487. <Key extends string = string>(value: number, key: Key | ResourceKeys): NumberFormatResult;
  2488. /**
  2489. * Number formatting
  2490. *
  2491. * @remarks
  2492. * Overloaded `n`. About details, see the [call signature](legacy#value-number-numberformatresult) details.
  2493. *
  2494. * @param value - A number value
  2495. * @param key - A key of number formats
  2496. * @param locale - A locale, it will be used over than global scope or local scope.
  2497. *
  2498. * @returns Formatted value
  2499. */
  2500. <Key extends string = string>(value: number, key: Key | ResourceKeys, locale: Locales): NumberFormatResult;
  2501. /**
  2502. * Number formatting
  2503. *
  2504. * @remarks
  2505. * Overloaded `n`. About details, see the [call signature](legacy#value-number-numberformatresult) details.
  2506. *
  2507. * @param value - A number value
  2508. * @param args - An argument values
  2509. *
  2510. * @returns Formatted value
  2511. */
  2512. (value: number, args: {
  2513. [key: string]: string | boolean | number;
  2514. }): NumberFormatResult;
  2515. }
  2516. /**
  2517. * VueI18n Options
  2518. *
  2519. * @remarks
  2520. * This option is compatible with `VueI18n` class constructor options (offered with Vue I18n v8.x)
  2521. *
  2522. * @VueI18nLegacy
  2523. */
  2524. export declare interface VueI18nOptions<Schema extends {
  2525. message?: unknown;
  2526. datetime?: unknown;
  2527. number?: unknown;
  2528. } = {
  2529. message: DefaultLocaleMessageSchema;
  2530. datetime: DefaultDateTimeFormatSchema;
  2531. number: DefaultNumberFormatSchema;
  2532. }, Locales extends {
  2533. messages: unknown;
  2534. datetimeFormats: unknown;
  2535. numberFormats: unknown;
  2536. } | string = Locale, Options extends ComposerOptions<Schema, Locales> = ComposerOptions<Schema, Locales>> {
  2537. /**
  2538. * @remarks
  2539. * The locale of localization.
  2540. *
  2541. * If the locale contains a territory and a dialect, this locale contains an implicit fallback.
  2542. *
  2543. * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope)
  2544. *
  2545. * @defaultValue `'en-US'`
  2546. */
  2547. locale?: Options['locale'];
  2548. /**
  2549. * @remarks
  2550. * The locale of fallback localization.
  2551. *
  2552. * For more complex fallback definitions see fallback.
  2553. *
  2554. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  2555. *
  2556. * @defaultValue The default `'en-US'` for the `locale` if it's not specified, or it's `locale` value
  2557. */
  2558. fallbackLocale?: Options['fallbackLocale'];
  2559. /**
  2560. * @remarks
  2561. * The locale messages of localization.
  2562. *
  2563. * @VueI18nSee [Getting Started](../guide/)
  2564. *
  2565. * @defaultValue `{}`
  2566. */
  2567. messages?: Options['messages'];
  2568. /**
  2569. * @remarks
  2570. * Allow use flat json messages or not
  2571. *
  2572. * @defaultValue `false`
  2573. */
  2574. flatJson?: Options['flatJson'];
  2575. /**
  2576. * @remarks
  2577. * The datetime formats of localization.
  2578. *
  2579. * @VueI18nSee [Datetime Formatting](../guide/essentials/datetime)
  2580. *
  2581. * @defaultValue `{}`
  2582. */
  2583. datetimeFormats?: Options['datetimeFormats'];
  2584. /**
  2585. * @remarks
  2586. * The number formats of localization.
  2587. *
  2588. * @VueI18nSee [Number Formatting](../guide/essentials/number)
  2589. *
  2590. * @defaultValue `{}`
  2591. */
  2592. numberFormats?: Options['numberFormats'];
  2593. /**
  2594. * @remarks
  2595. * The list of available locales in messages in lexical order.
  2596. *
  2597. * @defaultValue `[]`
  2598. */
  2599. availableLocales?: Locale[];
  2600. /**
  2601. * @remarks
  2602. * Custom Modifiers for linked messages.
  2603. *
  2604. * @VueI18nSee [Custom Modifiers](../guide/essentials/syntax#custom-modifiers)
  2605. */
  2606. modifiers?: Options['modifiers'];
  2607. /**
  2608. * @remarks
  2609. * The formatter that implemented with Formatter interface.
  2610. *
  2611. * @deprecated See the [here](../guide/migration/breaking#remove-custom-formatter)
  2612. */
  2613. formatter?: Formatter;
  2614. /**
  2615. * @remarks
  2616. * A handler for localization missing.
  2617. *
  2618. * The handler gets called with the localization target locale, localization path key, the Vue instance and values.
  2619. *
  2620. * If missing handler is assigned, and occurred localization missing, it's not warned.
  2621. *
  2622. * @defaultValue `null`
  2623. */
  2624. missing?: Options['missing'];
  2625. /**
  2626. * @remarks
  2627. * In the component localization, whether to fall back to root level (global scope) localization when localization fails.
  2628. *
  2629. * If `false`, it's not fallback to root.
  2630. *
  2631. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  2632. *
  2633. * @defaultValue `true`
  2634. */
  2635. fallbackRoot?: Options['fallbackRoot'];
  2636. /**
  2637. * @remarks
  2638. * Whether suppress warnings outputted when localization fails.
  2639. *
  2640. * If `true`, suppress localization fail warnings.
  2641. *
  2642. * If you use regular expression, you can suppress localization fail warnings that it match with translation key (e.g. `t`).
  2643. *
  2644. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  2645. *
  2646. * @defaultValue `false`
  2647. */
  2648. silentTranslationWarn?: Options['missingWarn'];
  2649. /**
  2650. * @remarks
  2651. * Whether do template interpolation on translation keys when your language lacks a translation for a key.
  2652. *
  2653. * If `true`, skip writing templates for your "base" language; the keys are your templates.
  2654. *
  2655. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  2656. *
  2657. * @defaultValue `false`
  2658. */
  2659. silentFallbackWarn?: Options['fallbackWarn'];
  2660. /**
  2661. * @remarks
  2662. * Whether suppress warnings when falling back to either `fallbackLocale` or root.
  2663. *
  2664. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  2665. *
  2666. * @defaultValue `false`
  2667. */
  2668. formatFallbackMessages?: Options['fallbackFormat'];
  2669. /**
  2670. * @remarks
  2671. * Whether `v-t` directive's element should preserve `textContent` after directive is unbinded.
  2672. *
  2673. * @VueI18nSee [Custom Directive](../guide/advanced/directive)
  2674. * @VueI18nSee [Remove `preserveDirectiveContent` option](../guide/migration/breaking#remove-preservedirectivecontent-option)
  2675. *
  2676. * @defaultValue `false`
  2677. *
  2678. * @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.
  2679. */
  2680. preserveDirectiveContent?: boolean;
  2681. /**
  2682. * @remarks
  2683. * Whether to allow the use locale messages of HTML formatting.
  2684. *
  2685. * See the warnHtmlInMessage property.
  2686. *
  2687. * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message)
  2688. * @VueI18nSee [Change `warnHtmlInMessage` option default value](../guide/migration/breaking#change-warnhtmlinmessage-option-default-value)
  2689. *
  2690. * @defaultValue `'off'`
  2691. */
  2692. warnHtmlInMessage?: WarnHtmlInMessageLevel;
  2693. /**
  2694. * @remarks
  2695. * If `escapeParameterHtml` is configured as true then interpolation parameters are escaped before the message is translated.
  2696. *
  2697. * 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).
  2698. *
  2699. * This usage pattern mostly occurs when passing precomputed text strings into UI components.
  2700. *
  2701. * The escape process involves replacing the following symbols with their respective HTML character entities: `<`, `>`, `"`, `'`.
  2702. *
  2703. * Setting `escapeParameterHtml` as true should not break existing functionality but provides a safeguard against a subtle type of XSS attack vectors.
  2704. *
  2705. * @VueI18nSee [HTML Message](../guide/essentials/syntax#html-message)
  2706. *
  2707. * @defaultValue `false`
  2708. */
  2709. escapeParameterHtml?: Options['escapeParameter'];
  2710. /**
  2711. * @remarks
  2712. * The shared locale messages of localization for components. More detail see Component based localization.
  2713. *
  2714. * @VueI18nSee [Shared locale messages for components](../guide/essentials/local#shared-locale-messages-for-components)
  2715. *
  2716. * @defaultValue `undefined`
  2717. */
  2718. sharedMessages?: LocaleMessages<VueMessageType>;
  2719. /**
  2720. * @remarks
  2721. * A set of rules for word pluralization
  2722. *
  2723. * @VueI18nSee [Custom Pluralization](../guide/essentials/pluralization#custom-pluralization)
  2724. *
  2725. * @defaultValue `{}`
  2726. */
  2727. pluralizationRules?: Options['pluralRules'];
  2728. /**
  2729. * @remarks
  2730. * A handler for post processing of translation. The handler gets after being called with the `$t`, `t`, `$tc`, and `tc`.
  2731. *
  2732. * This handler is useful if you want to filter on translated text such as space trimming.
  2733. *
  2734. * @defaultValue `null`
  2735. */
  2736. postTranslation?: Options['postTranslation'];
  2737. /**
  2738. * @remarks
  2739. * Whether synchronize the root level locale to the component localization locale.
  2740. *
  2741. * If `false`, regardless of the root level locale, localize for each component locale.
  2742. *
  2743. * @VueI18nSee [Local Scope](../guide/essentials/scope#local-scope-2)
  2744. *
  2745. * @defaultValue `true`
  2746. */
  2747. sync?: boolean;
  2748. /**
  2749. * @remarks
  2750. * A message resolver to resolve [`messages`](legacy#messages).
  2751. *
  2752. * If not specified, the vue-i18n internal message resolver will be used by default.
  2753. *
  2754. * You need to implement a message resolver yourself that supports the following requirements:
  2755. *
  2756. * - 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.
  2757. *
  2758. * - If the message could not be resolved, you need to return `null`.
  2759. *
  2760. * - 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.
  2761. *
  2762. * The message resolver is called indirectly by the following APIs:
  2763. *
  2764. * - [`t`](legacy#t-key)
  2765. *
  2766. * - [`tc`](legacy#tc-key)
  2767. *
  2768. * - [`te`](legacy#te-key-locale)
  2769. *
  2770. * - [`tm`](legacy#tm-key)
  2771. *
  2772. * - [Translation component](component#translation)
  2773. *
  2774. * @example
  2775. * Here is an example of how to set it up using your `createI18n`:
  2776. * ```js
  2777. * import { createI18n } from 'vue-i18n'
  2778. *
  2779. * // your message resolver
  2780. * function messageResolver(obj, path) {
  2781. * // simple message resolving!
  2782. * const msg = obj[path]
  2783. * return msg != null ? msg : null
  2784. * }
  2785. *
  2786. * // call with I18n option
  2787. * const i18n = createI18n({
  2788. * locale: 'ja',
  2789. * messageResolver, // set your message resolver
  2790. * messages: {
  2791. * en: { ... },
  2792. * ja: { ... }
  2793. * }
  2794. * })
  2795. *
  2796. * // the below your something to do ...
  2797. * // ...
  2798. * ```
  2799. *
  2800. * @VueI18nTip
  2801. * :new: v9.2+
  2802. *
  2803. * @VueI18nWarning
  2804. * 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.
  2805. *
  2806. * @VueI18nSee [Fallbacking](../guide/essentials/fallback)
  2807. *
  2808. * @defaultValue `undefined`
  2809. */
  2810. messageResolver?: MessageResolver;
  2811. }
  2812. /**
  2813. * Resolve locale message translation functions for VueI18n legacy interfaces
  2814. *
  2815. * @remarks
  2816. * This is the interface for {@link VueI18n}. This interface is an alias of {@link ComposerResolveLocaleMessageTranslation}.
  2817. *
  2818. * @VueI18nLegacy
  2819. */
  2820. export declare type VueI18nResolveLocaleMessageTranslation<Locales = 'en-US'> = ComposerResolveLocaleMessageTranslation<Locales>;
  2821. /**
  2822. * Locale message translation functions for VueI18n legacy interfaces
  2823. *
  2824. * @remarks
  2825. * This is the interface for {@link VueI18n}
  2826. *
  2827. * @VueI18nLegacy
  2828. */
  2829. export declare interface VueI18nTranslation<Messages extends Record<string, any> = {}, Locales = 'en-US', DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>, C = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  2830. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  2831. }> : 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> {
  2832. /**
  2833. * Locale message translation.
  2834. *
  2835. * @remarks
  2836. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  2837. *
  2838. * If [i18n component options](injection#i18n) is specified, it’s translated in preferentially local scope locale messages than global scope locale messages.
  2839. *
  2840. * If [i18n component options](injection#i18n) isn't specified, it’s translated with global scope locale messages.
  2841. *
  2842. * @param key - A target locale message key
  2843. *
  2844. * @returns Translated message
  2845. *
  2846. * @VueI18nSee [Scope and Locale Changing](../guide/essentials/scope)
  2847. */
  2848. <Key extends string>(key: Key | ResourceKeys): TranslateResult;
  2849. /**
  2850. * Locale message translation.
  2851. *
  2852. * @remarks
  2853. * Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details.
  2854. *
  2855. * @param key - A target locale message key
  2856. * @param locale - A locale, it will be used over than global scope or local scope.
  2857. *
  2858. * @returns Translated message
  2859. */
  2860. <Key extends string>(key: Key | ResourceKeys, locale: Locales | Locale): TranslateResult;
  2861. /**
  2862. * Locale message translation.
  2863. *
  2864. * @remarks
  2865. * Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details.
  2866. *
  2867. * @param key - A target locale message key
  2868. * @param locale - A locale, it will be used over than global scope or local scope.
  2869. * @param list - A values of list interpolation
  2870. *
  2871. * @returns Translated message
  2872. *
  2873. * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation)
  2874. */
  2875. <Key extends string>(key: Key | ResourceKeys, locale: Locales | Locale, list: unknown[]): TranslateResult;
  2876. /**
  2877. * Locale message translation.
  2878. *
  2879. * @remarks
  2880. * Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details.
  2881. *
  2882. * @param key - A target locale message key
  2883. * @param locale - A locale, it will be used over than global scope or local scope.
  2884. * @param named - A values of named interpolation
  2885. *
  2886. * @returns Translated message
  2887. *
  2888. * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation)
  2889. */
  2890. <Key extends string>(key: Key | ResourceKeys, locale: Locales | Locale, named: Record<string, unknown>): TranslateResult;
  2891. /**
  2892. * Locale message translation.
  2893. *
  2894. * @remarks
  2895. * Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details.
  2896. *
  2897. * @param key - A target locale message key
  2898. * @param list - A values of list interpolation
  2899. *
  2900. * @returns Translated message
  2901. *
  2902. * @VueI18nSee [List interpolation](../guide/essentials/syntax#list-interpolation)
  2903. */
  2904. <Key extends string>(key: Key | ResourceKeys, list: unknown[]): TranslateResult;
  2905. /**
  2906. * Locale message translation.
  2907. *
  2908. * @remarks
  2909. * Overloaded `t`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult) details.
  2910. *
  2911. * @param key - A target locale message key
  2912. * @param named - A values of named interpolation
  2913. *
  2914. * @returns Translated message
  2915. *
  2916. * @VueI18nSee [Named interpolation](../guide/essentials/syntax#named-interpolation)
  2917. */
  2918. <Key extends string>(key: Key | ResourceKeys, named: Record<string, unknown>): TranslateResult;
  2919. }
  2920. /**
  2921. * Locale message pluralization functions for VueI18n legacy interfaces
  2922. *
  2923. * @remarks
  2924. * This is the interface for {@link VueI18n}
  2925. *
  2926. * @VueI18nLegacy
  2927. */
  2928. export declare interface VueI18nTranslationChoice<Messages extends Record<string, any> = {}, Locales = 'en-US', DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>, C = IsEmptyObject<DefinedLocaleMessage> extends false ? PickupPaths<{
  2929. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K];
  2930. }> : 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> {
  2931. /**
  2932. * Locale message pluralization
  2933. *
  2934. * @remarks
  2935. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  2936. *
  2937. * If [i18n component options](injection#i18n) is specified, it’s pluraled in preferentially local scope locale messages than global scope locale messages.
  2938. *
  2939. * If [i18n component options](injection#i18n) isn't specified, it’s pluraled with global scope locale messages.
  2940. *
  2941. * The plural choice number is handled with default `1`.
  2942. *
  2943. * @param key - A target locale message key
  2944. *
  2945. * @returns Pluraled message
  2946. *
  2947. * @VueI18nSee [Pluralization](../guide/essentials/pluralization)
  2948. */
  2949. <Key extends string = string>(key: Key | ResourceKeys): TranslateResult;
  2950. /**
  2951. * Locale message pluralization
  2952. *
  2953. * @remarks
  2954. * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details.
  2955. *
  2956. * @param key - A target locale message key
  2957. * @param locale - A locale, it will be used over than global scope or local scope.
  2958. *
  2959. * @returns Pluraled message
  2960. */
  2961. <Key extends string = string>(key: Key | ResourceKeys, locale: Locales | Locale): TranslateResult;
  2962. /**
  2963. * Locale message pluralization
  2964. *
  2965. * @remarks
  2966. * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details.
  2967. *
  2968. * @param key - A target locale message key
  2969. * @param list - A values of list interpolation
  2970. *
  2971. * @returns Pluraled message
  2972. */
  2973. <Key extends string>(key: Key | ResourceKeys, list: unknown[]): TranslateResult;
  2974. /**
  2975. * Locale message pluralization
  2976. *
  2977. * @remarks
  2978. * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details.
  2979. *
  2980. * @param key - A target locale message key
  2981. * @param named - A values of named interpolation
  2982. *
  2983. * @returns Pluraled message
  2984. */
  2985. <Key extends string>(key: Key | ResourceKeys, named: Record<string, unknown>): TranslateResult;
  2986. /**
  2987. * Locale message pluralization
  2988. *
  2989. * @remarks
  2990. * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details.
  2991. *
  2992. * @param key - A target locale message key
  2993. * @param choice - Which plural string to get. 1 returns the first one.
  2994. *
  2995. * @returns Pluraled message
  2996. */
  2997. <Key extends string>(key: Key | ResourceKeys, choice: number): TranslateResult;
  2998. /**
  2999. * Locale message pluralization
  3000. *
  3001. * @remarks
  3002. * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details.
  3003. *
  3004. * @param key - A target locale message key
  3005. * @param choice - Which plural string to get. 1 returns the first one.
  3006. * @param locale - A locale, it will be used over than global scope or local scope.
  3007. *
  3008. * @returns Pluraled message
  3009. */
  3010. <Key extends string>(key: Key | ResourceKeys, choice: number, locale: Locales | Locale): TranslateResult;
  3011. /**
  3012. * Locale message pluralization
  3013. *
  3014. * @remarks
  3015. * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details.
  3016. *
  3017. * @param key - A target locale message key
  3018. * @param choice - Which plural string to get. 1 returns the first one.
  3019. * @param list - A values of list interpolation
  3020. *
  3021. * @returns Pluraled message
  3022. */
  3023. <Key extends string>(key: Key | ResourceKeys, choice: number, list: unknown[]): TranslateResult;
  3024. /**
  3025. * Locale message pluralization
  3026. *
  3027. * @remarks
  3028. * Overloaded `tc`. About details, see the [call signature](legacy#key-key-resourcekeys-translateresult-2) details.
  3029. *
  3030. * @param key - A target locale message key
  3031. * @param choice - Which plural string to get. 1 returns the first one.
  3032. * @param named - A values of named interpolation
  3033. *
  3034. * @returns Pluraled message
  3035. */
  3036. <Key extends string>(key: Key | ResourceKeys, choice: number, named: Record<string, unknown>): TranslateResult;
  3037. }
  3038. /** @VueI18nComposition */
  3039. export declare type VueMessageType = string | ResourceNode | VNode;
  3040. export declare type WarnHtmlInMessageLevel = 'off' | 'warn' | 'error';
  3041. export { }
  3042. declare module '@vue/runtime-core' {
  3043. /**
  3044. * Component Custom Options for Vue I18n
  3045. *
  3046. * @VueI18nInjection
  3047. */
  3048. export interface ComponentCustomOptions {
  3049. /**
  3050. * VueI18n options
  3051. *
  3052. * @remarks
  3053. * See the {@link VueI18nOptions}
  3054. */
  3055. i18n?: VueI18nOptions
  3056. /**
  3057. * For custom blocks options
  3058. * @internal
  3059. */
  3060. __i18n?: CustomBlocks
  3061. /**
  3062. * For devtools
  3063. * @internal
  3064. */
  3065. __INTLIFY_META__?: string
  3066. }
  3067. /**
  3068. * Component Custom Properties for Vue I18n
  3069. *
  3070. * @VueI18nInjection
  3071. */
  3072. export interface ComponentCustomProperties {
  3073. /**
  3074. * Exported Global Composer instance, or global VueI18n instance.
  3075. *
  3076. * @remarks
  3077. * 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}.
  3078. * 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.
  3079. * The locales, locale messages, and other resources managed by the instance referenced by this property are valid as global scope.
  3080. * 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.
  3081. */
  3082. $i18n: VueI18n | ExportedGlobalComposer
  3083. /**
  3084. * Locale message translation
  3085. *
  3086. * @remarks
  3087. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  3088. *
  3089. * 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`}.
  3090. *
  3091. * In {@link I18nMode | Composition API mode}, the `$t` is injected by `app.config.globalProperties`.
  3092. * the input / output is the same as for Composer, and it work on **global scope**. About that details, see {@link Composer#t | `Composer#t` }.
  3093. *
  3094. * @param key - A target locale message key
  3095. *
  3096. * @returns translation message
  3097. */
  3098. $t<
  3099. Key extends string,
  3100. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3101. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3102. ? PickupPaths<{
  3103. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3104. }>
  3105. : never,
  3106. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3107. >(
  3108. key: Key | ResourceKeys | Path
  3109. ): TranslateResult
  3110. /**
  3111. * Locale message translation
  3112. *
  3113. * @remarks
  3114. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3115. *
  3116. * @param key - A target locale message key
  3117. * @param locale - A locale, override locale that global scope or local scope
  3118. *
  3119. * @returns translation message
  3120. */
  3121. $t<
  3122. Key extends string,
  3123. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3124. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3125. ? PickupPaths<{
  3126. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3127. }>
  3128. : never,
  3129. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3130. >(
  3131. key: Key | ResourceKeys | Path
  3132. ): TranslateResult
  3133. /**
  3134. * Locale message translation
  3135. *
  3136. * @remarks
  3137. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3138. *
  3139. * @param key - A target locale message key
  3140. * @param locale - A locale, override locale that global scope or local scope
  3141. * @param list - A values of list interpolation
  3142. *
  3143. * @returns translation message
  3144. */
  3145. $t<
  3146. Key extends string,
  3147. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3148. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3149. ? PickupPaths<{
  3150. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3151. }>
  3152. : never,
  3153. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3154. >(
  3155. key: Key | ResourceKeys | Path,
  3156. locale: Locale,
  3157. list: unknown[]
  3158. ): TranslateResult
  3159. /**
  3160. * Locale message translation
  3161. *
  3162. * @remarks
  3163. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3164. *
  3165. * @param key - A target locale message key
  3166. * @param locale - A locale, override locale that global scope or local scope
  3167. * @param named - A values of named interpolation
  3168. *
  3169. * @returns translation message
  3170. */
  3171. $t<
  3172. Key extends string,
  3173. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3174. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3175. ? PickupPaths<{
  3176. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3177. }>
  3178. : never,
  3179. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3180. >(
  3181. key: Key | ResourceKeys | Path,
  3182. locale: Locale,
  3183. named: object
  3184. ): TranslateResult
  3185. /**
  3186. * Locale message translation
  3187. *
  3188. * @remarks
  3189. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3190. *
  3191. * @param key - A target locale message key
  3192. * @param list - A values of list interpolation
  3193. *
  3194. * @returns translation message
  3195. */
  3196. $t<
  3197. Key extends string,
  3198. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3199. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3200. ? PickupPaths<{
  3201. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3202. }>
  3203. : never,
  3204. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3205. >(
  3206. key: Key | ResourceKeys | Path,
  3207. list: unknown[]
  3208. ): TranslateResult
  3209. /**
  3210. * Locale message translation
  3211. *
  3212. * @remarks
  3213. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3214. *
  3215. * @param key - A target locale message key
  3216. * @param named - A values of named interpolation
  3217. *
  3218. * @returns translation message
  3219. */
  3220. $t<
  3221. Key extends string,
  3222. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3223. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3224. ? PickupPaths<{
  3225. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3226. }>
  3227. : never,
  3228. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3229. >(
  3230. key: Key | ResourceKeys | Path,
  3231. named: Record<string, unknown>
  3232. ): TranslateResult
  3233. /**
  3234. * Locale message translation
  3235. *
  3236. * @remarks
  3237. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3238. *
  3239. * @param key - A target locale message key
  3240. *
  3241. * @returns translation message
  3242. */
  3243. $t<
  3244. Key extends string,
  3245. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3246. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3247. ? PickupPaths<{
  3248. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3249. }>
  3250. : never,
  3251. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3252. >(
  3253. key: Key | ResourceKeys | Path
  3254. ): string
  3255. /**
  3256. * Locale message translation
  3257. *
  3258. * @remarks
  3259. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3260. *
  3261. * @param key - A target locale message key
  3262. * @param plural - A choice number of plural
  3263. *
  3264. * @returns translation message
  3265. */
  3266. $t<
  3267. Key extends string,
  3268. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3269. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3270. ? PickupPaths<{
  3271. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3272. }>
  3273. : never,
  3274. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3275. >(
  3276. key: Key | ResourceKeys | Path,
  3277. plural: number
  3278. ): string
  3279. /**
  3280. * Locale message translation
  3281. *
  3282. * @remarks
  3283. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3284. *
  3285. * @param key - A target locale message key
  3286. * @param plural - Which plural string to get. 1 returns the first one.
  3287. * @param options - An options, see the {@link TranslateOptions}
  3288. *
  3289. * @returns translation message
  3290. */
  3291. $t<
  3292. Key extends string,
  3293. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3294. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3295. ? PickupPaths<{
  3296. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3297. }>
  3298. : never,
  3299. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3300. >(
  3301. key: Key | ResourceKeys | Path,
  3302. plural: number,
  3303. options: TranslateOptions
  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 defaultMsg - A default message to return if no translation was found
  3313. *
  3314. * @returns translation message
  3315. */
  3316. $t<
  3317. Key extends string,
  3318. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3319. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3320. ? PickupPaths<{
  3321. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3322. }>
  3323. : never,
  3324. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3325. >(
  3326. key: Key | ResourceKeys | Path,
  3327. defaultMsg: string
  3328. ): string
  3329. /**
  3330. * Locale message translation
  3331. *
  3332. * @remarks
  3333. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3334. *
  3335. * @param key - A target locale message key
  3336. * @param defaultMsg - A default message to return if no translation was found
  3337. * @param options - An options, see the {@link TranslateOptions}
  3338. *
  3339. * @returns translation message
  3340. */
  3341. $t<
  3342. Key extends string,
  3343. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3344. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3345. ? PickupPaths<{
  3346. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3347. }>
  3348. : never,
  3349. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3350. >(
  3351. key: Key | ResourceKeys | Path,
  3352. defaultMsg: string,
  3353. options: TranslateOptions
  3354. ): string
  3355. /**
  3356. * Locale message translation
  3357. *
  3358. * @remarks
  3359. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3360. *
  3361. * @param key - A target locale message key
  3362. * @param list - A values of list interpolation
  3363. *
  3364. * @returns translation message
  3365. */
  3366. $t<
  3367. Key extends string,
  3368. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3369. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3370. ? PickupPaths<{
  3371. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3372. }>
  3373. : never,
  3374. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3375. >(
  3376. key: Key | ResourceKeys | Path,
  3377. list: unknown[]
  3378. ): string
  3379. /**
  3380. * Locale message translation
  3381. *
  3382. * @remarks
  3383. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3384. *
  3385. * @param key - A target locale message key
  3386. * @param list - A values of list interpolation
  3387. * @param plural - A choice number of plural
  3388. *
  3389. * @returns translation message
  3390. */
  3391. $t<
  3392. Key extends string,
  3393. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3394. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3395. ? PickupPaths<{
  3396. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3397. }>
  3398. : never,
  3399. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3400. >(
  3401. key: Key | ResourceKeys | Path,
  3402. list: unknown[],
  3403. plural: number
  3404. ): string
  3405. /**
  3406. * Locale message translation
  3407. *
  3408. * @remarks
  3409. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3410. *
  3411. * @param key - A target locale message key
  3412. * @param list - A values of list interpolation
  3413. * @param defaultMsg - A default message to return if no translation was found
  3414. *
  3415. * @returns translation message
  3416. */
  3417. $t<
  3418. Key extends string,
  3419. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3420. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3421. ? PickupPaths<{
  3422. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3423. }>
  3424. : never,
  3425. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3426. >(
  3427. key: Key | ResourceKeys | Path,
  3428. list: unknown[],
  3429. defaultMsg: string
  3430. ): string
  3431. /**
  3432. * Locale message translation
  3433. *
  3434. * @remarks
  3435. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3436. *
  3437. * @param key - A target locale message key
  3438. * @param list - A values of list interpolation
  3439. * @param options - An options, see the {@link TranslateOptions}
  3440. *
  3441. * @returns translation message
  3442. */
  3443. $t<
  3444. Key extends string,
  3445. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3446. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3447. ? PickupPaths<{
  3448. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3449. }>
  3450. : never,
  3451. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3452. >(
  3453. key: Key | ResourceKeys | Path,
  3454. list: unknown[],
  3455. options: TranslateOptions
  3456. ): string
  3457. /**
  3458. * Locale message translation
  3459. *
  3460. * @remarks
  3461. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3462. *
  3463. * @param key - A target locale message key
  3464. * @param named - A values of named interpolation
  3465. *
  3466. * @returns translation message
  3467. */
  3468. $t<
  3469. Key extends string,
  3470. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3471. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3472. ? PickupPaths<{
  3473. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3474. }>
  3475. : never,
  3476. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3477. >(
  3478. key: Key | ResourceKeys | Path,
  3479. named: NamedValue
  3480. ): string
  3481. /**
  3482. * Locale message translation
  3483. *
  3484. * @remarks
  3485. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3486. *
  3487. * @param key - A target locale message key
  3488. * @param named - A values of named interpolation
  3489. * @param plural - A choice number of plural
  3490. *
  3491. * @returns translation message
  3492. */
  3493. $t<
  3494. Key extends string,
  3495. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3496. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3497. ? PickupPaths<{
  3498. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3499. }>
  3500. : never,
  3501. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3502. >(
  3503. key: Key | ResourceKeys | Path,
  3504. named: NamedValue,
  3505. plural: number
  3506. ): string
  3507. /**
  3508. * Locale message translation
  3509. *
  3510. * @remarks
  3511. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3512. *
  3513. * @param key - A target locale message key
  3514. * @param named - A values of named interpolation
  3515. * @param defaultMsg - A default message to return if no translation was found
  3516. *
  3517. * @returns translation message
  3518. */
  3519. $t<
  3520. Key extends string,
  3521. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3522. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3523. ? PickupPaths<{
  3524. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3525. }>
  3526. : never,
  3527. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3528. >(
  3529. key: Key | ResourceKeys | Path,
  3530. named: NamedValue,
  3531. defaultMsg: string
  3532. ): string
  3533. /**
  3534. * Locale message translation
  3535. *
  3536. * @remarks
  3537. * Overloaded `$t`. About details, see the {@link $t} remarks.
  3538. *
  3539. * @param key - A target locale message key
  3540. * @param named - A values of named interpolation
  3541. * @param options - An options, see the {@link TranslateOptions}
  3542. *
  3543. * @returns translation message
  3544. */
  3545. $t<
  3546. Key extends string,
  3547. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3548. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3549. ? PickupPaths<{
  3550. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3551. }>
  3552. : never,
  3553. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3554. >(
  3555. key: Key | ResourceKeys | Path,
  3556. named: NamedValue,
  3557. options: TranslateOptions
  3558. ): string
  3559. /**
  3560. * Resolve locale message translation
  3561. *
  3562. * @remarks
  3563. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  3564. *
  3565. * 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`}.
  3566. *
  3567. * In {@link I18nMode | Composition API mode}, the `$rt` is injected by `app.config.globalProperties`.
  3568. * the input / output is the same as for Composer, and it work on **global scope**. About that details, see {@link Composer#rt | `Composer#rt` }.
  3569. *
  3570. * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `$tm`.
  3571. *
  3572. * @returns translated message
  3573. */
  3574. $rt(message: MessageFunction<VueMessageType> | VueMessageType): string
  3575. /**
  3576. * Resolve locale message translation for plurals
  3577. *
  3578. * @remarks
  3579. * Overloaded `$rt`. About details, see the {@link $rt} remarks.
  3580. *
  3581. * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `$tm`.
  3582. * @param plural - Which plural string to get. 1 returns the first one.
  3583. * @param options - Additional {@link TranslateOptions | options} for translation
  3584. *
  3585. * @returns Translated message
  3586. */
  3587. $rt(
  3588. message: MessageFunction<VueMessageType> | VueMessageType,
  3589. plural: number,
  3590. options?: TranslateOptions
  3591. ): string
  3592. /**
  3593. * Resolve locale message translation for list interpolations
  3594. *
  3595. * @remarks
  3596. * Overloaded `$rt`. About details, see the {@link $rt} remarks.
  3597. *
  3598. * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `$tm`.
  3599. * @param list - A values of list interpolation.
  3600. * @param options - Additional {@link TranslateOptions | options} for translation
  3601. *
  3602. * @returns Translated message
  3603. */
  3604. $rt(
  3605. message: MessageFunction<VueMessageType> | VueMessageType,
  3606. list: unknown[],
  3607. options?: TranslateOptions
  3608. ): string
  3609. /**
  3610. * Resolve locale message translation for named interpolations
  3611. *
  3612. * @remarks
  3613. * Overloaded `$rt`. About details, see the {@link $rt} remarks.
  3614. *
  3615. * @param message - A target locale message to be resolved. You will need to specify the locale message returned by `$tm`.
  3616. * @param named - A values of named interpolation.
  3617. * @param options - Additional {@link TranslateOptions | options} for translation
  3618. *
  3619. * @returns Translated message
  3620. */
  3621. $rt(
  3622. message: MessageFunction<VueMessageType> | VueMessageType,
  3623. named: NamedValue,
  3624. options?: TranslateOptions
  3625. ): string
  3626. /**
  3627. * Locale message pluralization
  3628. *
  3629. * @remarks
  3630. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  3631. *
  3632. * The input / output is the same as for VueI18n instance. About that details, see {@link VueI18n#tc | `VueI18n#tc` }.
  3633. * The value of plural is handled with default `1`.
  3634. * Supported for Legacy API mode only.
  3635. *
  3636. * @param key - A target locale message key
  3637. *
  3638. * @returns translation message that is pluraled
  3639. */
  3640. $tc<
  3641. Key extends string,
  3642. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3643. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3644. ? PickupPaths<{
  3645. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3646. }>
  3647. : never,
  3648. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3649. >(
  3650. key: Key | ResourceKeys | Path
  3651. ): TranslateResult
  3652. /**
  3653. * Locale message pluralization
  3654. *
  3655. * @remarks
  3656. * Overloaded `$tc`. About details, see the {@link $tc} remarks.
  3657. * Supported for Legacy API mode only.
  3658. *
  3659. * @param key - A target locale message key
  3660. * @param locale - A locale, override locale that global scope or local scope
  3661. *
  3662. * @returns translation message that is pluraled
  3663. */
  3664. $tc<
  3665. Key extends string,
  3666. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3667. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3668. ? PickupPaths<{
  3669. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3670. }>
  3671. : never,
  3672. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3673. >(
  3674. key: Key | ResourceKeys | Path,
  3675. locale: Locale
  3676. ): TranslateResult
  3677. /**
  3678. * Locale message pluralization
  3679. *
  3680. * @remarks
  3681. * Overloaded `$tc`. About details, see the {@link $tc} remarks.
  3682. * Supported for Legacy API mode only.
  3683. *
  3684. * @param key - A target locale message key
  3685. * @param list - A values of list interpolation
  3686. *
  3687. * @returns translation message that is pluraled
  3688. */
  3689. $tc<
  3690. Key extends string,
  3691. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3692. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3693. ? PickupPaths<{
  3694. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3695. }>
  3696. : never,
  3697. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3698. >(
  3699. key: Key | ResourceKeys | Path,
  3700. list: unknown[]
  3701. ): TranslateResult
  3702. /**
  3703. * Locale message pluralization
  3704. * Supported for Legacy API mode only.
  3705. *
  3706. * @remarks
  3707. * Overloaded `$tc`. About details, see the {@link $tc} remarks.
  3708. * Supported for Legacy API mode only.
  3709. *
  3710. * @param key - A target locale message key
  3711. * @param named - A values of named interpolation
  3712. *
  3713. * @returns translation message that is pluraled
  3714. */
  3715. $tc<
  3716. Key extends string,
  3717. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3718. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3719. ? PickupPaths<{
  3720. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3721. }>
  3722. : never,
  3723. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3724. >(
  3725. key: Key | ResourceKeys | Path,
  3726. named: Record<string, unknown>
  3727. ): TranslateResult
  3728. /**
  3729. * Locale message pluralization
  3730. * Supported for Legacy API mode only.
  3731. *
  3732. * @remarks
  3733. * Overloaded `$tc`. About details, see the {@link $tc} remarks.
  3734. * Supported for Legacy API mode only.
  3735. *
  3736. * @param key - A target locale message key
  3737. * @param choice - Which plural string to get. 1 returns the first one.
  3738. *
  3739. * @returns translation message that is pluraled
  3740. */
  3741. $tc<
  3742. Key extends string,
  3743. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3744. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3745. ? PickupPaths<{
  3746. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3747. }>
  3748. : never,
  3749. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3750. >(
  3751. key: Key | ResourceKeys | Path,
  3752. choice: number
  3753. ): TranslateResult
  3754. /**
  3755. * Locale message pluralization
  3756. * Supported for Legacy API mode only.
  3757. *
  3758. * @remarks
  3759. * Overloaded `$tc`. About details, see the {@link $tc} remarks.
  3760. * Supported for Legacy API mode only.
  3761. *
  3762. * @param key - A target locale message key
  3763. * @param choice - Which plural string to get. 1 returns the first one.
  3764. * @param locale - A locale, override locale that global scope or local scope
  3765. *
  3766. * @returns translation message that is pluraled
  3767. */
  3768. $tc<
  3769. Key extends string,
  3770. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3771. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3772. ? PickupPaths<{
  3773. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3774. }>
  3775. : never,
  3776. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3777. >(
  3778. key: Key | ResourceKeys | Path,
  3779. choice: number,
  3780. locale: Locale
  3781. ): TranslateResult
  3782. /**
  3783. * Locale message pluralization
  3784. * Supported for Legacy API mode only.
  3785. *
  3786. * @remarks
  3787. * Overloaded `$tc`. About details, see the {@link $tc} remarks.
  3788. * Supported for Legacy API mode only.
  3789. *
  3790. * @param key - A target locale message key
  3791. * @param choice - Which plural string to get. 1 returns the first one.
  3792. * @param list - A values of list interpolation
  3793. *
  3794. * @returns translation message that is pluraled
  3795. */
  3796. $tc<
  3797. Key extends string,
  3798. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3799. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3800. ? PickupPaths<{
  3801. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3802. }>
  3803. : never,
  3804. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3805. >(
  3806. key: Key | ResourceKeys | Path,
  3807. choice: number,
  3808. list: unknown[]
  3809. ): TranslateResult
  3810. /**
  3811. * Locale message pluralization
  3812. * Supported for Legacy API mode only.
  3813. *
  3814. * @remarks
  3815. * Overloaded `$tc`. About details, see the {@link $tc} remarks.
  3816. * Supported for Legacy API mode only.
  3817. *
  3818. * @param key - A target locale message key
  3819. * @param choice - Which plural string to get. 1 returns the first one.
  3820. * @param named - A values of named interpolation
  3821. *
  3822. * @returns translation message that is pluraled
  3823. */
  3824. $tc<
  3825. Key extends string,
  3826. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3827. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3828. ? PickupPaths<{
  3829. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3830. }>
  3831. : never,
  3832. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3833. >(
  3834. key: Key | ResourceKeys | Path,
  3835. choice: number,
  3836. named: Record<string, unknown>
  3837. ): TranslateResult
  3838. /**
  3839. * Translation message exist
  3840. *
  3841. * @remarks
  3842. * About that details, see {@link VueI18n#te | `VueI18n#te` } or {@link Composer#te | `Composer#te`}.
  3843. *
  3844. * @param key - A target locale message key
  3845. * @param locale - A locale, optional, override locale that global scope or local scope
  3846. *
  3847. * @returns if found locale message, `true`, else `false`
  3848. */
  3849. $te<
  3850. Key extends string,
  3851. DefinedLocaleMessage extends RemovedIndexResources<DefineLocaleMessage> = RemovedIndexResources<DefineLocaleMessage>,
  3852. Keys = IsEmptyObject<DefinedLocaleMessage> extends false
  3853. ? PickupPaths<{
  3854. [K in keyof DefinedLocaleMessage]: DefinedLocaleMessage[K]
  3855. }>
  3856. : never,
  3857. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3858. >(
  3859. key: Key | ResourceKeys | Path,
  3860. locale?: Locale
  3861. ): boolean
  3862. /**
  3863. * Datetime formatting
  3864. *
  3865. * @remarks
  3866. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  3867. *
  3868. * 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` }.
  3869. *
  3870. * In {@link I18nMode | Composition API mode}, the `$d` is injected by `app.config.globalProperties`.
  3871. * 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` }.
  3872. *
  3873. * @param value - A value, timestamp number or `Date` instance
  3874. *
  3875. * @returns formatted value
  3876. */
  3877. $d(value: number | Date): DateTimeFormatResult
  3878. /**
  3879. * Datetime formatting
  3880. *
  3881. * @remarks
  3882. * Overloaded `$d`. About details, see the {@link $d} remarks.
  3883. *
  3884. * @param value - A value, timestamp number or `Date` instance
  3885. * @param key - A key of datetime formats
  3886. *
  3887. * @returns formatted value
  3888. */
  3889. $d<
  3890. Value extends number | Date = number,
  3891. Key extends string = string,
  3892. DefinedDateTimeFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>,
  3893. Keys = IsEmptyObject<DefinedDateTimeFormat> extends false
  3894. ? PickupFormatPathKeys<{
  3895. [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K]
  3896. }>
  3897. : never,
  3898. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3899. >(
  3900. value: Value,
  3901. key: Key | ResourceKeys
  3902. ): DateTimeFormatResult
  3903. /**
  3904. * Datetime formatting
  3905. *
  3906. * @remarks
  3907. * Overloaded `$d`. About details, see the {@link $d} remarks.
  3908. *
  3909. * @param value - A value, timestamp number or `Date` instance
  3910. * @param key - A key of datetime formats
  3911. * @param locale - A locale, optional, override locale that global scope or local scope
  3912. *
  3913. * @returns formatted value
  3914. */
  3915. $d<
  3916. Value extends number | Date = number,
  3917. Key extends string = string,
  3918. DefinedDateTimeFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>,
  3919. Keys = IsEmptyObject<DefinedDateTimeFormat> extends false
  3920. ? PickupFormatPathKeys<{
  3921. [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K]
  3922. }>
  3923. : never,
  3924. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3925. >(
  3926. value: Value,
  3927. key: Key | ResourceKeys,
  3928. locale: Locale
  3929. ): DateTimeFormatResult
  3930. /**
  3931. * Datetime formatting
  3932. *
  3933. * @remarks
  3934. * Overloaded `$d`. About details, see the {@link $d} remarks.
  3935. *
  3936. * @param value - A value, timestamp number or `Date` instance
  3937. * @param args - An argument values
  3938. *
  3939. * @returns formatted value
  3940. */
  3941. $d(
  3942. value: number | Date,
  3943. args: { [key: string]: string }
  3944. ): DateTimeFormatResult
  3945. /**
  3946. * Datetime formatting
  3947. *
  3948. * @remarks
  3949. * Overloaded `$d`. About details, see the {@link $d} remarks.
  3950. *
  3951. * @param value - A value, timestamp number or `Date` instance
  3952. *
  3953. * @returns formatted value
  3954. */
  3955. $d(value: number | Date): string
  3956. /**
  3957. * Datetime formatting
  3958. *
  3959. * @remarks
  3960. * Overloaded `$d`. About details, see the {@link $d} remarks.
  3961. *
  3962. * @param value - A value, timestamp number or `Date` instance
  3963. * @param key - A key of datetime formats
  3964. *
  3965. * @returns formatted value
  3966. */
  3967. $d<
  3968. Value extends number | Date = number,
  3969. Key extends string = string,
  3970. DefinedDateTimeFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>,
  3971. Keys = IsEmptyObject<DefinedDateTimeFormat> extends false
  3972. ? PickupFormatPathKeys<{
  3973. [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K]
  3974. }>
  3975. : never,
  3976. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  3977. >(
  3978. value: Value,
  3979. key: Key | ResourceKeys
  3980. ): string
  3981. /**
  3982. * Datetime formatting
  3983. *
  3984. * @remarks
  3985. * Overloaded `$d`. About details, see the {@link $d} remarks.
  3986. *
  3987. * @param value - A value, timestamp number or `Date` instance
  3988. * @param key - A key of datetime formats
  3989. * @param locale - A locale, optional, override locale that global scope or local scope
  3990. *
  3991. * @returns formatted value
  3992. */
  3993. $d<
  3994. Value extends number | Date = number,
  3995. Key extends string = string,
  3996. DefinedDateTimeFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>,
  3997. Keys = IsEmptyObject<DefinedDateTimeFormat> extends false
  3998. ? PickupFormatPathKeys<{
  3999. [K in keyof DefinedDateTimeFormat]: DefinedDateTimeFormat[K]
  4000. }>
  4001. : never,
  4002. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  4003. >(
  4004. value: Value,
  4005. key: Key | ResourceKeys,
  4006. locale: Locale
  4007. ): string
  4008. /**
  4009. * Datetime formatting
  4010. *
  4011. * @remarks
  4012. * Overloaded `$d`. About details, see the {@link $d} remarks.
  4013. *
  4014. * @param value - A value, timestamp number or `Date` instance
  4015. * @param options - An options, see the {@link DateTimeOptions}
  4016. *
  4017. * @returns formatted value
  4018. */
  4019. $d(value: number | Date, options: DateTimeOptions): string
  4020. /**
  4021. * Number formatting
  4022. *
  4023. * @remarks
  4024. * If this is used in a reactive context, it will re-evaluate once the locale changes.
  4025. *
  4026. * 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` }.
  4027. *
  4028. * In {@link I18nMode | Composition API mode}, the `$n` is injected by `app.config.globalProperties`.
  4029. * 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` }.
  4030. *
  4031. * @param value - A number value
  4032. *
  4033. * @returns formatted value
  4034. */
  4035. $n(value: number): NumberFormatResult
  4036. /**
  4037. * Number formatting
  4038. *
  4039. * @remarks
  4040. * Overloaded `$n`. About details, see the {@link $n} remarks.
  4041. *
  4042. * @param value - A number value
  4043. * @param key - A key of number formats
  4044. *
  4045. * @returns formatted value
  4046. */
  4047. $n<
  4048. Key extends string = string,
  4049. DefinedNumberFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>,
  4050. Keys = IsEmptyObject<DefinedNumberFormat> extends false
  4051. ? PickupFormatPathKeys<{
  4052. [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K]
  4053. }>
  4054. : never,
  4055. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  4056. >(
  4057. value: number,
  4058. key: Key | ResourceKeys
  4059. ): NumberFormatResult
  4060. /**
  4061. * Number formatting
  4062. *
  4063. * @remarks
  4064. * Overloaded `$n`. About details, see the {@link $n} remarks.
  4065. *
  4066. * @param value - A number value
  4067. * @param key - A key of number formats
  4068. * @param locale - A locale, optional, override locale that global scope or local scope
  4069. *
  4070. * @returns formatted value
  4071. */
  4072. $n<
  4073. Key extends string = string,
  4074. DefinedNumberFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>,
  4075. Keys = IsEmptyObject<DefinedNumberFormat> extends false
  4076. ? PickupFormatPathKeys<{
  4077. [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K]
  4078. }>
  4079. : never,
  4080. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  4081. >(
  4082. value: number,
  4083. key: Key | ResourceKeys,
  4084. locale: Locale
  4085. ): 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 args - An argument values
  4094. *
  4095. * @returns formatted value
  4096. */
  4097. $n(
  4098. value: number,
  4099. args: { [key: string]: string | boolean | number }
  4100. ): NumberFormatResult
  4101. /**
  4102. * Number formatting
  4103. *
  4104. * @remarks
  4105. * Overloaded `$n`. About details, see the {@link $n} remarks.
  4106. *
  4107. * @param value - A number value
  4108. * @param key - A key of number formats
  4109. * @param args - An argument values
  4110. *
  4111. * @returns formatted value
  4112. */
  4113. $n(
  4114. value: number,
  4115. key: string,
  4116. args: { [key: string]: string | boolean | number }
  4117. ): NumberFormatResult
  4118. /**
  4119. * Number formatting
  4120. *
  4121. * @remarks
  4122. * Overloaded `$n`. About details, see the {@link $n} remarks.
  4123. *
  4124. * @param value - A number value
  4125. * @param key - A key of number formats
  4126. * @param locale - A locale, optional, override locale that global scope or local scope
  4127. * @param args - An argument values
  4128. *
  4129. * @returns formatted value
  4130. */
  4131. $n(
  4132. value: number,
  4133. key: string,
  4134. locale: Locale,
  4135. args: { [key: string]: string | boolean | number }
  4136. ): NumberFormatResult
  4137. /**
  4138. * Number formatting
  4139. *
  4140. * @remarks
  4141. * Overloaded `$n`. About details, see the {@link $n} remarks.
  4142. *
  4143. * @param value - A number value
  4144. *
  4145. * @returns formatted value
  4146. */
  4147. $n(value: number): string
  4148. /**
  4149. * Number formatting
  4150. *
  4151. * @remarks
  4152. * Overloaded `$n`. About details, see the {@link $n} remarks.
  4153. *
  4154. * @param value - A number value
  4155. * @param key - A key of number formats
  4156. *
  4157. * @returns formatted value
  4158. */
  4159. $n<
  4160. Key extends string = string,
  4161. DefinedNumberFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>,
  4162. Keys = IsEmptyObject<DefinedNumberFormat> extends false
  4163. ? PickupFormatPathKeys<{
  4164. [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K]
  4165. }>
  4166. : never,
  4167. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  4168. >(
  4169. value: number,
  4170. key: Key | ResourceKeys
  4171. ): string
  4172. /**
  4173. * Number formatting
  4174. *
  4175. * @remarks
  4176. * Overloaded `$n`. About details, see the {@link $n} remarks.
  4177. *
  4178. * @param value - A number value
  4179. * @param key - A key of number formats
  4180. * @param locale - A locale, optional, override locale that global scope or local scope
  4181. *
  4182. * @returns formatted value
  4183. */
  4184. $n<
  4185. Key extends string = string,
  4186. DefinedNumberFormat extends RemovedIndexResources<DefineDateTimeFormat> = RemovedIndexResources<DefineDateTimeFormat>,
  4187. Keys = IsEmptyObject<DefinedNumberFormat> extends false
  4188. ? PickupFormatPathKeys<{
  4189. [K in keyof DefinedNumberFormat]: DefinedNumberFormat[K]
  4190. }>
  4191. : never,
  4192. ResourceKeys extends Keys = IsNever<Keys> extends false ? Keys : never
  4193. >(
  4194. value: number,
  4195. key: Key | ResourceKeys,
  4196. locale: Locale
  4197. ): string
  4198. /**
  4199. * Number formatting
  4200. *
  4201. * @remarks
  4202. * Overloaded `$n`. About details, see the {@link $n} remarks.
  4203. *
  4204. * @param value - A number value
  4205. * @param options - An options, see the {@link NumberOptions}
  4206. *
  4207. * @returns formatted value
  4208. */
  4209. $n(value: number, options: NumberOptions): string
  4210. /**
  4211. * Locale messages getter
  4212. *
  4213. * 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` }.
  4214. *
  4215. * @remarks
  4216. * In {@link I18nMode | Composition API mode}, the `$tm` is injected by `app.config.globalProperties`.
  4217. * 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` }.
  4218. * Based on the current `locale`, locale messages will be returned from Composer instance messages.
  4219. * If you change the `locale`, the locale messages returned will also correspond to the locale.
  4220. * If there are no locale messages for the given `key` in the composer instance messages, they will be returned with fallbacking.
  4221. *
  4222. * @param key - A target locale message key
  4223. *
  4224. * @returns locale messages
  4225. */
  4226. $tm<
  4227. Key extends string,
  4228. Messages extends object = {},
  4229. ResourceKeys extends PickupKeys<Messages> = PickupKeys<Messages>
  4230. >(
  4231. key: Key | ResourceKeys
  4232. ): LocaleMessageValue<VueMessageType> | {}
  4233. }
  4234. }
  4235. declare module 'vue' {
  4236. export interface GlobalComponents {
  4237. ['i18n-t']: typeof Translation
  4238. ['i18n-d']: typeof DatetimeFormat
  4239. ['i18n-n']: typeof NumberFormat
  4240. ['I18nT']: typeof Translation
  4241. ['I18nD']: typeof DatetimeFormat
  4242. ['I18nN']: typeof NumberFormat
  4243. }
  4244. }