vue-i18n.d.ts 110 KB

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