vue-i18n.d.ts 148 KB

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