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