vue-i18n.d.ts 153 KB

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