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