From 7bee10b999249a710a8e28962b2db1d4fd9bde1e Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Tue, 21 Jul 2020 13:20:03 +0900 Subject: [PATCH 01/20] bump up typescript version --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index cea56d584..262da1dbd 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "set-tz": "^0.2.0", "shipjs": "^0.20.0", "ts-jest": "^26.0.0", - "typescript": "^3.9.3", + "typescript": "^3.9.7", "typescript-eslint-language-service": "^3.0.0", "vue": "^3.0.0-beta.15" }, diff --git a/yarn.lock b/yarn.lock index 3e6322481..6ce2216ef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6814,10 +6814,10 @@ typescript-eslint-language-service@^3.0.0: dependencies: read-pkg-up "^7.0.0" -typescript@^3.9.3: - version "3.9.5" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.5.tgz#586f0dba300cde8be52dd1ac4f7e1009c1b13f36" - integrity sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ== +typescript@^3.9.7: + version "3.9.7" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa" + integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw== typescript@~3.7.2: version "3.7.5" From 71fa61460eca0daffded8a96db9ef8ba5ee2cab3 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Tue, 21 Jul 2020 14:33:33 +0900 Subject: [PATCH 02/20] refactoring --- src/core/context.ts | 4 ++-- src/message/compiler.ts | 4 ++-- src/message/errors.ts | 2 +- src/message/generator.ts | 16 ++++++++-------- src/message/options.ts | 8 ++++---- src/message/parser.ts | 10 +++++----- src/message/runtime.ts | 4 ++-- src/message/scanner.ts | 28 ++++++++++++++-------------- src/message/tokenizer.ts | 24 ++++++++++++------------ src/message/transformer.ts | 4 ++-- 10 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/core/context.ts b/src/core/context.ts index fe909eaca..301360922 100644 --- a/src/core/context.ts +++ b/src/core/context.ts @@ -54,7 +54,7 @@ export type MessageCompiler = ( options?: CompileOptions ) => MessageFunction -export type RuntimeOptions = { +export interface RuntimeOptions { locale?: Locale fallbackLocale?: FallbackLocale messages?: LocaleMessages @@ -76,7 +76,7 @@ export type RuntimeOptions = { _numberFormatters?: Map } -export type RuntimeContext = { +export interface RuntimeContext { locale: Locale fallbackLocale: FallbackLocale messages: LocaleMessages diff --git a/src/message/compiler.ts b/src/message/compiler.ts index b499d0f02..0b18ea1c4 100644 --- a/src/message/compiler.ts +++ b/src/message/compiler.ts @@ -1,12 +1,12 @@ import { CompileOptions } from './options' -import { createParser, ResourceNode } from './parser' +import { ResourceNode, createParser } from './parser' import { transform } from './transformer' import { generate } from './generator' import { CompileError, defaultOnError } from './errors' import { MessageFunction, MessageFunctions } from './runtime' import { warn, format, isBoolean } from '../utils' -export type CompileResult = { +export interface CompileResult { code: string ast: ResourceNode // TODO: should be implemetend sourcemap diff --git a/src/message/errors.ts b/src/message/errors.ts index dbfc6bc5d..5ab1596e5 100644 --- a/src/message/errors.ts +++ b/src/message/errors.ts @@ -14,7 +14,7 @@ export interface CompileError extends SyntaxError { location?: SourceLocation } -export type CreateCompileErrorOptions = { +export interface CreateCompileErrorOptions { domain?: CompileDomain messages?: { [code: number]: string } args?: unknown[] diff --git a/src/message/generator.ts b/src/message/generator.ts index d20316695..1d8db8e1a 100644 --- a/src/message/generator.ts +++ b/src/message/generator.ts @@ -26,14 +26,14 @@ type CodeGenContext = { // map?: SourceMapGenerator } -type CodeGenerator = Readonly<{ - context: () => CodeGenContext - push: (code: string) => void - indent: () => void - deindent: (withoutNewLine?: boolean) => void - newline: () => void - helper: (key: string) => string -}> +type CodeGenerator = { + context(): CodeGenContext + push(code: string): void + indent(): void + deindent(withoutNewLine?: boolean): void + newline(): void + helper(key: string): string +} function createCodeGenerator(source?: string): CodeGenerator { const _context = { diff --git a/src/message/options.ts b/src/message/options.ts index a78e354c9..ca444bd17 100644 --- a/src/message/options.ts +++ b/src/message/options.ts @@ -3,12 +3,12 @@ import { CompileError } from './errors' export type CompileErrorHandler = (error: CompileError) => void export type CompileCacheKeyHandler = (source: string) => string -export type TokenizeOptions = { +export interface TokenizeOptions { location?: boolean onError?: CompileErrorHandler } -export type ParserOptions = { +export interface ParserOptions { // Generate source map? // - Default: false // sourceMap?: boolean @@ -19,11 +19,11 @@ export type ParserOptions = { onError?: CompileErrorHandler } -export type TransformOptions = { +export interface TransformOptions { onError?: CompileErrorHandler } -export type CodeGenOptions = { +export interface CodeGenOptions { mode?: 'normal' | 'arrow' // default normal onError?: CompileErrorHandler } diff --git a/src/message/parser.ts b/src/message/parser.ts index c22fcb532..37ebd3230 100644 --- a/src/message/parser.ts +++ b/src/message/parser.ts @@ -1,7 +1,7 @@ -import { createLocation, SourceLocation, Position } from './location' +import { Position, createLocation, SourceLocation } from './location' import { ParserOptions } from './options' import { createCompileError, CompileErrorCodes } from './errors' -import { createTokenizer, Tokenizer, TokenTypes } from './tokenizer' +import { Tokenizer, createTokenizer, TokenTypes } from './tokenizer' export const enum NodeTypes { Resource, // 0 @@ -85,9 +85,9 @@ export interface LinkedModitierNode extends Node { value: Identifier } -export type Parser = Readonly<{ - parse: (source: string) => ResourceNode -}> +export interface Parser { + parse(source: string): ResourceNode +} export const ERROR_DOMAIN = 'parser' diff --git a/src/message/runtime.ts b/src/message/runtime.ts index 2c66d639a..f51e70e6a 100644 --- a/src/message/runtime.ts +++ b/src/message/runtime.ts @@ -34,7 +34,7 @@ export interface MessageProcessor { normalize?: MessageNormalize } -export type MessageContextOptions = { +export interface MessageContextOptions { parent?: MessageContext locale?: string list?: unknown[] @@ -59,7 +59,7 @@ export const enum HelperNameMap { NORMALIZE = 'normalize' } -export type MessageContext = { +export interface MessageContext { list: (index: number) => unknown named: (key: string) => unknown pluralIndex: number diff --git a/src/message/scanner.ts b/src/message/scanner.ts index 94f2ba55c..be082edcc 100644 --- a/src/message/scanner.ts +++ b/src/message/scanner.ts @@ -1,17 +1,17 @@ -export type Scanner = Readonly<{ - index: () => number - line: () => number - column: () => number - peekOffset: () => number - charAt: (offset: number) => string - currentChar: () => string - currentPeek: () => string - next: () => string - peek: () => string - reset: () => void - resetPeek: (offset?: number) => void - skipToPeek: () => void -}> +export interface Scanner { + index(): number + line(): number + column(): number + peekOffset(): number + charAt(offset: number): string + currentChar(): string + currentPeek(): string + next(): string + peek(): string + reset(): void + resetPeek(offset?: number): void + skipToPeek(): void +} export const CHAR_SP = ' ' export const CHAR_CR = '\r' diff --git a/src/message/tokenizer.ts b/src/message/tokenizer.ts index ec849fec2..08e29a5f7 100644 --- a/src/message/tokenizer.ts +++ b/src/message/tokenizer.ts @@ -1,14 +1,14 @@ import { + Scanner, createScanner, CHAR_SP as SPACE, - CHAR_LF as NEW_LINE, - Scanner + CHAR_LF as NEW_LINE } from './scanner' import { SourceLocation, + Position, createLocation, - createPosition, - Position + createPosition } from './location' import { TokenizeOptions } from './options' import { createCompileError, CompileErrorCodes } from './errors' @@ -45,13 +45,13 @@ const EOF = undefined const LITERAL_DELIMITER = "'" export const ERROR_DOMAIN = 'tokenizer' -export type Token = { +export interface Token { type: TokenTypes value?: string loc?: SourceLocation } -export type TokenizeContext = { +export interface TokenizeContext { currentType: TokenTypes offset: number startLoc: Position @@ -64,12 +64,12 @@ export type TokenizeContext = { inLinked: boolean } -export type Tokenizer = Readonly<{ - currentPosition: () => Position - currentOffset: () => number - context: () => TokenizeContext - nextToken: () => Token -}> +export interface Tokenizer { + currentPosition(): Position + currentOffset(): number + context(): TokenizeContext + nextToken(): Token +} export function createTokenizer( source: string, diff --git a/src/message/transformer.ts b/src/message/transformer.ts index 272abd7bc..8a9ef2213 100644 --- a/src/message/transformer.ts +++ b/src/message/transformer.ts @@ -20,8 +20,8 @@ type TransformContext = { } type Transformer = Readonly<{ - context: () => TransformContext - helper: (name: string) => string + context(): TransformContext + helper(name: string): string }> function createTransformer( From 242d374c58b9202d622ad27ed69b0e41e967c31e Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Tue, 21 Jul 2020 14:45:32 +0900 Subject: [PATCH 03/20] add type definition for plural --- src/message/runtime.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/message/runtime.ts b/src/message/runtime.ts index f51e70e6a..03428f5b3 100644 --- a/src/message/runtime.ts +++ b/src/message/runtime.ts @@ -14,6 +14,10 @@ export type PluralizationRule = ( ) => number export type PluralizationRules = { [locale: string]: PluralizationRule } +export type PluralizationProps = { + n?: number + count?: number +} export type LinkedModify = (value: unknown, type: string) => unknown export type LinkedModifiers = { [key: string]: LinkedModify } export type MessageFunction = { @@ -107,13 +111,12 @@ function getPluralIndex(options: MessageContextOptions): number { : index } -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function normalizeNamed(pluralIndex: number, named: any): void { - if (!named.count) { - named.count = pluralIndex +function normalizeNamed(pluralIndex: number, props: PluralizationProps): void { + if (!props.count) { + props.count = pluralIndex } - if (!named.n) { - named.n = pluralIndex + if (!props.n) { + props.n = pluralIndex } } From 64d47b11f488f37679cd4e7cf86efa1cd393a941 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Tue, 21 Jul 2020 17:00:16 +0900 Subject: [PATCH 04/20] updates --- src/core/context.ts | 2 +- src/i18n.ts | 4 ++-- src/message/runtime.ts | 8 ++++---- test/message/runtime.test.ts | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/context.ts b/src/core/context.ts index 301360922..32595fb2c 100644 --- a/src/core/context.ts +++ b/src/core/context.ts @@ -93,7 +93,7 @@ export interface RuntimeContext { processor: MessageProcessor | null warnHtmlMessage: boolean messageCompiler: MessageCompiler - onWarn: (msg: string, err?: Error) => void + onWarn(msg: string, err?: Error): void _datetimeFormatters: Map _numberFormatters: Map _fallbackLocaleStack?: Locale[] diff --git a/src/i18n.ts b/src/i18n.ts index a54dd2c23..54de42512 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -45,7 +45,7 @@ export interface I18nAdditionalOptions { /** * Whether vue-i18n legacy API use on your Vue App. * - * @defaultValue `false` + * @default false */ legacy?: boolean } @@ -66,7 +66,7 @@ export interface I18n { * if you specified `legacy: true` option in `createI18n`, return `legacy`, * else `composable` * - * @defaultValue `composable` + * @default composable */ readonly mode: I18nMode /** diff --git a/src/message/runtime.ts b/src/message/runtime.ts index 03428f5b3..0a2ec8768 100644 --- a/src/message/runtime.ts +++ b/src/message/runtime.ts @@ -64,13 +64,13 @@ export const enum HelperNameMap { } export interface MessageContext { - list: (index: number) => unknown - named: (key: string) => unknown + list(index: number): unknown + named(key: string): unknown pluralIndex: number pluralRule: PluralizationRule orgPluralRule?: PluralizationRule - modifier: (name: string) => LinkedModify - message: (name: string) => MessageFunction + modifier(name: string): LinkedModify + message(name: string): MessageFunction type: string interpolate: MessageInterpolate normalize: MessageNormalize diff --git a/test/message/runtime.test.ts b/test/message/runtime.test.ts index 56bc00b97..1c7dc2dc4 100644 --- a/test/message/runtime.test.ts +++ b/test/message/runtime.test.ts @@ -1,5 +1,5 @@ import { compile } from '../../src/message/compiler' -import { createMessageContext } from '../../src/message/runtime' +import { createMessageContext, NamedValue, MessageContextOptions } from '../../src/message/runtime' import { isString } from '../../src/utils' describe('text', () => { From 7b99321b75f278e2c8315507abfaaecab17292d0 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Sat, 25 Jul 2020 20:14:09 +0900 Subject: [PATCH 05/20] improve runtime and compiler type definition --- package.json | 5 +- src/message/compiler.ts | 12 +- src/message/runtime.ts | 114 +++++--- test-d/runtime.test-d.ts | 83 ++++++ test/message/runtime.test.ts | 53 ++-- yarn.lock | 531 ++++++++++++++++++++++++++++++++++- 6 files changed, 719 insertions(+), 79 deletions(-) create mode 100644 test-d/runtime.test-d.ts diff --git a/package.json b/package.json index 262da1dbd..99b861ed8 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ "set-tz": "^0.2.0", "shipjs": "^0.20.0", "ts-jest": "^26.0.0", + "tsd": "^0.13.1", "typescript": "^3.9.7", "typescript-eslint-language-service": "^3.0.0", "vue": "^3.0.0-beta.15" @@ -114,14 +115,14 @@ "fix": "npm-run-all --parallel lint:fix format:fix", "format": "prettier --config .prettierrc --ignore-path .prettierignore '**/*.{js,json,html}'", "format:fix": "yarn format --write", - "lint": "eslint ./src ./test ./e2e ./benchmark --ext .js,.ts", + "lint": "eslint ./src ./test ./test-d ./e2e ./benchmark --ext .js,.ts", "lint:fix": "yarn lint --fix", "release:prepare": "shipjs prepare", "release:trigger": "shipjs trigger", "test": "npm-run-all lint clean:cache:jest test:cover test:e2e", "test:cover": "yarn test:unit --coverage", "test:e2e": "yarn build && jest --runInBand --config ./jest.e2e.config.js", - "test:type": "tsc -p . --noEmit", + "test:type": "tsd", "test:unit": "yarn clean:cache:jest && cross-env NODE_ICU_DATA=./node_modules/full-icu jest --env node", "test:watch": "yarn clean:cache:jest && cross-env NODE_ICU_DATA=./node_modules/full-icu jest --env node --watch" }, diff --git a/src/message/compiler.ts b/src/message/compiler.ts index 0b18ea1c4..d162e214f 100644 --- a/src/message/compiler.ts +++ b/src/message/compiler.ts @@ -26,7 +26,7 @@ function checkHtmlMessage(source: string, options: CompileOptions): void { } const defaultOnCacheKey = (source: string): string => source -let compileCache: MessageFunctions = Object.create(null) +let compileCache: unknown = Object.create(null) export function clearCompileCache(): void { compileCache = Object.create(null) @@ -49,17 +49,17 @@ export function baseCompile( return { ast, code } } -export function compile( +export function compile( source: string, options: CompileOptions = {} -): MessageFunction { +): MessageFunction { // check HTML message __DEV__ && checkHtmlMessage(source, options) // check caches const onCacheKey = options.onCacheKey || defaultOnCacheKey const key = onCacheKey(source) - const cached = compileCache[key] + const cached = (compileCache as MessageFunctions)[key] if (cached) { return cached } @@ -76,8 +76,8 @@ export function compile( const { code } = baseCompile(source, options) // evaluate function - const msg = new Function(`return ${code}`)() as MessageFunction + const msg = new Function(`return ${code}`)() as MessageFunction // if occured compile error, don't cache - return !occured ? (compileCache[key] = msg) : msg + return !occured ? ((compileCache as MessageFunctions)[key] = msg) : msg } diff --git a/src/message/runtime.ts b/src/message/runtime.ts index 0a2ec8768..23796a9e6 100644 --- a/src/message/runtime.ts +++ b/src/message/runtime.ts @@ -7,47 +7,75 @@ import { isPlainObject } from '../utils' +type ExtractToStringKey = Extract +type ExtractToStringFunction = T[ExtractToStringKey] +// prettier-ignore +type StringConvertable = ExtractToStringKey extends never + ? unknown + : ExtractToStringFunction extends (...args: any) => string // eslint-disable-line @typescript-eslint/no-explicit-any + ? T + : unknown + +export type MessageType = T extends string + ? string + : StringConvertable + +export type MessageFunctionCallable = ( + ctx: MessageContext +) => MessageType +export type MessageFunctionInternal = { + (ctx: MessageContext): MessageType + key?: string + locale?: string + source?: string +} +export type MessageFunction = + | MessageFunctionCallable + | MessageFunctionInternal +export type MessageFunctions = Record> +export type MessageResolveFunction = ( + key: string +) => MessageFunction + +export type MessageNormalize = ( + values: MessageType[] +) => MessageType +export type MessageInterpolate = (val: unknown) => MessageType +export interface MessageProcessor { + type?: string + interpolate?: MessageInterpolate + normalize?: MessageNormalize +} + export type PluralizationRule = ( choice: number, choicesLength: number, orgRule?: PluralizationRule ) => number - export type PluralizationRules = { [locale: string]: PluralizationRule } export type PluralizationProps = { n?: number count?: number } -export type LinkedModify = (value: unknown, type: string) => unknown -export type LinkedModifiers = { [key: string]: LinkedModify } -export type MessageFunction = { - (ctx: MessageContext): unknown - key?: string - locale?: string - source?: string -} -export type MessageFunctions = Record -export type MessageResolveFunction = (key: string) => MessageFunction -export type NamedValue = T & Record -export type MessageNormalize = (values: unknown[]) => unknown -export type MessageInterpolate = (val: unknown) => unknown -export interface MessageProcessor { +export type LinkedModify = ( + value: T, type?: string - interpolate?: MessageInterpolate - normalize?: MessageNormalize -} +) => MessageType +export type LinkedModifiers = { [key: string]: LinkedModify } + +export type NamedValue = T & Record -export interface MessageContextOptions { - parent?: MessageContext +export interface MessageContextOptions { + parent?: MessageContext locale?: string list?: unknown[] named?: NamedValue - modifiers?: LinkedModifiers + modifiers?: LinkedModifiers pluralIndex?: number pluralRules?: PluralizationRules - messages?: MessageFunctions | MessageResolveFunction // TODO: need to design resolve message function? - processor?: MessageProcessor + messages?: MessageFunctions | MessageResolveFunction // TODO: need to design resolve message function? + processor?: MessageProcessor } export const enum HelperNameMap { @@ -63,23 +91,23 @@ export const enum HelperNameMap { NORMALIZE = 'normalize' } -export interface MessageContext { +export interface MessageContext { list(index: number): unknown named(key: string): unknown pluralIndex: number pluralRule: PluralizationRule orgPluralRule?: PluralizationRule - modifier(name: string): LinkedModify - message(name: string): MessageFunction + modifier(name: string): LinkedModify + message(name: string): MessageFunction type: string - interpolate: MessageInterpolate - normalize: MessageNormalize + interpolate: MessageInterpolate + normalize: MessageNormalize } -const DEFAULT_MODIFIER = (str: unknown): unknown => str -const DEFAULT_MESSAGE = (ctx: MessageContext): unknown => '' // eslint-disable-line +const DEFAULT_MODIFIER = (str: string): string => str +const DEFAULT_MESSAGE = (ctx: MessageContext): string => '' // eslint-disable-line export const DEFAULT_MESSAGE_DATA_TYPE = 'text' -const DEFAULT_NORMALIZE = (values: unknown[]): unknown => +const DEFAULT_NORMALIZE = (values: string[]): string => values.length === 0 ? '' : values.join('') const DEFAULT_INTERPOLATE = toDisplayString @@ -96,7 +124,7 @@ function pluralDefault(choice: number, choicesLength: number): number { return choice ? Math.min(choice, 2) : 0 } -function getPluralIndex(options: MessageContextOptions): number { +function getPluralIndex(options: MessageContextOptions): number { // prettier-ignore const index = isNumber(options.pluralIndex) ? options.pluralIndex @@ -120,9 +148,9 @@ function normalizeNamed(pluralIndex: number, props: PluralizationProps): void { } } -export function createMessageContext( - options: MessageContextOptions = {} -): MessageContext { +export function createMessageContext( + options: MessageContextOptions = {} +): MessageContext { const locale = options.locale const pluralIndex = getPluralIndex(options) @@ -147,11 +175,13 @@ export function createMessageContext( isNumber(options.pluralIndex) && normalizeNamed(pluralIndex, _named) const named = (key: string): unknown => _named[key] - const modifier = (name: string): LinkedModify => - options.modifiers ? options.modifiers[name] : DEFAULT_MODIFIER + const modifier = (name: string): LinkedModify => + options.modifiers + ? options.modifiers[name] + : ((DEFAULT_MODIFIER as unknown) as LinkedModify) - function message(name: string): MessageFunction { - // TODO: need to design resolve message function? + // TODO: need to design resolve message function? + function message(name: string): MessageFunction { // prettier-ignore const msg = isFunction(options.messages) ? options.messages(name) @@ -161,7 +191,7 @@ export function createMessageContext( return !msg ? options.parent ? options.parent.message(name) // resolve from parent messages - : DEFAULT_MESSAGE + : ((DEFAULT_MESSAGE as unknown) as MessageFunction) : msg } @@ -173,13 +203,13 @@ export function createMessageContext( const normalize = isPlainObject(options.processor) && isFunction(options.processor.normalize) ? options.processor.normalize - : DEFAULT_NORMALIZE + : ((DEFAULT_NORMALIZE as unknown) as MessageNormalize) const interpolate = isPlainObject(options.processor) && isFunction(options.processor.interpolate) ? options.processor.interpolate - : DEFAULT_INTERPOLATE + : ((DEFAULT_INTERPOLATE as unknown) as MessageInterpolate) return { [HelperNameMap.LIST]: list, diff --git a/test-d/runtime.test-d.ts b/test-d/runtime.test-d.ts new file mode 100644 index 000000000..32a7deded --- /dev/null +++ b/test-d/runtime.test-d.ts @@ -0,0 +1,83 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { expectType } from 'tsd' +import { MessageType } from '../src/message/runtime' + +/** + * Message Type + */ + +interface HaveToString { + toString: () => string +} +interface NotHaveToString { + foo: 1 +} +type HaveToStringTypeAlias = { + toString: (arg1: string, arg2: boolean) => string +} +type NotHaveToStringTypeAlias = { foo: 1 } +class HaveToStringClass { + toString(arg1: number, arg2: Date): string { + return arg1.toString() + arg2.toString() + } +} +class NotHaveToStringClass {} +enum NumberEnum { + One, + Two +} +enum StringEnum { + One = 'one', + Two = 'two' +} + +// OK +expectType('' as MessageType) // default +expectType('' as MessageType) // string type +expectType('' as MessageType<''>) // string literal +expectType(1 as MessageType) // number type +expectType<1>(1 as MessageType<1>) // number literal +expectType(new Date() as MessageType) // Date +expectType(Object.create(null) as MessageType) // Object type +expectType<{ toString: () => '' }>( + Object.create({ toString: () => '' }) as MessageType<{ toString: () => '' }> +) // object literal +expectType>([0] as MessageType>) // Array type +expectType<[1, 2]>([1, 2] as MessageType<[1, 2]>) // Array literal +expectType<[number, string]>([1, ''] as MessageType<[number, string]>) // Tuple +expectType((() => '') as MessageType) // Function +expectType(Symbol('foo') as MessageType) // Symbol +expectType({} as MessageType) // interface have toString +expectType({} as MessageType) // type alias have toString +expectType( + new HaveToStringClass() as MessageType +) // class have toString +expectType(NumberEnum.One as MessageType) // number enum +expectType(NumberEnum.Two as MessageType) // number enum field +expectType(StringEnum.One as MessageType) // string enum +expectType(StringEnum.Two as MessageType) // string enum field +expectType '' }>( + {} as MessageType '' }> +) + +// NG +expectType(Boolean(1) as MessageType) // boolean +expectType(true as MessageType) // true +expectType(false as MessageType) // false +expectType(null as MessageType) // null +expectType(undefined as MessageType) // undefined +expectType(0 as MessageType) // void +expectType('' as MessageType) // any +expectType('' as MessageType) // never +expectType('' as MessageType) // unknown +expectType({} as MessageType) // ts object +expectType({} as MessageType<{}>) // object empty +expectType(/foo/ as MessageType) // RegExp +expectType({ foo: 1 } as MessageType<{ foo: 1 }>) // object that cannot covert +expectType({} as MessageType) // interface does not have toString +expectType({} as MessageType) // type alias does not have toString +expectType( + new NotHaveToStringClass() as MessageType +) // class does not have toString + +/* eslint-enable @typescript-eslint/no-explicit-any */ diff --git a/test/message/runtime.test.ts b/test/message/runtime.test.ts index 1c7dc2dc4..8a3318bbe 100644 --- a/test/message/runtime.test.ts +++ b/test/message/runtime.test.ts @@ -1,7 +1,16 @@ import { compile } from '../../src/message/compiler' -import { createMessageContext, NamedValue, MessageContextOptions } from '../../src/message/runtime' +import { + createMessageContext, + MessageType, + MessageContext +} from '../../src/message/runtime' import { isString } from '../../src/utils' +type MockVNode = { + text: string + toString: () => string +} + describe('text', () => { test('basic', () => { const msg = compile('hello world') @@ -72,7 +81,7 @@ describe('linked', () => { const msg = compile('hi @:name !') const ctx = createMessageContext({ messages: { - name: ctx => 'kazupon' // eslint-disable-line + name: (ctx: MessageContext): string => 'kazupon' // eslint-disable-line } }) expect(msg(ctx)).toMatch(`hi kazupon !`) @@ -259,14 +268,16 @@ describe('plural', () => { }) describe('custom process', () => { - const createVNode = (text: string) => ({ text }) - const normalize = (values: unknown[]): unknown => - values.map(val => (isString(val) ? createVNode(val) : val)) - const interpolate = (val: unknown): unknown => val + const createVNode = (text: string): MockVNode => ({ text }) + const normalize = ( + values: MessageType[] + ): MessageType => + values.map(val => (isString(val) ? createVNode(val) : val)) as MockVNode[] + const interpolate = (val: unknown): MockVNode => val as MockVNode test('simple text', () => { - const msg = compile('hello') - const ctx = createMessageContext({ + const msg = compile('hello') + const ctx = createMessageContext({ processor: { normalize, interpolate @@ -276,8 +287,8 @@ describe('custom process', () => { }) test('list', () => { - const msg = compile('hi, {0}!') - const ctx = createMessageContext({ + const msg = compile('hi, {0}!') + const ctx = createMessageContext({ list: [createVNode('kazupon')], processor: { normalize, @@ -288,8 +299,8 @@ describe('custom process', () => { }) test('named', () => { - const msg = compile('hi {name} !') - const ctx = createMessageContext({ + const msg = compile('hi {name} !') + const ctx = createMessageContext({ named: { name: createVNode('kazupon') }, processor: { normalize, @@ -300,16 +311,16 @@ describe('custom process', () => { }) test('linked', () => { - const msg = compile(`hi @.upper:{'name'} !`) - const ctx = createMessageContext({ + const msg = compile(`hi @.upper:{'name'} !`) + const ctx = createMessageContext({ processor: { normalize, interpolate, type: 'vnode' }, modifiers: { - upper: (val: unknown, type: string): unknown => - `${type}:${(val as { text: string }).text.toUpperCase()}` + upper: (val: string | MockVNode, type: string): string | MockVNode => + `${type}:${(val as MockVNode).text.toUpperCase()}` }, messages: { name: ctx => createVNode('kazupon') // eslint-disable-line @@ -319,16 +330,18 @@ describe('custom process', () => { }) test('plural', () => { - const msg = compile('no apples | {n} @.lower:{unit} | {n} apples') - const ctx = createMessageContext({ + const msg = compile( + 'no apples | {n} @.lower:{unit} | {n} apples' + ) + const ctx = createMessageContext({ processor: { normalize, interpolate, type: 'vnode' }, modifiers: { - lower: (val: unknown, type: string): unknown => - `${type}:${(val as { text: string }).text.toLowerCase()}` + lower: (val: string | MockVNode, type: string): string | MockVNode => + `${type}:${(val as MockVNode).text.toLowerCase()}` }, named: { unit: 'apple', diff --git a/yarn.lock b/yarn.lock index 6ce2216ef..4457344c9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -719,6 +719,11 @@ argparse "~1.0.9" colors "~1.2.1" +"@sindresorhus/is@^0.14.0": + version "0.14.0" + resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" + integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ== + "@sinonjs/commons@^1.7.0": version "1.7.2" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.7.2.tgz#505f55c74e0272b43f6c52d81946bed7058fc0e2" @@ -747,6 +752,13 @@ "@types/node" ">=8.9.0" axios "^0.19.0" +"@szmarczak/http-timer@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-1.1.2.tgz#b1665e2c461a2cd92f4c1bbf50d5454de0d4b421" + integrity sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA== + dependencies: + defer-to-connect "^1.0.1" + "@types/argparse@1.0.33": version "1.0.33" resolved "https://registry.yarnpkg.com/@types/argparse/-/argparse-1.0.33.tgz#2728669427cdd74a99e53c9f457ca2866a37c52d" @@ -864,6 +876,11 @@ resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA== +"@types/minimist@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.0.tgz#69a23a3ad29caf0097f06eda59b361ee2f0639f6" + integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= + "@types/node@*", "@types/node@>= 8", "@types/node@>=8.9.0": version "13.13.4" resolved "https://registry.yarnpkg.com/@types/node/-/node-13.13.4.tgz#1581d6c16e3d4803eb079c87d4ac893ee7501c2c" @@ -1085,6 +1102,13 @@ ajv@^6.10.0, ajv@^6.10.2, ajv@^6.5.5: json-schema-traverse "^0.4.1" uri-js "^4.2.2" +ansi-align@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-3.0.0.tgz#b536b371cf687caaef236c18d3e21fe3797467cb" + integrity sha512-ZpClVKqXN3RGBmKibdfWzqCY4lnjEuoNzU5T0oEFpfd/z5qJHVarukridD4juLO2FXMiwUQxr9WqQtaYa8XRYw== + dependencies: + string-width "^3.0.0" + ansi-escapes@^4.2.1, ansi-escapes@^4.3.1: version "4.3.1" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.1.tgz#a5c47cc43181f1f38ffd7076837700d395522a61" @@ -1195,6 +1219,11 @@ arrify@^1.0.1: resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" integrity sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0= +arrify@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-2.0.1.tgz#c9655e9331e0abcd588d2a7cad7e9956f66701fa" + integrity sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug== + asn1@~0.2.3: version "0.2.4" resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136" @@ -1376,6 +1405,20 @@ before-after-hook@^2.1.0: resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.1.0.tgz#b6c03487f44e24200dd30ca5e6a1979c5d2fb635" integrity sha512-IWIbu7pMqyw3EAJHzzHbWa85b6oud/yfKYg5rqB5hNE8CeMi3nX+2C2sj0HswfblST86hpVEOAb9x34NZd6P7A== +boxen@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/boxen/-/boxen-4.2.0.tgz#e411b62357d6d6d36587c8ac3d5d974daa070e64" + integrity sha512-eB4uT9RGzg2odpER62bBwSLvUeGC+WbRjjyyFhGsKnc8wp/m0+hQsMUvUe3H2V0D5vw0nBdO1hCJoZo5mKeuIQ== + dependencies: + ansi-align "^3.0.0" + camelcase "^5.3.1" + chalk "^3.0.0" + cli-boxes "^2.2.0" + string-width "^4.1.0" + term-size "^2.1.0" + type-fest "^0.8.1" + widest-line "^3.1.0" + brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -1488,6 +1531,19 @@ cache-base@^1.0.1: union-value "^1.0.0" unset-value "^1.0.0" +cacheable-request@^6.0.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-6.1.0.tgz#20ffb8bd162ba4be11e9567d823db651052ca912" + integrity sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg== + dependencies: + clone-response "^1.0.2" + get-stream "^5.1.0" + http-cache-semantics "^4.0.0" + keyv "^3.0.0" + lowercase-keys "^2.0.0" + normalize-url "^4.1.0" + responselike "^1.0.2" + callsites@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" @@ -1518,6 +1574,15 @@ camelcase-keys@^4.0.0: map-obj "^2.0.0" quick-lru "^1.0.0" +camelcase-keys@^6.2.2: + version "6.2.2" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-6.2.2.tgz#5e755d6ba51aa223ec7d3d52f25778210f9dc3c0" + integrity sha512-YrwaA0vEKazPBkn0ipTiMpSajYDSe+KjQfrjhcBMxJt/znbvlHd8Pw/Vamaz5EB4Wfhs3SUR3Z9mwRu/P3s3Yg== + dependencies: + camelcase "^5.3.1" + map-obj "^4.0.0" + quick-lru "^4.0.1" + camelcase@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" @@ -1584,6 +1649,14 @@ chalk@^3.0.0: ansi-styles "^4.1.0" supports-color "^7.1.0" +chalk@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a" + integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + change-case@4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/change-case/-/change-case-4.1.1.tgz#d5005709275952e7963fed7b91e4f9fdb6180afa" @@ -1642,6 +1715,11 @@ clean-stack@^2.0.0: resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b" integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A== +cli-boxes@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-2.2.0.tgz#538ecae8f9c6ca508e3c3c95b453fe93cb4c168d" + integrity sha512-gpaBrMAizVEANOpfZp/EEUixTXDyGt7DFzdK5hU+UbWt/J0lB0w20ncZj59Z9a93xHb9u12zF5BS6i9RKbtg4w== + cli-cursor@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-3.1.0.tgz#264305a7ae490d1d03bf0c9ba7c925d1753af307" @@ -1695,6 +1773,13 @@ clone-deep@^0.2.4: lazy-cache "^1.0.3" shallow-clone "^0.1.2" +clone-response@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/clone-response/-/clone-response-1.0.2.tgz#d1dc973920314df67fbeb94223b4ee350239e96b" + integrity sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws= + dependencies: + mimic-response "^1.0.0" + co@^4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" @@ -1797,6 +1882,18 @@ concat-stream@^1.6.2: readable-stream "^2.2.2" typedarray "^0.0.6" +configstore@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/configstore/-/configstore-5.0.1.tgz#d365021b5df4b98cdd187d6a3b0e3f6a7cc5ed96" + integrity sha512-aMKprgk5YhBNyH25hj8wGt2+D52Sw1DRRIzqBwLp2Ya9mFmY8KPvvtvmna8SxVR9JMZ4kzMD68N22vlaRpkeFA== + dependencies: + dot-prop "^5.2.0" + graceful-fs "^4.1.2" + make-dir "^3.0.0" + unique-string "^2.0.0" + write-file-atomic "^3.0.0" + xdg-basedir "^4.0.0" + constant-case@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/constant-case/-/constant-case-3.0.3.tgz#ac910a99caf3926ac5112f352e3af599d8c5fc0a" @@ -2023,6 +2120,11 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.1, cross-spawn@^7.0.2: shebang-command "^2.0.0" which "^2.0.1" +crypto-random-string@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-2.0.0.tgz#ef2a7a966ec11083388369baa02ebead229b30d5" + integrity sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA== + cssom@^0.4.4: version "0.4.4" resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.4.4.tgz#5a66cf93d2d0b661d80bf6a44fb65f5c2e4e0a10" @@ -2116,7 +2218,7 @@ debug@^3.0.0, debug@^3.1.1: dependencies: ms "^2.1.1" -decamelize-keys@^1.0.0: +decamelize-keys@^1.0.0, decamelize-keys@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.0.tgz#d171a87933252807eb3cb61dc1c1445d078df2d9" integrity sha1-0XGoeTMlKAfrPLYdwcFEXQeN8tk= @@ -2139,6 +2241,18 @@ decode-uri-component@^0.2.0: resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= +decompress-response@^3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" + integrity sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M= + dependencies: + mimic-response "^1.0.0" + +deep-extend@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" + integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== + deep-freeze@^0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/deep-freeze/-/deep-freeze-0.0.1.tgz#3a0b0005de18672819dfd38cd31f91179c893e84" @@ -2154,6 +2268,11 @@ deepmerge@^4.2.2: resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955" integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg== +defer-to-connect@^1.0.1: + version "1.1.3" + resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-1.1.3.tgz#331ae050c08dcf789f8c83a7b81f0ed94f4ac591" + integrity sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ== + define-properties@^1.1.2, define-properties@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" @@ -2249,11 +2368,23 @@ dot-prop@^3.0.0: dependencies: is-obj "^1.0.0" +dot-prop@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-5.2.0.tgz#c34ecc29556dc45f1f4c22697b6f4904e0cc4fcb" + integrity sha512-uEUyaDKoSQ1M4Oq8l45hSE26SnTxL6snNnqvK/VWx5wJhmff5z0FUVJDKDanor/6w3kzE3i7XZOk+7wC0EXr1A== + dependencies: + is-obj "^2.0.0" + dotenv@^8.1.0, dotenv@^8.2.0: version "8.2.0" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-8.2.0.tgz#97e619259ada750eea3e4ea3e26bceea5424b16a" integrity sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw== +duplexer3@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" + integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI= + ecc-jsbn@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" @@ -2353,6 +2484,11 @@ es6-promisify@^5.0.0: dependencies: es6-promise "^4.0.3" +escape-goat@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/escape-goat/-/escape-goat-2.1.1.tgz#1b2dc77003676c457ec760b2dc68edb648188675" + integrity sha512-8/uIhbG12Csjy2JEW7D9pHbreaVaS/OpN3ycnyvElTdwM5n6GY6W6e2IPemfvGZeUMqZ9A/3GqIZMgKnBhAw/Q== + escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" @@ -2382,6 +2518,19 @@ eslint-config-prettier@^6.11.0: dependencies: get-stdin "^6.0.0" +eslint-formatter-pretty@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/eslint-formatter-pretty/-/eslint-formatter-pretty-4.0.0.tgz#dc15f3bf4fb51b7ba5fbedb77f57ba8841140ce2" + integrity sha512-QgdeZxQwWcN0TcXXNZJiS6BizhAANFhCzkE7Yl9HKB7WjElzwED6+FbbZB2gji8ofgJTGPqKm6VRCNT3OGCeEw== + dependencies: + ansi-escapes "^4.2.1" + chalk "^4.1.0" + eslint-rule-docs "^1.1.5" + log-symbols "^4.0.0" + plur "^4.0.0" + string-width "^4.2.0" + supports-hyperlinks "^2.0.0" + eslint-plugin-prettier@^3.1.2: version "3.1.3" resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.3.tgz#ae116a0fc0e598fdae48743a4430903de5b4e6ca" @@ -2414,6 +2563,11 @@ eslint-plugin-vue@^7.0.0-alpha.1: semver "^5.6.0" vue-eslint-parser "^7.0.0" +eslint-rule-docs@^1.1.5: + version "1.1.200" + resolved "https://registry.yarnpkg.com/eslint-rule-docs/-/eslint-rule-docs-1.1.200.tgz#6de559326ff08f87d319f86daee0b26430150f19" + integrity sha512-3j5+8OVAWepxOZuLijXhqzWFPzD02CqxAP0hnHj1+s6PgTFmSmpaAtwPfv6BZg8NHGxLVS3AD0MIXJIwfn5ypQ== + eslint-scope@^4.0.0: version "4.0.3" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848" @@ -2725,6 +2879,18 @@ fast-glob@^3.0.3: micromatch "^4.0.2" picomatch "^2.2.1" +fast-glob@^3.1.1: + version "3.2.4" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.4.tgz#d20aefbf99579383e7f3cc66529158c9b98554d3" + integrity sha512-kr/Oo6PX51265qeuCYsyGypiO5uJFgBS0jksyG7FUeCyQzNwYnzrNIMR1NXfkZXsMYXYLRAHgISHBz8gQcxKHQ== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.0" + merge2 "^1.3.0" + micromatch "^4.0.2" + picomatch "^2.2.1" + fast-json-stable-stringify@2.x, fast-json-stable-stringify@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" @@ -3034,14 +3200,14 @@ get-stdin@^6.0.0: resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b" integrity sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g== -get-stream@^4.0.0: +get-stream@^4.0.0, get-stream@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w== dependencies: pump "^3.0.0" -get-stream@^5.0.0: +get-stream@^5.0.0, get-stream@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.1.0.tgz#01203cdc92597f9b909067c3e656cc1f4d3c4dc9" integrity sha512-EXr1FOzrzTfGeL0gQdeFEvOMm2mzMOglyiOXSTpPC+iAjAKftbr3jpCMWynogwYnM+eSj9sHGc6wjIcDvYiygw== @@ -3113,6 +3279,13 @@ glob@^7.0.0, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6: once "^1.3.0" path-is-absolute "^1.0.0" +global-dirs@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/global-dirs/-/global-dirs-2.0.1.tgz#acdf3bb6685bcd55cb35e8a052266569e9469201" + integrity sha512-5HqUqdhkEovj2Of/ms3IeS/EekcO54ytHRLV4PEY2rhRwrHXLQjeVEES0Lhka0xwNDtGYn58wyC4s5+MHsOO6A== + dependencies: + ini "^1.3.5" + global-modules@^0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/global-modules/-/global-modules-0.2.3.tgz#ea5a3bed42c6d6ce995a4f8a1269b5dae223828d" @@ -3157,6 +3330,35 @@ globby@^10.0.1: merge2 "^1.2.3" slash "^3.0.0" +globby@^11.0.1: + version "11.0.1" + resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.1.tgz#9a2bf107a068f3ffeabc49ad702c79ede8cfd357" + integrity sha512-iH9RmgwCmUJHi2z5o2l3eTtGBtXek1OYlHrbcxOYugyHLmAsZrPj43OtHThd62Buh/Vv6VyCBD2bdyWcGNQqoQ== + dependencies: + array-union "^2.1.0" + dir-glob "^3.0.1" + fast-glob "^3.1.1" + ignore "^5.1.4" + merge2 "^1.3.0" + slash "^3.0.0" + +got@^9.6.0: + version "9.6.0" + resolved "https://registry.yarnpkg.com/got/-/got-9.6.0.tgz#edf45e7d67f99545705de1f7bbeeeb121765ed85" + integrity sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q== + dependencies: + "@sindresorhus/is" "^0.14.0" + "@szmarczak/http-timer" "^1.1.2" + cacheable-request "^6.0.0" + decompress-response "^3.3.0" + duplexer3 "^0.1.4" + get-stream "^4.1.0" + lowercase-keys "^1.0.1" + mimic-response "^1.0.1" + p-cancelable "^1.0.0" + to-readable-stream "^1.0.0" + url-parse-lax "^3.0.0" + graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.2, graceful-fs@^4.2.4: version "4.2.4" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" @@ -3192,6 +3394,11 @@ har-validator@~5.1.3: ajv "^6.5.5" har-schema "^2.0.0" +hard-rejection@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/hard-rejection/-/hard-rejection-2.1.0.tgz#1c6eda5c1685c63942766d79bb40ae773cecd883" + integrity sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA== + has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" @@ -3238,6 +3445,11 @@ has-values@^1.0.0: is-number "^3.0.0" kind-of "^4.0.0" +has-yarn@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/has-yarn/-/has-yarn-2.1.0.tgz#137e11354a7b5bf11aa5cb649cf0c6f3ff2b2e77" + integrity sha512-UqBRqi4ju7T+TqGNdqAO0PaSVGsDGJUBQvk9eUWNGRY1CFGDzYhLWoM7JQEemnlvVcv/YEmc2wNW8BC24EnUsw== + has@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" @@ -3287,7 +3499,7 @@ html-escaper@^2.0.0: resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== -http-cache-semantics@^4.0.3: +http-cache-semantics@^4.0.0, http-cache-semantics@^4.0.3: version "4.1.0" resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz#49e91c5cbf36c9b94bcfcd71c23d5249ec74e390" integrity sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ== @@ -3376,6 +3588,11 @@ ignore@^5.1.1: resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.4.tgz#84b7b3dbe64552b6ef0eca99f6743dbec6d97adf" integrity sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A== +ignore@^5.1.4: + version "5.1.8" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57" + integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw== + import-fresh@^3.0.0: version "3.2.1" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.2.1.tgz#633ff618506e793af5ac91bf48b72677e15cbe66" @@ -3384,6 +3601,11 @@ import-fresh@^3.0.0: parent-module "^1.0.0" resolve-from "^4.0.0" +import-lazy@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/import-lazy/-/import-lazy-2.1.0.tgz#05698e3d45c88e8d7e9d92cb0584e77f096f3e43" + integrity sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM= + import-local@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.0.2.tgz#a8cfd0431d1de4a2199703d003e3e62364fa6db6" @@ -3432,7 +3654,7 @@ inherits@2, inherits@^2.0.3, inherits@~2.0.3: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== -ini@^1.3.2, ini@^1.3.4: +ini@^1.3.2, ini@^1.3.4, ini@^1.3.5, ini@~1.3.0: version "1.3.5" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== @@ -3471,6 +3693,11 @@ ip@1.1.5: resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a" integrity sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo= +irregular-plurals@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/irregular-plurals/-/irregular-plurals-3.2.0.tgz#b19c490a0723798db51b235d7e39add44dab0822" + integrity sha512-YqTdPLfwP7YFN0SsD3QUVCkm9ZG2VzOXv3DOrw5G5mkMbVwptTwVcFv7/C0vOpBmgTxAeTG19XpUs1E522LW9Q== + is-accessor-descriptor@^0.1.6: version "0.1.6" resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6" @@ -3593,6 +3820,14 @@ is-glob@^4.0.0, is-glob@^4.0.1: dependencies: is-extglob "^2.1.1" +is-installed-globally@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/is-installed-globally/-/is-installed-globally-0.3.2.tgz#fd3efa79ee670d1187233182d5b0a1dd00313141" + integrity sha512-wZ8x1js7Ia0kecP/CHM/3ABkAmujX7WPvQk6uu3Fly/Mk44pySulQpnHG46OMjHGXApINnV4QhY3SWnECO2z5g== + dependencies: + global-dirs "^2.0.1" + is-path-inside "^3.0.1" + is-lambda@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-lambda/-/is-lambda-1.0.1.tgz#3d9877899e6a53efc0160504cde15f82e6f061d5" @@ -3603,6 +3838,11 @@ is-module@^1.0.0: resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591" integrity sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE= +is-npm@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-4.0.0.tgz#c90dd8380696df87a7a6d823c20d0b12bbe3c84d" + integrity sha512-96ECIfh9xtDDlPylNPXhzjsykHsMJZ18ASpaWzQyBr4YRTcVjUvzaHayDAES2oU/3KpljhHUjtSRNiDwi0F0ig== + is-number@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" @@ -3620,6 +3860,16 @@ is-obj@^1.0.0: resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f" integrity sha1-PkcprB9f3gJc19g6iW2rn09n2w8= +is-obj@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-2.0.0.tgz#473fb05d973705e3fd9620545018ca8e22ef4982" + integrity sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w== + +is-path-inside@^3.0.1: + version "3.0.2" + resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.2.tgz#f5220fc82a3e233757291dddc9c5877f2a1f3017" + integrity sha512-/2UGPSgmtqwo1ktx8NDHjuPwZWmHhO+gj0f93EkhLB5RgW9RZevWYYlIkS6zePc6U2WpOdQYIwHe9YC4DWEBVg== + is-plain-obj@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" @@ -3707,6 +3957,11 @@ is-wsl@^2.1.1: resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.1.1.tgz#4a1c152d429df3d441669498e2486d3596ebaf1d" integrity sha512-umZHcSrwlDHo2TGMXv0DZ8dIUGunZ2Iv68YZnrmCiBPkZ4aaOhtv7pXJKeki9k3qJ3RJr0cDyitcl5wEH3AYog== +is-yarn-global@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/is-yarn-global/-/is-yarn-global-0.3.0.tgz#d502d3382590ea3004893746754c89139973e232" + integrity sha512-VjSeb/lHmkoyd8ryPVIKvOCn4D1koMqY+vqyjjUfc3xyKtP4dYOxM44sZrnqQSzSds3xyOrUTLTC9LVCVgLngw== + isarray@1.0.0, isarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" @@ -4272,6 +4527,11 @@ jsesc@^2.5.1: resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== +json-buffer@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.0.tgz#5b1f397afc75d677bde8bcfc0e47e1f9a3d9a898" + integrity sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg= + json-parse-better-errors@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" @@ -4335,6 +4595,13 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" +keyv@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/keyv/-/keyv-3.1.0.tgz#ecc228486f69991e49e9476485a5be1e8fc5c4d9" + integrity sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA== + dependencies: + json-buffer "3.0.0" + kind-of@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-2.0.1.tgz#018ec7a4ce7e3a86cb9141be519d24c8faa981b5" @@ -4361,7 +4628,7 @@ kind-of@^5.0.0: resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d" integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw== -kind-of@^6.0.0, kind-of@^6.0.2: +kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3: version "6.0.3" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== @@ -4371,6 +4638,13 @@ kleur@^3.0.3: resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== +latest-version@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/latest-version/-/latest-version-5.1.0.tgz#119dfe908fe38d15dfa43ecd13fa12ec8832face" + integrity sha512-weT+r0kTkRQdCdYCNtkMwWXQTMEswKrFBkm4ckQOMVhhqhIMI1UT2hMj+1iigIhgSZm5gTmrRXBNoGUgaTY1xA== + dependencies: + package-json "^6.3.0" + lazy-cache@^0.2.3: version "0.2.7" resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-0.2.7.tgz#7feddf2dcb6edb77d11ef1d117ab5ffdf0ab1b65" @@ -4515,6 +4789,13 @@ lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@~4.17 resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== +log-symbols@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.0.0.tgz#69b3cc46d20f448eccdb75ea1fa733d9e821c920" + integrity sha512-FN8JBzLx6CzeMrB0tg6pqlGU1wCrXW+ZXGH481kfsBqer0hToTIiHdjH4Mq8xJUbvATujKCvaREGWpGUionraA== + dependencies: + chalk "^4.0.0" + loud-rejection@^1.0.0: version "1.6.0" resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" @@ -4530,6 +4811,16 @@ lower-case@^2.0.1: dependencies: tslib "^1.10.0" +lowercase-keys@^1.0.0, lowercase-keys@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" + integrity sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA== + +lowercase-keys@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479" + integrity sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA== + lru-cache@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" @@ -4604,6 +4895,11 @@ map-obj@^2.0.0: resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-2.0.0.tgz#a65cd29087a92598b8791257a523e021222ac1f9" integrity sha1-plzSkIepJZi4eRJXpSPgISIqwfk= +map-obj@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-4.1.0.tgz#b91221b542734b9f14256c0132c897c5d7256fd5" + integrity sha512-glc9y00wgtwcDmp7GaE/0b0OnxpNJsVf3ael/An6Fe2Q51LLwN1er6sdomLRzz5h0+yMpiYLhWYF5R7HeqVd4g== + map-visit@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f" @@ -4662,6 +4958,25 @@ meow@^5.0.0: trim-newlines "^2.0.0" yargs-parser "^10.0.0" +meow@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/meow/-/meow-7.0.1.tgz#1ed4a0a50b3844b451369c48362eb0515f04c1dc" + integrity sha512-tBKIQqVrAHqwit0vfuFPY3LlzJYkEOFyKa3bPgxzNl6q/RtN8KQ+ALYEASYuFayzSAsjlhXj/JZ10rH85Q6TUw== + dependencies: + "@types/minimist" "^1.2.0" + arrify "^2.0.1" + camelcase "^6.0.0" + camelcase-keys "^6.2.2" + decamelize-keys "^1.1.0" + hard-rejection "^2.1.0" + minimist-options "^4.0.2" + normalize-package-data "^2.5.0" + read-pkg-up "^7.0.1" + redent "^3.0.0" + trim-newlines "^3.0.0" + type-fest "^0.13.1" + yargs-parser "^18.1.3" + merge-deep@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/merge-deep/-/merge-deep-3.0.2.tgz#f39fa100a4f1bd34ff29f7d2bf4508fbb8d83ad2" @@ -4735,6 +5050,16 @@ mimic-fn@^2.1.0: resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== +mimic-response@^1.0.0, mimic-response@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" + integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== + +min-indent@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/min-indent/-/min-indent-1.0.1.tgz#a63f681673b30571fbe8bc25686ae746eefa9869" + integrity sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg== + minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" @@ -4750,6 +5075,15 @@ minimist-options@^3.0.1: arrify "^1.0.1" is-plain-obj "^1.1.0" +minimist-options@^4.0.2: + version "4.1.0" + resolved "https://registry.yarnpkg.com/minimist-options/-/minimist-options-4.1.0.tgz#c0655713c53a8a2ebd77ffa247d342c40f010619" + integrity sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A== + dependencies: + arrify "^1.0.1" + is-plain-obj "^1.1.0" + kind-of "^6.0.3" + minimist@^1.1.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0, minimist@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" @@ -4973,6 +5307,11 @@ normalize-path@^3.0.0: resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== +normalize-url@^4.1.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.0.tgz#453354087e6ca96957bd8f5baf753f5982142129" + integrity sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ== + npm-run-all@^4.1.5: version "4.1.5" resolved "https://registry.yarnpkg.com/npm-run-all/-/npm-run-all-4.1.5.tgz#04476202a15ee0e2e214080861bff12a51d98fba" @@ -5134,6 +5473,11 @@ os-tmpdir@~1.0.2: resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= +p-cancelable@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-1.1.0.tgz#d078d15a3af409220c886f1d9a0ca2e441ab26cc" + integrity sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw== + p-each-series@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/p-each-series/-/p-each-series-2.1.0.tgz#961c8dd3f195ea96c747e636b262b800a6b1af48" @@ -5196,6 +5540,16 @@ p-try@^2.0.0: resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== +package-json@^6.3.0: + version "6.5.0" + resolved "https://registry.yarnpkg.com/package-json/-/package-json-6.5.0.tgz#6feedaca35e75725876d0b0e64974697fed145b0" + integrity sha512-k3bdm2n25tkyxcjSKzB5x8kfVxlMdgsbPr0GkZcwHsLpba6cBjqCt1KlcChKEvxHIcTB1FVMuwoijZ26xex5MQ== + dependencies: + got "^9.6.0" + registry-auth-token "^4.0.0" + registry-url "^5.0.0" + semver "^6.2.0" + param-case@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/param-case/-/param-case-3.0.3.tgz#4be41f8399eff621c56eebb829a5e451d9801238" @@ -5398,6 +5752,13 @@ pkg-dir@^4.1.0, pkg-dir@^4.2.0: dependencies: find-up "^4.0.0" +plur@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/plur/-/plur-4.0.0.tgz#729aedb08f452645fe8c58ef115bf16b0a73ef84" + integrity sha512-4UGewrYgqDFw9vV6zNV+ADmPAUAfJPKtGvb/VdpQAx25X5f3xXdGdyOEVFwkl8Hl/tl7+xbeHqSEM+D5/TirUg== + dependencies: + irregular-plurals "^3.2.0" + portfinder@^1.0.25: version "1.0.26" resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.26.tgz#475658d56ca30bed72ac7f1378ed350bd1b64e70" @@ -5422,6 +5783,11 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= +prepend-http@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" + integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= + prettier-linter-helpers@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" @@ -5508,6 +5874,13 @@ punycode@^2.1.0, punycode@^2.1.1: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== +pupa@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pupa/-/pupa-2.0.1.tgz#dbdc9ff48ffbea4a26a069b6f9f7abb051008726" + integrity sha512-hEJH0s8PXLY/cdXh66tNEQGndDrIKNqNC5xmrysZy3i5C3oEoLna7YAOad+7u125+zH1HNXUmGEkrhb3c2VriA== + dependencies: + escape-goat "^2.0.0" + puppeteer@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-2.1.1.tgz#ccde47c2a688f131883b50f2d697bd25189da27e" @@ -5544,6 +5917,21 @@ quick-lru@^1.0.0: resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-1.1.0.tgz#4360b17c61136ad38078397ff11416e186dcfbb8" integrity sha1-Q2CxfGETatOAeDl/8RQW4Ybc+7g= +quick-lru@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-4.0.1.tgz#5b8878f113a58217848c6482026c73e1ba57727f" + integrity sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g== + +rc@^1.2.8: + version "1.2.8" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" + integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== + dependencies: + deep-extend "^0.6.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~2.0.1" + react-is@^16.12.0: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" @@ -5647,6 +6035,14 @@ redent@^2.0.0: indent-string "^3.0.0" strip-indent "^2.0.0" +redent@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-3.0.0.tgz#e557b7998316bb53c9f1f56fa626352c6963059f" + integrity sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg== + dependencies: + indent-string "^4.0.0" + strip-indent "^3.0.0" + regenerator-runtime@^0.13.4: version "0.13.5" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz#d878a1d094b4306d10b9096484b33ebd55e26697" @@ -5665,6 +6061,20 @@ regexpp@^3.0.0, regexpp@^3.1.0: resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.1.0.tgz#206d0ad0a5648cffbdb8ae46438f3dc51c9f78e2" integrity sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q== +registry-auth-token@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-4.2.0.tgz#1d37dffda72bbecd0f581e4715540213a65eb7da" + integrity sha512-P+lWzPrsgfN+UEpDS3U8AQKg/UjZX6mQSJueZj3EK+vNESoqBSpBUD3gmu4sF9lOsjXWjF11dQKUqemf3veq1w== + dependencies: + rc "^1.2.8" + +registry-url@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/registry-url/-/registry-url-5.1.0.tgz#e98334b50d5434b81136b44ec638d9c2009c5009" + integrity sha512-8acYXXTI0AkQv6RAOjE3vOaIXZkT9wo4LOFbBKYQEEnnMNBpKqdUrI6S4NT0KPIo/WVvJ5tE/X5LF/TQUf0ekw== + dependencies: + rc "^1.2.8" + remove-trailing-separator@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" @@ -5795,6 +6205,13 @@ resolve@^1.1.6, resolve@^1.10.0, resolve@^1.11.0, resolve@^1.12.0, resolve@^1.14 dependencies: path-parse "^1.0.6" +responselike@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/responselike/-/responselike-1.0.2.tgz#918720ef3b631c5642be068f15ade5a46f4ba1e7" + integrity sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec= + dependencies: + lowercase-keys "^1.0.0" + restore-cursor@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e" @@ -5950,12 +6367,19 @@ secure-compare@3.0.1: resolved "https://registry.yarnpkg.com/secure-compare/-/secure-compare-3.0.1.tgz#f1a0329b308b221fae37b9974f3d578d0ca999e3" integrity sha1-8aAymzCLIh+uN7mXTz1XjQypmeM= +semver-diff@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-3.1.1.tgz#05f77ce59f325e00e2706afd67bb506ddb1ca32b" + integrity sha512-GX0Ix/CJcHyB8c4ykpHGIAvLyOwOobtM/8d+TQkAd81/bEjgPHrfba41Vpesr7jX/t8Uh+R3EX9eAS5be+jQYg== + dependencies: + semver "^6.3.0" + "semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.6.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -semver@6.3.0, semver@^6.0.0, semver@^6.3.0: +semver@6.3.0, semver@^6.0.0, semver@^6.2.0, semver@^6.3.0: version "6.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== @@ -6347,7 +6771,7 @@ string-width@^3.0.0, string-width@^3.1.0: is-fullwidth-code-point "^2.0.0" strip-ansi "^5.1.0" -string-width@^4.1.0, string-width@^4.2.0: +string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5" integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg== @@ -6465,11 +6889,23 @@ strip-indent@^2.0.0: resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-2.0.0.tgz#5ef8db295d01e6ed6cbf7aab96998d7822527b68" integrity sha1-XvjbKV0B5u1sv3qrlpmNeCJSe2g= +strip-indent@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-3.0.0.tgz#c32e1cee940b6b3432c771bc2c54bcce73cd3001" + integrity sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ== + dependencies: + min-indent "^1.0.0" + strip-json-comments@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.0.tgz#7638d31422129ecf4457440009fba03f9f9ac180" integrity sha512-e6/d0eBu7gHtdCqFt0xJr642LdToM5/cN4Qb9DbHjVx1CP5RyeM+zH7pbecEmDv/lBqb0QH+6Uqq75rxFPkM0w== +strip-json-comments@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" + integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= + supports-color@^5.3.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" @@ -6548,6 +6984,11 @@ tempfile@^3.0.0: temp-dir "^2.0.0" uuid "^3.3.2" +term-size@^2.1.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/term-size/-/term-size-2.2.0.tgz#1f16adedfe9bdc18800e1776821734086fcc6753" + integrity sha512-a6sumDlzyHVJWb8+YofY4TW112G6p2FCPEAFk+59gIYHv3XHRhm9ltVQ9kli4hNWeQBwSpe8cRN25x0ROunMOw== + terminal-link@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/terminal-link/-/terminal-link-2.1.1.tgz#14a64a27ab3c0df933ea546fba55f2d078edc994" @@ -6652,6 +7093,11 @@ to-object-path@^0.3.0: dependencies: kind-of "^3.0.2" +to-readable-stream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/to-readable-stream/-/to-readable-stream-1.0.0.tgz#ce0aa0c2f3df6adf852efb404a783e77c0475771" + integrity sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q== + to-regex-range@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38" @@ -6716,6 +7162,11 @@ trim-newlines@^2.0.0: resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-2.0.0.tgz#b403d0b91be50c331dfc4b82eeceb22c3de16d20" integrity sha1-tAPQuRvlDDMd/EuC7s6yLD3hbSA= +trim-newlines@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-3.0.0.tgz#79726304a6a898aa8373427298d54c2ee8b1cb30" + integrity sha512-C4+gOpvmxaSMKuEf9Qc134F1ZuOHVXKRbtEflf4NTtuuJDEIJ9p5PXsalL8SkeRw+qit1Mo+yuvMPAKwWg/1hA== + trim-off-newlines@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/trim-off-newlines/-/trim-off-newlines-1.0.1.tgz#9f9ba9d9efa8764c387698bcbfeb2c848f11adb3" @@ -6737,6 +7188,18 @@ ts-jest@^26.0.0: semver "7.x" yargs-parser "18.x" +tsd@^0.13.1: + version "0.13.1" + resolved "https://registry.yarnpkg.com/tsd/-/tsd-0.13.1.tgz#d2a8baa80b8319dafea37fbeb29fef3cec86e92b" + integrity sha512-+UYM8LRG/M4H8ISTg2ow8SWi65PS7Os+4DUnyiQLbJysXBp2DEmws9SMgBH+m8zHcJZqUJQ+mtDWJXP1IAvB2A== + dependencies: + eslint-formatter-pretty "^4.0.0" + globby "^11.0.1" + meow "^7.0.1" + path-exists "^4.0.0" + read-pkg-up "^7.0.0" + update-notifier "^4.1.0" + tslib@1.11.1, tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0: version "1.11.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35" @@ -6785,6 +7248,11 @@ type-fest@^0.11.0: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.11.0.tgz#97abf0872310fed88a5c466b25681576145e33f1" integrity sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ== +type-fest@^0.13.1: + version "0.13.1" + resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.13.1.tgz#0172cb5bce80b0bd542ea348db50c7e21834d934" + integrity sha512-34R7HTnG0XIJcBSn5XhDd7nNFPRcXYRZrBB2O2jdKqYODldSzBAqzsWoZYYvduky73toYS/ESqxPvkDf/F0XMg== + type-fest@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.6.0.tgz#8d2a2370d3df886eb5c90ada1c5bf6188acf838b" @@ -6862,6 +7330,13 @@ unique-slug@^2.0.0: dependencies: imurmurhash "^0.1.4" +unique-string@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/unique-string/-/unique-string-2.0.0.tgz#39c6451f81afb2749de2b233e3f7c5e8843bd89d" + integrity sha512-uNaeirEPvpZWSgzwsPGtU2zVSTrn/8L5q/IexZmH0eH6SA73CmAA5U4GwORTxQAZs95TAXLNqeLoPPNO5gZfWg== + dependencies: + crypto-random-string "^2.0.0" + universal-user-agent@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-4.0.1.tgz#fd8d6cb773a679a709e967ef8288a31fcc03e557" @@ -6894,6 +7369,25 @@ unset-value@^1.0.0: has-value "^0.3.1" isobject "^3.0.0" +update-notifier@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/update-notifier/-/update-notifier-4.1.0.tgz#4866b98c3bc5b5473c020b1250583628f9a328f3" + integrity sha512-w3doE1qtI0/ZmgeoDoARmI5fjDoT93IfKgEGqm26dGUOh8oNpaSTsGNdYRN/SjOuo10jcJGwkEL3mroKzktkew== + dependencies: + boxen "^4.2.0" + chalk "^3.0.0" + configstore "^5.0.1" + has-yarn "^2.1.0" + import-lazy "^2.1.0" + is-ci "^2.0.0" + is-installed-globally "^0.3.1" + is-npm "^4.0.0" + is-yarn-global "^0.3.0" + latest-version "^5.0.0" + pupa "^2.0.1" + semver-diff "^3.1.1" + xdg-basedir "^4.0.0" + upper-case-first@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/upper-case-first/-/upper-case-first-2.0.1.tgz#32ab436747d891cc20ab1e43d601cb4d0a7fbf4a" @@ -6925,6 +7419,13 @@ url-join@^2.0.5: resolved "https://registry.yarnpkg.com/url-join/-/url-join-2.0.5.tgz#5af22f18c052a000a48d7b82c5e9c2e2feeda728" integrity sha1-WvIvGMBSoACkjXuCxenC4v7tpyg= +url-parse-lax@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-3.0.0.tgz#16b5cafc07dbe3676c1b1999177823d6503acb0c" + integrity sha1-FrXK/Afb42dsGxmZF3gj1lA6yww= + dependencies: + prepend-http "^2.0.0" + use@^3.1.0: version "3.1.1" resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" @@ -7105,6 +7606,13 @@ which@^2.0.1, which@^2.0.2: dependencies: isexe "^2.0.0" +widest-line@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/widest-line/-/widest-line-3.1.0.tgz#8292333bbf66cb45ff0de1603b136b7ae1496eca" + integrity sha512-NsmoXalsWVDMGupxZ5R08ka9flZjjiLvHVAWYOKtiKM8ujtZWr9cRffak+uSE48+Ob8ObalXpwyeUiyDD6QFgg== + dependencies: + string-width "^4.0.0" + windows-iana@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/windows-iana/-/windows-iana-3.1.0.tgz#156b1d7faef085068383827ac2884f1656cff217" @@ -7179,6 +7687,11 @@ ws@^7.2.3: resolved "https://registry.yarnpkg.com/ws/-/ws-7.2.5.tgz#abb1370d4626a5a9cd79d8de404aa18b3465d10d" integrity sha512-C34cIU4+DB2vMyAbmEKossWq2ZQDr6QEyuuCzWrM9zfw1sGc0mYiJ0UnG9zzNykt49C2Fi34hvr2vssFQRS6EA== +xdg-basedir@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-4.0.0.tgz#4bc8d9984403696225ef83a1573cbbcb4e79db13" + integrity sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q== + xml-name-validator@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" @@ -7209,7 +7722,7 @@ yallist@^4.0.0: resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== -yargs-parser@18.x, yargs-parser@^18.1.1: +yargs-parser@18.x, yargs-parser@^18.1.1, yargs-parser@^18.1.3: version "18.1.3" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0" integrity sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ== From 613753370f9f082c3a154b7a977195b72c6d0a2f Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Sun, 26 Jul 2020 01:34:29 +0900 Subject: [PATCH 06/20] updates --- src/composer.ts | 1 - src/core/context.ts | 81 +++++++++++++++++++++------------------- src/message/generator.ts | 1 + src/message/runtime.ts | 14 +++---- 4 files changed, 51 insertions(+), 46 deletions(-) diff --git a/src/composer.ts b/src/composer.ts index cf6567fd0..62c24a51a 100644 --- a/src/composer.ts +++ b/src/composer.ts @@ -537,7 +537,6 @@ export function createComposer( } const interpolate = (val: unknown): unknown => val const processor = { - type: 'vnode', normalize, interpolate } as MessageProcessor diff --git a/src/core/context.ts b/src/core/context.ts index 32595fb2c..218b02af7 100644 --- a/src/core/context.ts +++ b/src/core/context.ts @@ -1,11 +1,11 @@ -import { MessageFunction } from '../message/runtime' import { CompileOptions } from '../message/options' import { compile } from '../message/compiler' import { LinkedModifiers, PluralizationRules, MessageProcessor, - DEFAULT_MESSAGE_DATA_TYPE + MessageFunction, + MessageType } from '../message/runtime' import { CoreWarnCodes, getWarnMessage } from './warnings' import { Path } from '../path' @@ -40,59 +40,62 @@ export type LocaleMessage = | LocaleMessage[] export type LocaleMessages = Record -export type RuntimeMissingHandler = ( - context: RuntimeContext, +export type RuntimeMissingType = 'translate' | 'datetime' | 'number' +export type RuntimeMissingHandler = ( + context: RuntimeContext, locale: Locale, key: Path, - type: string, + type: RuntimeMissingType, ...values: unknown[] ) => string | void -export type PostTranslationHandler = (translated: unknown) => unknown +export type PostTranslationHandler = ( + translated: MessageType +) => MessageType -export type MessageCompiler = ( +export type MessageCompiler = ( source: string, options?: CompileOptions -) => MessageFunction +) => MessageFunction -export interface RuntimeOptions { +export interface RuntimeOptions { locale?: Locale fallbackLocale?: FallbackLocale messages?: LocaleMessages datetimeFormats?: DateTimeFormats numberFormats?: NumberFormats - modifiers?: LinkedModifiers + modifiers?: LinkedModifiers pluralRules?: PluralizationRules - missing?: RuntimeMissingHandler + missing?: RuntimeMissingHandler missingWarn?: boolean | RegExp fallbackWarn?: boolean | RegExp fallbackFormat?: boolean unresolving?: boolean - postTranslation?: PostTranslationHandler - processor?: MessageProcessor + postTranslation?: PostTranslationHandler + processor?: MessageProcessor warnHtmlMessage?: boolean - messageCompiler?: MessageCompiler + messageCompiler?: MessageCompiler onWarn?: (msg: string, err?: Error) => void _datetimeFormatters?: Map _numberFormatters?: Map } -export interface RuntimeContext { +export interface RuntimeContext { locale: Locale fallbackLocale: FallbackLocale messages: LocaleMessages datetimeFormats: DateTimeFormats numberFormats: NumberFormats - modifiers: LinkedModifiers + modifiers: LinkedModifiers pluralRules?: PluralizationRules - missing: RuntimeMissingHandler | null + missing: RuntimeMissingHandler | null missingWarn: boolean | RegExp fallbackWarn: boolean | RegExp fallbackFormat: boolean unresolving: boolean - postTranslation: PostTranslationHandler | null - processor: MessageProcessor | null + postTranslation: PostTranslationHandler | null + processor: MessageProcessor | null warnHtmlMessage: boolean - messageCompiler: MessageCompiler + messageCompiler: MessageCompiler onWarn(msg: string, err?: Error): void _datetimeFormatters: Map _numberFormatters: Map @@ -100,24 +103,26 @@ export interface RuntimeContext { _localeChainCache?: Map } -const DEFAULT_LINKDED_MODIFIERS: LinkedModifiers = { - upper: (val: unknown, type: string): unknown => - type === DEFAULT_MESSAGE_DATA_TYPE ? (val as string).toUpperCase() : val, - lower: (val: unknown, type: string): unknown => - type === DEFAULT_MESSAGE_DATA_TYPE ? (val as string).toLowerCase() : val, - // prettier-ignore - capitalize: (val: unknown, type: string): unknown => - type === DEFAULT_MESSAGE_DATA_TYPE - ? `${(val as string).charAt(0).toLocaleUpperCase()}${(val as string).substr(1)}` - : val -} - export const NOT_REOSLVED = -1 export const MISSING_RESOLVE_VALUE = '' -export function createRuntimeContext( - options: RuntimeOptions = {} -): RuntimeContext { +function getDefaultLinkedModifiers(): LinkedModifiers { + return { + upper: (val: T): MessageType => + (isString(val) ? val.toUpperCase() : val) as MessageType, + lower: (val: T): MessageType => + (isString(val) ? val.toLowerCase() : val) as MessageType, + // prettier-ignore + capitalize: (val: T): MessageType => + (isString(val) + ? `${val.charAt(0).toLocaleUpperCase()}${val.substr(1)}` + : val) as MessageType + } +} + +export function createRuntimeContext( + options: RuntimeOptions = {} +): RuntimeContext { const locale = isString(options.locale) ? options.locale : 'en-US' const fallbackLocale = isArray(options.fallbackLocale) || @@ -138,7 +143,7 @@ export function createRuntimeContext( const modifiers = Object.assign( {} as LinkedModifiers, options.modifiers || {}, - DEFAULT_LINKDED_MODIFIERS + getDefaultLinkedModifiers() ) const pluralRules = options.pluralRules || {} const missing = isFunction(options.missing) ? options.missing : null @@ -195,7 +200,7 @@ export function createRuntimeContext( export function isTrarnslateFallbackWarn( fallback: boolean | RegExp, - key: string + key: Path ): boolean { return fallback instanceof RegExp ? fallback.test(key) : fallback } @@ -212,7 +217,7 @@ export function handleMissing( key: Path, locale: Locale, missingWarn: boolean | RegExp, - type: string + type: RuntimeMissingType ): unknown { const { missing, onWarn } = context if (missing !== null) { diff --git a/src/message/generator.ts b/src/message/generator.ts index 1d8db8e1a..e0327497f 100644 --- a/src/message/generator.ts +++ b/src/message/generator.ts @@ -91,6 +91,7 @@ function generateLinkedNode(generator: CodeGenerator, node: LinkedNode): void { generateNode(generator, node.key) generator.push(')(ctx)') if (node.modifier) { + // TODO: should be refactorerd! (remove TYPE!) generator.push(`, ${helper(HelperNameMap.TYPE)})`) } } diff --git a/src/message/runtime.ts b/src/message/runtime.ts index 23796a9e6..76a5abe40 100644 --- a/src/message/runtime.ts +++ b/src/message/runtime.ts @@ -58,14 +58,12 @@ export type PluralizationProps = { count?: number } -export type LinkedModify = ( - value: T, - type?: string -) => MessageType +export type LinkedModify = (value: T) => MessageType export type LinkedModifiers = { [key: string]: LinkedModify } export type NamedValue = T & Record +// TODO: list and named type definition more improvements export interface MessageContextOptions { parent?: MessageContext locale?: string @@ -86,11 +84,12 @@ export const enum HelperNameMap { ORG_PLURAL_RULE = 'orgPluralRule', MODIFIER = 'modifier', MESSAGE = 'message', - TYPE = 'type', + TYPE = 'type', // TODO: should be removed! INTERPOLATE = 'interpolate', NORMALIZE = 'normalize' } +// TODO: list and named type definition more improvements export interface MessageContext { list(index: number): unknown named(key: string): unknown @@ -99,7 +98,7 @@ export interface MessageContext { orgPluralRule?: PluralizationRule modifier(name: string): LinkedModify message(name: string): MessageFunction - type: string + type?: string // TODO: should be removed! interpolate: MessageInterpolate normalize: MessageNormalize } @@ -195,6 +194,7 @@ export function createMessageContext( : msg } + // TODO: should be removed! const type = isPlainObject(options.processor) && isString(options.processor.type) ? options.processor.type @@ -219,7 +219,7 @@ export function createMessageContext( [HelperNameMap.ORG_PLURAL_RULE]: orgPluralRule, [HelperNameMap.MODIFIER]: modifier, [HelperNameMap.MESSAGE]: message, - [HelperNameMap.TYPE]: type, + [HelperNameMap.TYPE]: type, // TODO: should be removed! [HelperNameMap.INTERPOLATE]: interpolate, [HelperNameMap.NORMALIZE]: normalize } From 4d35f698f2ba4374dec50153b8ee9b356d688b5e Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Sun, 26 Jul 2020 01:40:37 +0900 Subject: [PATCH 07/20] fix type errors --- src/core/translate.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/translate.ts b/src/core/translate.ts index f741bd285..4791226b5 100644 --- a/src/core/translate.ts +++ b/src/core/translate.ts @@ -5,6 +5,7 @@ import { createMessageContext, NamedValue, MessageFunction, + MessageFunctionInternal, MessageContextOptions } from '../message/runtime' import { @@ -259,12 +260,12 @@ export function translate( warnHtmlMessage, errorDetector ) - ) + ) as MessageFunctionInternal msg.locale = targetLocale msg.key = key msg.source = format } else { - msg = format + msg = format as MessageFunctionInternal msg.locale = msg.locale || targetLocale msg.key = msg.key || key } From 17d9fa43647d9ab07f34f40dbbdd62f15b93c8c6 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Sun, 26 Jul 2020 02:15:52 +0900 Subject: [PATCH 08/20] update core modules --- src/core/context.ts | 8 +-- src/core/datetime.ts | 24 ++++----- src/core/number.ts | 24 ++++----- src/core/translate.ts | 121 ++++++++++++++++++++++-------------------- 4 files changed, 92 insertions(+), 85 deletions(-) diff --git a/src/core/context.ts b/src/core/context.ts index 218b02af7..2830e356b 100644 --- a/src/core/context.ts +++ b/src/core/context.ts @@ -212,8 +212,8 @@ export function isTranslateMissingWarn( return missing instanceof RegExp ? missing.test(key) : missing } -export function handleMissing( - context: RuntimeContext, +export function handleMissing( + context: RuntimeContext, key: Path, locale: Locale, missingWarn: boolean | RegExp, @@ -231,8 +231,8 @@ export function handleMissing( } } -export function getLocaleChain( - context: RuntimeContext, +export function getLocaleChain( + context: RuntimeContext, fallback: FallbackLocale, start: Locale = '' ): Locale[] { diff --git a/src/core/datetime.ts b/src/core/datetime.ts index 3e1525f9d..f42d3cab3 100644 --- a/src/core/datetime.ts +++ b/src/core/datetime.ts @@ -68,34 +68,34 @@ export type DateTimeOptions = { } // `datetime` function overloads -export function datetime( - context: RuntimeContext, +export function datetime( + context: RuntimeContext, value: number | Date ): string | number | Intl.DateTimeFormatPart[] -export function datetime( - context: RuntimeContext, +export function datetime( + context: RuntimeContext, value: number | Date, key: string ): string | number | Intl.DateTimeFormatPart[] -export function datetime( - context: RuntimeContext, +export function datetime( + context: RuntimeContext, value: number | Date, key: string, locale: Locale ): string | number | Intl.DateTimeFormatPart[] -export function datetime( - context: RuntimeContext, +export function datetime( + context: RuntimeContext, value: number | Date, options: DateTimeOptions ): string | number | Intl.DateTimeFormatPart[] -export function datetime( - context: RuntimeContext, +export function datetime( + context: RuntimeContext, ...args: unknown[] ): string | number | Intl.DateTimeFormatPart[] // for internal // implementation of `datetime` function -export function datetime( - context: RuntimeContext, +export function datetime( + context: RuntimeContext, ...args: unknown[] ): string | number | Intl.DateTimeFormatPart[] { const { diff --git a/src/core/number.ts b/src/core/number.ts index db6765bca..c8cad9fcc 100644 --- a/src/core/number.ts +++ b/src/core/number.ts @@ -66,34 +66,34 @@ export type NumberOptions = { } // `number` function overloads -export function number( - context: RuntimeContext, +export function number( + context: RuntimeContext, value: number ): string | number | Intl.NumberFormatPart[] -export function number( - context: RuntimeContext, +export function number( + context: RuntimeContext, value: number, key: string ): string | number | Intl.NumberFormatPart[] -export function number( - context: RuntimeContext, +export function number( + context: RuntimeContext, value: number, key: string, locale: Locale ): string | number | Intl.NumberFormatPart[] -export function number( - context: RuntimeContext, +export function number( + context: RuntimeContext, value: number, options: NumberOptions ): string | number | Intl.NumberFormatPart[] -export function number( - context: RuntimeContext, +export function number( + context: RuntimeContext, ...args: unknown[] ): string | number | Intl.NumberFormatPart[] // for internal // implementation of `number` function -export function number( - context: RuntimeContext, +export function number( + context: RuntimeContext, ...args: unknown[] ): string | number | Intl.NumberFormatPart[] { const { diff --git a/src/core/translate.ts b/src/core/translate.ts index 4791226b5..d507a00d9 100644 --- a/src/core/translate.ts +++ b/src/core/translate.ts @@ -6,7 +6,8 @@ import { NamedValue, MessageFunction, MessageFunctionInternal, - MessageContextOptions + MessageContextOptions, + MessageType } from '../message/runtime' import { Locale, @@ -32,7 +33,7 @@ import { } from '../utils' const NOOP_MESSAGE_FUNCTION = () => '' -const isMessageFunction = (val: unknown): val is MessageFunction => +const isMessageFunction = (val: unknown): val is MessageFunction => isFunction(val) /** @@ -87,82 +88,88 @@ export type TranslateOptions = { } // `translate` function overloads -export function translate(context: RuntimeContext, key: Path): unknown -export function translate( - context: RuntimeContext, +export function translate( + context: RuntimeContext, + key: Path +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, plural: number -): unknown -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, plural: number, options: TranslateOptions -): unknown -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, defaultMsg: string -): unknown -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, defaultMsg: string, options: TranslateOptions -): unknown -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, list: unknown[] -): unknown -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, list: unknown[], plural: number -): unknown -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, list: unknown[], defaultMsg: string -): unknown -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, list: unknown[], options: TranslateOptions -): unknown -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, named: NamedValue -): unknown -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, named: NamedValue, plural: number -): unknown -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, named: NamedValue, defaultMsg: string -): unknown -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, named: NamedValue, options: TranslateOptions -): unknown -export function translate(context: RuntimeContext, ...args: unknown[]): unknown // for internal +): MessageType | number +export function translate( + context: RuntimeContext, + ...args: unknown[] +): MessageType | number // for internal // implementationo of `translate` function -export function translate( - context: RuntimeContext, +export function translate( + context: RuntimeContext, ...args: unknown[] -): unknown { +): MessageType | number { const { messages, fallbackFormat, @@ -227,7 +234,7 @@ export function translate( let cacheBaseKey = key // if you use default message, set it as message format! - if (!(isString(format) || isMessageFunction(format))) { + if (!(isString(format) || isMessageFunction(format))) { if (enableDefaultMsg) { format = defaultMsgOrKey cacheBaseKey = format @@ -236,10 +243,10 @@ export function translate( // checking message format and target locale if ( - !(isString(format) || isMessageFunction(format)) || + !(isString(format) || isMessageFunction(format)) || !isString(targetLocale) ) { - return unresolving ? NOT_REOSLVED : key + return unresolving ? NOT_REOSLVED : (key as MessageType) } // setup compile error detecting @@ -250,7 +257,7 @@ export function translate( // compile message format let msg - if (!isMessageFunction(format)) { + if (!isMessageFunction(format)) { msg = messageCompiler( format, getCompileOptions( @@ -272,7 +279,7 @@ export function translate( // if occured compile error, return the message format if (occured) { - return format + return format as MessageType } // evaluate message with context @@ -283,7 +290,7 @@ export function translate( options ) const msgContext = createMessageContext(ctxOptions) - const messaged = msg(msgContext) + const messaged = (msg as MessageFunction)(msgContext) // if use post translation option, procee it with handler return postTranslation ? postTranslation(messaged) : messaged @@ -351,15 +358,15 @@ function getCompileOptions( } as CompileOptions } -function getMessageContextOptions( - context: RuntimeContext, +function getMessageContextOptions( + context: RuntimeContext, locale: Locale, message: LocaleMessage, options: TranslateOptions -): MessageContextOptions { +): MessageContextOptions { const { modifiers, pluralRules, messageCompiler } = context - const resolveMessage = (key: string): MessageFunction => { + const resolveMessage = (key: string): MessageFunction => { const val = resolveValue(message, key) if (isString(val)) { let occured = false @@ -376,16 +383,16 @@ function getMessageContextOptions( errorDetector ) ) - return !occured ? msg : NOOP_MESSAGE_FUNCTION - } else if (isMessageFunction(val)) { + return !occured ? msg : (NOOP_MESSAGE_FUNCTION as MessageFunction) + } else if (isMessageFunction(val)) { return val } else { // TODO: should be implemented warning message - return NOOP_MESSAGE_FUNCTION + return NOOP_MESSAGE_FUNCTION as MessageFunction } } - const ctxOptions: MessageContextOptions = { + const ctxOptions: MessageContextOptions = { locale, modifiers, pluralRules, From 7247e512e59f07f9faf3e48f9bfd379676f8818a Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Mon, 27 Jul 2020 01:19:36 +0900 Subject: [PATCH 09/20] update composer type definitions --- src/components/Translation.ts | 7 +- src/composer.ts | 151 ++++++++++-------- src/core/context.ts | 11 +- src/core/datetime.ts | 4 +- src/core/number.ts | 4 +- test/__snapshots__/composer.test.ts.snap | 30 ++++ test/composer.test.ts | 2 +- .../__snapshots__/runtime.test.ts.snap | 4 +- test/message/runtime.test.ts | 8 +- 9 files changed, 133 insertions(+), 88 deletions(-) create mode 100644 test/__snapshots__/composer.test.ts.snap diff --git a/src/components/Translation.ts b/src/components/Translation.ts index a97ad7538..811c06c7d 100644 --- a/src/components/Translation.ts +++ b/src/components/Translation.ts @@ -49,12 +49,7 @@ export const Translation = defineComponent({ options.plural = isString(props.plural) ? +props.plural : props.plural } const arg = getInterpolateArg(context, keys) - - const children = i18n.__transrateVNode( - props.keypath, - arg, - options - ) as VNodeArrayChildren + const children = i18n.__transrateVNode(props.keypath, arg, options) return props.tag ? h(props.tag, { ...attrs }, children) : h(Fragment, { ...attrs }, children) diff --git a/src/composer.ts b/src/composer.ts index 62c24a51a..693e405d6 100644 --- a/src/composer.ts +++ b/src/composer.ts @@ -12,7 +12,9 @@ import { ComponentInternalInstance, Text, createVNode, - watch + watch, + VNode, + VNodeArrayChildren } from 'vue' import { WritableComputedRef, ComputedRef } from '@vue/reactivity' import { Path, parse as parsePath } from './path' @@ -27,7 +29,8 @@ import { PluralizationRules, NamedValue, MessageFunctions, - MessageProcessor + MessageProcessor, + MessageType } from './message/runtime' import { Locale, @@ -72,6 +75,14 @@ import { isPlainObject } from './utils' +// extend VNode interface +declare module '@vue/runtime-core' { + interface VNode { + toString: () => string // mark for vue-i18n message runtime + } +} + +export type VueMessageType = string | VNode export type MissingHandler = ( locale: Locale, key: Path, @@ -79,12 +90,14 @@ export type MissingHandler = ( type?: string ) => string | void -export type PreCompileHandler = () => { +export type PreCompileHandler = () => { messages: LocaleMessages - functions: MessageFunctions + functions: MessageFunctions } -export type CustomBlocks = Array | PreCompileHandler +export type CustomBlocks = + | Array + | PreCompileHandler /** * Composer Options @@ -92,30 +105,30 @@ export type CustomBlocks = Array | PreCompileHandler * @remarks * This is options to create composer. */ -export interface ComposerOptions { +export interface ComposerOptions { locale?: Locale fallbackLocale?: FallbackLocale inheritLocale?: boolean messages?: LocaleMessages datetimeFormats?: DateTimeFormats numberFormats?: NumberFormats - modifiers?: LinkedModifiers + modifiers?: LinkedModifiers pluralRules?: PluralizationRules missing?: MissingHandler missingWarn?: boolean | RegExp fallbackWarn?: boolean | RegExp fallbackRoot?: boolean fallbackFormat?: boolean - postTranslation?: PostTranslationHandler + postTranslation?: PostTranslationHandler warnHtmlMessage?: boolean } /** * @internal */ -export interface ComposerInternalOptions { - __i18n?: CustomBlocks - __root?: Composer +export interface ComposerInternalOptions { + __i18n?: CustomBlocks + __root?: Composer } /** @@ -124,7 +137,7 @@ export interface ComposerInternalOptions { * @remarks * This is the interface for being used for Vue 3 Composition API. */ -export interface Composer { +export interface Composer { // properties locale: WritableComputedRef fallbackLocale: WritableComputedRef @@ -133,7 +146,7 @@ export interface Composer { readonly messages: ComputedRef readonly datetimeFormats: ComputedRef readonly numberFormats: ComputedRef - readonly modifiers: LinkedModifiers + readonly modifiers: LinkedModifiers readonly pluralRules?: PluralizationRules readonly isGlobal: boolean missingWarn: boolean | RegExp @@ -175,8 +188,8 @@ export interface Composer { getNumberFormat(locale: Locale): NumberFormat setNumberFormat(locale: Locale, format: NumberFormat): void mergeNumberFormat(locale: Locale, format: NumberFormat): void - getPostTranslationHandler(): PostTranslationHandler | null - setPostTranslationHandler(handler: PostTranslationHandler | null): void + getPostTranslationHandler(): PostTranslationHandler | null + setPostTranslationHandler(handler: PostTranslationHandler | null): void getMissingHandler(): MissingHandler | null setMissingHandler(handler: MissingHandler | null): void } @@ -186,18 +199,20 @@ export interface Composer { */ export interface ComposerInternal { __id: number - __transrateVNode(...args: unknown[]): unknown + __transrateVNode(...args: unknown[]): VNodeArrayChildren __numberParts(...args: unknown[]): string | Intl.NumberFormatPart[] __datetimeParts(...args: unknown[]): string | Intl.DateTimeFormatPart[] } +type ComposerWarnType = 'translate' | 'number format' | 'datetime format' + let composerID = 0 -function defineRuntimeMissingHandler( +function defineRuntimeMissingHandler( missing: MissingHandler -): RuntimeMissingHandler { +): RuntimeMissingHandler { return ( - ctx: RuntimeContext, + ctx: RuntimeContext, locale: Locale, key: Path, type: string @@ -206,8 +221,8 @@ function defineRuntimeMissingHandler( } } -function getLocaleMessages( - options: ComposerOptions & ComposerInternalOptions, +function getLocaleMessages( + options: ComposerOptions & ComposerInternalOptions, locale: Locale ): LocaleMessages { const { messages, __i18n } = options @@ -229,15 +244,15 @@ function getLocaleMessages( if (isFunction(__i18n)) { const { functions } = __i18n() - addPreCompileMessages(ret, functions) + addPreCompileMessages(ret, functions as MessageFunctions) } return ret } -export function addPreCompileMessages( +export function addPreCompileMessages( messages: LocaleMessages, - functions: MessageFunctions + functions: MessageFunctions ): void { const keys = Object.keys(functions) keys.forEach(key => { @@ -275,9 +290,9 @@ export function addPreCompileMessages( * * @internal */ -export function createComposer( - options: ComposerOptions & ComposerInternalOptions = {} -): Composer { +export function createComposer( + options: ComposerOptions & ComposerInternalOptions = {} +): Composer { const { __root } = options const _isGlobal = __root === undefined @@ -307,7 +322,7 @@ export function createComposer( ) const _messages = ref( - getLocaleMessages(options, _locale.value) + getLocaleMessages(options, _locale.value) ) const _datetimeFormats = ref( @@ -347,7 +362,7 @@ export function createComposer( // runtime missing let _missing = isFunction(options.missing) ? options.missing : null let _runtimeMissing = isFunction(options.missing) - ? defineRuntimeMissingHandler(options.missing) + ? defineRuntimeMissingHandler(options.missing) : null // postTranslation handler @@ -365,15 +380,15 @@ export function createComposer( ? __root.modifiers : isPlainObject(options.modifiers) ? options.modifiers - : {} + : {} as LinkedModifiers // pluralRules const _pluralRules = options.pluralRules // runtime context - let _context: RuntimeContext // eslint-disable-line prefer-const - function getRuntimeContext(): RuntimeContext { - return createRuntimeContext({ + let _context: RuntimeContext // eslint-disable-line prefer-const + function getRuntimeContext(): RuntimeContext { + return createRuntimeContext({ locale: _locale.value, fallbackLocale: _fallbackLocale.value, messages: _messages.value, @@ -397,7 +412,7 @@ export function createComposer( }) } _context = getRuntimeContext() - updateFallbackLocale(_context, _locale.value, _fallbackLocale.value) + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value) /*! * define properties @@ -436,12 +451,12 @@ export function createComposer( */ // getPostTranslationHandler - const getPostTranslationHandler = (): PostTranslationHandler | null => + const getPostTranslationHandler = (): PostTranslationHandler | null => isFunction(_postTranslation) ? _postTranslation : null // setPostTranslationHandler function setPostTranslationHandler( - handler: PostTranslationHandler | null + handler: PostTranslationHandler | null ): void { _postTranslation = handler _context.postTranslation = handler @@ -459,17 +474,17 @@ export function createComposer( _context.missing = _runtimeMissing } - function defineComputed( - fn: (context: RuntimeContext) => unknown, + function defineComputed( + fn: (context: RuntimeContext) => unknown, argumentParser: () => string, - warnType: string, - fallbackSuccess: (root: Composer & ComposerInternal) => T, - fallbackFail: (key: string) => T, + warnType: ComposerWarnType, + fallbackSuccess: (root: Composer & ComposerInternal) => U, + fallbackFail: (key: string) => U, successCondition: (val: unknown) => boolean - ): ComputedRef { - return computed( - (): T => { - const ret = fn(getRuntimeContext()) + ): ComputedRef { + return computed( + (): U => { + const ret = fn(getRuntimeContext()) if (isNumber(ret) && ret === NOT_REOSLVED) { const key = argumentParser() if (__DEV__ && _fallbackRoot && __root) { @@ -481,10 +496,12 @@ export function createComposer( ) } return _fallbackRoot && __root - ? fallbackSuccess(__root as Composer & ComposerInternal) + ? fallbackSuccess( + (__root as unknown) as Composer & ComposerInternal + ) : fallbackFail(key) } else if (successCondition(ret)) { - return ret as T + return ret as U } else { /* istanbul ignore next */ throw createI18nError(I18nErrorCodes.UNEXPECTED_RETURN_TYPE) @@ -496,7 +513,7 @@ export function createComposer( // t function t(...args: unknown[]): string { return defineComputed( - context => translate(context, ...args), + context => translate(context, ...args), () => parseTranslateArgs(...args)[0], 'translate', root => root.t(...args), @@ -508,7 +525,7 @@ export function createComposer( // d function d(...args: unknown[]): string { return defineComputed( - context => datetime(context, ...args), + context => datetime(context, ...args), () => parseDateTimeArgs(...args)[0], 'datetime format', root => root.d(...args), @@ -520,7 +537,7 @@ export function createComposer( // n function n(...args: unknown[]): string { return defineComputed( - context => number(context, ...args), + context => number(context, ...args), () => parseNumberArgs(...args)[0], 'number format', root => root.n(...args), @@ -530,25 +547,27 @@ export function createComposer( } // for custom processor - function normalize(values: unknown[]): unknown { + function normalize( + values: MessageType[] + ): MessageType[] { return values.map(val => isString(val) ? createVNode(Text, null, val, 0) : val ) } - const interpolate = (val: unknown): unknown => val + const interpolate = (val: unknown): MessageType => val as VNode const processor = { normalize, interpolate - } as MessageProcessor + } as MessageProcessor // __transrateVNode, using for `i18n-t` component - function __transrateVNode(...args: unknown[]): unknown { - return defineComputed( + function __transrateVNode(...args: unknown[]): VNodeArrayChildren { + return defineComputed( context => { let ret: unknown try { context.processor = processor - ret = translate(context, ...args) + ret = translate(context, ...args) } finally { context.processor = null } @@ -557,7 +576,7 @@ export function createComposer( () => parseTranslateArgs(...args)[0], 'translate', root => root.__transrateVNode(...args), - key => key, + key => [createVNode(Text, null, key, 0)], val => isArray(val) ).value } @@ -593,7 +612,7 @@ export function createComposer( _messages.value[locale] || {} // setLocaleMessage - function setLocaleMessage(locale: Locale, message: LocaleMessage): void { + function setLocaleMessage(locale: Locale, message: LocaleMessage) { _messages.value[locale] = message _context.messages = _messages.value } @@ -615,7 +634,7 @@ export function createComposer( function setDateTimeFormat(locale: Locale, format: DateTimeFormat): void { _datetimeFormats.value[locale] = format _context.datetimeFormats = _datetimeFormats.value - clearDateTimeFormat(_context, locale, format) + clearDateTimeFormat(_context, locale, format) } // mergeDateTimeFormat @@ -625,7 +644,7 @@ export function createComposer( format ) _context.datetimeFormats = _datetimeFormats.value - clearDateTimeFormat(_context, locale, format) + clearDateTimeFormat(_context, locale, format) } // getNumberFormat @@ -636,7 +655,7 @@ export function createComposer( function setNumberFormat(locale: Locale, format: NumberFormat): void { _numberFormats.value[locale] = format _context.numberFormats = _numberFormats.value - clearNumberFormat(_context, locale, format) + clearNumberFormat(_context, locale, format) } // mergeNumberFormat @@ -646,7 +665,7 @@ export function createComposer( format ) _context.numberFormats = _numberFormats.value - clearNumberFormat(_context, locale, format) + clearNumberFormat(_context, locale, format) } // for debug @@ -658,14 +677,14 @@ export function createComposer( if (_inheritLocale) { _locale.value = val _context.locale = val - updateFallbackLocale(_context, _locale.value, _fallbackLocale.value) + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value) } }) watch(__root.fallbackLocale, (val: FallbackLocale) => { if (_inheritLocale) { _fallbackLocale.value = val _context.fallbackLocale = val - updateFallbackLocale(_context, _locale.value, _fallbackLocale.value) + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value) } }) } @@ -683,7 +702,7 @@ export function createComposer( if (val && __root) { _locale.value = __root.locale.value _fallbackLocale.value = __root.fallbackLocale.value - updateFallbackLocale(_context, _locale.value, _fallbackLocale.value) + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value) } }, get availableLocales(): Locale[] { @@ -692,7 +711,7 @@ export function createComposer( messages, datetimeFormats, numberFormats, - get modifiers(): LinkedModifiers { + get modifiers(): LinkedModifiers { return _modifiers }, get pluralRules(): PluralizationRules | undefined { diff --git a/src/core/context.ts b/src/core/context.ts index 2830e356b..336a7d26b 100644 --- a/src/core/context.ts +++ b/src/core/context.ts @@ -20,6 +20,7 @@ import { isObject } from '../utils' import { DateTimeFormats, NumberFormats } from './types' +import { LinkedKeyNode } from '../message/parser' export type Locale = string @@ -141,8 +142,8 @@ export function createRuntimeContext( ? options.numberFormats : { [locale]: {} } const modifiers = Object.assign( - {} as LinkedModifiers, - options.modifiers || {}, + {} as LinkedModifiers, + options.modifiers || ({} as LinkedModifiers), getDefaultLinkedModifiers() ) const pluralRules = options.pluralRules || {} @@ -331,11 +332,11 @@ function appendItemToChain( return follow } -export function updateFallbackLocale( - context: RuntimeContext, +export function updateFallbackLocale( + context: RuntimeContext, locale: Locale, fallback: FallbackLocale ): void { context._localeChainCache = new Map() - getLocaleChain(context, fallback, locale) + getLocaleChain(context, fallback, locale) } diff --git a/src/core/datetime.ts b/src/core/datetime.ts index f42d3cab3..05390f3a7 100644 --- a/src/core/datetime.ts +++ b/src/core/datetime.ts @@ -202,8 +202,8 @@ export function parseDateTimeArgs( return [options.key || '', value, options, orverrides] } -export function clearDateTimeFormat( - context: RuntimeContext, +export function clearDateTimeFormat( + context: RuntimeContext, locale: Locale, format: DateTimeFormat ): void { diff --git a/src/core/number.ts b/src/core/number.ts index c8cad9fcc..6f0e67b25 100644 --- a/src/core/number.ts +++ b/src/core/number.ts @@ -200,8 +200,8 @@ export function parseNumberArgs( return [options.key || '', value, options, orverrides] } -export function clearNumberFormat( - context: RuntimeContext, +export function clearNumberFormat( + context: RuntimeContext, locale: Locale, format: NumberFormat ): void { diff --git a/test/__snapshots__/composer.test.ts.snap b/test/__snapshots__/composer.test.ts.snap new file mode 100644 index 000000000..70bd69270 --- /dev/null +++ b/test/__snapshots__/composer.test.ts.snap @@ -0,0 +1,30 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`__transrateVNode missing 1`] = ` +Array [ + Object { + "__v_isVNode": true, + "__v_skip": true, + "anchor": null, + "appContext": null, + "children": "hello", + "component": null, + "dirs": null, + "dynamicChildren": null, + "dynamicProps": null, + "el": null, + "key": null, + "patchFlag": 0, + "props": null, + "ref": null, + "scopeId": null, + "shapeFlag": 8, + "staticCount": 0, + "suspense": null, + "target": null, + "targetAnchor": null, + "transition": null, + "type": Symbol(Text), + }, +] +`; diff --git a/test/composer.test.ts b/test/composer.test.ts index 4ec176020..c6c2e21bd 100644 --- a/test/composer.test.ts +++ b/test/composer.test.ts @@ -923,7 +923,7 @@ describe('__transrateVNode', () => { (composer as Composer & ComposerInternal).__transrateVNode('hello', { name: createVNode(Text, null, 'kazupon', 0) }) - ).toEqual('hello') + ).toMatchSnapshot() }) }) diff --git a/test/message/__snapshots__/runtime.test.ts.snap b/test/message/__snapshots__/runtime.test.ts.snap index 11b74cae7..e98289a99 100644 --- a/test/message/__snapshots__/runtime.test.ts.snap +++ b/test/message/__snapshots__/runtime.test.ts.snap @@ -6,7 +6,7 @@ Array [ "text": "hi ", }, Object { - "text": "vnode:KAZUPON", + "text": "KAZUPON", }, Object { "text": " !", @@ -51,7 +51,7 @@ Array [ "text": " ", }, Object { - "text": "vnode:apple", + "text": "apple", }, ] `; diff --git a/test/message/runtime.test.ts b/test/message/runtime.test.ts index 8a3318bbe..506c9543b 100644 --- a/test/message/runtime.test.ts +++ b/test/message/runtime.test.ts @@ -319,8 +319,8 @@ describe('custom process', () => { type: 'vnode' }, modifiers: { - upper: (val: string | MockVNode, type: string): string | MockVNode => - `${type}:${(val as MockVNode).text.toUpperCase()}` + upper: (val: string | MockVNode): string | MockVNode => + `${(val as MockVNode).text.toUpperCase()}` }, messages: { name: ctx => createVNode('kazupon') // eslint-disable-line @@ -340,8 +340,8 @@ describe('custom process', () => { type: 'vnode' }, modifiers: { - lower: (val: string | MockVNode, type: string): string | MockVNode => - `${type}:${(val as MockVNode).text.toLowerCase()}` + lower: (val: string | MockVNode): string | MockVNode => + `${(val as MockVNode).text.toLowerCase()}` }, named: { unit: 'apple', From 6a39b9985fc7705a7be90ba35724e0cc19a0d1f8 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Mon, 27 Jul 2020 02:02:33 +0900 Subject: [PATCH 10/20] update legacy type defintion --- src/composer.ts | 21 +++++++++++---------- src/legacy.ts | 15 +++++++++------ 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/composer.ts b/src/composer.ts index 693e405d6..063890ee8 100644 --- a/src/composer.ts +++ b/src/composer.ts @@ -475,7 +475,7 @@ export function createComposer( } function defineComputed( - fn: (context: RuntimeContext) => unknown, + fn: (context: unknown) => unknown, argumentParser: () => string, warnType: ComposerWarnType, fallbackSuccess: (root: Composer & ComposerInternal) => U, @@ -484,7 +484,7 @@ export function createComposer( ): ComputedRef { return computed( (): U => { - const ret = fn(getRuntimeContext()) + const ret = fn(getRuntimeContext()) if (isNumber(ret) && ret === NOT_REOSLVED) { const key = argumentParser() if (__DEV__ && _fallbackRoot && __root) { @@ -513,7 +513,7 @@ export function createComposer( // t function t(...args: unknown[]): string { return defineComputed( - context => translate(context, ...args), + context => translate(context as RuntimeContext, ...args), () => parseTranslateArgs(...args)[0], 'translate', root => root.t(...args), @@ -525,7 +525,7 @@ export function createComposer( // d function d(...args: unknown[]): string { return defineComputed( - context => datetime(context, ...args), + context => datetime(context as RuntimeContext, ...args), () => parseDateTimeArgs(...args)[0], 'datetime format', root => root.d(...args), @@ -537,7 +537,7 @@ export function createComposer( // n function n(...args: unknown[]): string { return defineComputed( - context => number(context, ...args), + context => number(context as RuntimeContext, ...args), () => parseNumberArgs(...args)[0], 'number format', root => root.n(...args), @@ -566,10 +566,11 @@ export function createComposer( context => { let ret: unknown try { - context.processor = processor - ret = translate(context, ...args) + const _context = context as RuntimeContext + _context.processor = processor + ret = translate(_context, ...args) } finally { - context.processor = null + _context.processor = null } return ret }, @@ -584,7 +585,7 @@ export function createComposer( // __numberParts, using for `i18n-n` component function __numberParts(...args: unknown[]): string | Intl.NumberFormatPart[] { return defineComputed( - context => number(context, ...args), + context => number(context as RuntimeContext, ...args), () => parseNumberArgs(...args)[0], 'number format', root => root.__numberParts(...args), @@ -598,7 +599,7 @@ export function createComposer( ...args: unknown[] ): string | Intl.DateTimeFormatPart[] { return defineComputed( - context => datetime(context, ...args), + context => datetime(context as RuntimeContext, ...args), () => parseDateTimeArgs(...args)[0], 'datetime format', root => root.__datetimeParts(...args), diff --git a/src/legacy.ts b/src/legacy.ts index 4bd94cd65..e10a1012e 100644 --- a/src/legacy.ts +++ b/src/legacy.ts @@ -27,6 +27,7 @@ import { NumberFormat } from './core/types' import { + VueMessageType, MissingHandler, Composer, ComposerOptions, @@ -76,7 +77,7 @@ export interface VueI18nOptions { datetimeFormats?: DateTimeFormats numberFormats?: NumberFormats availableLocales?: Locale[] - modifiers?: LinkedModifiers + modifiers?: LinkedModifiers formatter?: Formatter missing?: MissingHandler fallbackRoot?: boolean @@ -87,7 +88,7 @@ export interface VueI18nOptions { warnHtmlInMessage?: WarnHtmlInMessageLevel sharedMessages?: LocaleMessages pluralizationRules?: PluralizationRules - postTranslation?: PostTranslationHandler + postTranslation?: PostTranslationHandler sync?: boolean componentInstanceCreatedListener?: ComponentInstanceCreatedListener } @@ -108,7 +109,7 @@ export interface VueI18n { readonly numberFormats: NumberFormats formatter: Formatter missing: MissingHandler | null - postTranslation: PostTranslationHandler | null + postTranslation: PostTranslationHandler | null silentTranslationWarn: boolean | RegExp silentFallbackWarn: boolean | RegExp formatFallbackMessages: boolean @@ -170,7 +171,7 @@ export interface VueI18nInternal { * @internal */ function convertComposerOptions( - options: VueI18nOptions & ComposerInternalOptions + options: VueI18nOptions & ComposerInternalOptions ): ComposerOptions & ComposerInternalOptions { const locale = isString(options.locale) ? options.locale : 'en-US' const fallbackLocale = @@ -350,10 +351,12 @@ export function createVueI18n( }, // postTranslation - get postTranslation(): PostTranslationHandler | null { + get postTranslation(): PostTranslationHandler | null { return composer.getPostTranslationHandler() }, - set postTranslation(handler: PostTranslationHandler | null) { + set postTranslation( + handler: PostTranslationHandler | null + ) { composer.setPostTranslationHandler(handler) }, From 8fbd532e8090255645ff9a3de5f3f11965f02b96 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Mon, 27 Jul 2020 02:11:56 +0900 Subject: [PATCH 11/20] fix lint errors --- src/components/Translation.ts | 9 +-------- src/core/context.ts | 1 - 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/components/Translation.ts b/src/components/Translation.ts index 811c06c7d..24ccf4e2f 100644 --- a/src/components/Translation.ts +++ b/src/components/Translation.ts @@ -1,11 +1,4 @@ -import { - h, - Fragment, - defineComponent, - SetupContext, - VNodeChild, - VNodeArrayChildren -} from 'vue' +import { h, Fragment, defineComponent, SetupContext, VNodeChild } from 'vue' import { Composer, ComposerInternal } from '../composer' import { useI18n } from '../i18n' import { TranslateOptions } from '../core' diff --git a/src/core/context.ts b/src/core/context.ts index 336a7d26b..92f112851 100644 --- a/src/core/context.ts +++ b/src/core/context.ts @@ -20,7 +20,6 @@ import { isObject } from '../utils' import { DateTimeFormats, NumberFormats } from './types' -import { LinkedKeyNode } from '../message/parser' export type Locale = string From b3bf89c91bfa8feee44f2b0213aaca44fe365599 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Mon, 27 Jul 2020 03:02:16 +0900 Subject: [PATCH 12/20] extract runtime context for internal --- src/composer.ts | 11 +++++---- src/core/context.ts | 54 ++++++++++++++++++++++++++------------------ src/core/datetime.ts | 23 +++++++++---------- src/core/number.ts | 23 ++++++++----------- 4 files changed, 59 insertions(+), 52 deletions(-) diff --git a/src/composer.ts b/src/composer.ts index 063890ee8..bd927dff4 100644 --- a/src/composer.ts +++ b/src/composer.ts @@ -42,7 +42,8 @@ import { PostTranslationHandler, MISSING_RESOLVE_VALUE, updateFallbackLocale, - FallbackLocale + FallbackLocale, + RuntimeInternalContext } from './core/context' import { translate, @@ -403,11 +404,11 @@ export function createComposer( unresolving: true, postTranslation: _postTranslation === null ? undefined : _postTranslation, warnHtmlMessage: _warnHtmlMessage, - _datetimeFormatters: isPlainObject(_context) - ? _context._datetimeFormatters + __datetimeFormatters: isPlainObject(_context) + ? ((_context as unknown) as RuntimeInternalContext).__datetimeFormatters : undefined, - _numberFormatters: isPlainObject(_context) - ? _context._numberFormatters + __numberFormatters: isPlainObject(_context) + ? ((_context as unknown) as RuntimeInternalContext).__numberFormatters : undefined }) } diff --git a/src/core/context.ts b/src/core/context.ts index 92f112851..85e5f8fee 100644 --- a/src/core/context.ts +++ b/src/core/context.ts @@ -75,8 +75,11 @@ export interface RuntimeOptions { warnHtmlMessage?: boolean messageCompiler?: MessageCompiler onWarn?: (msg: string, err?: Error) => void - _datetimeFormatters?: Map - _numberFormatters?: Map +} + +export interface RuntimeInternalOptions { + __datetimeFormatters?: Map + __numberFormatters?: Map } export interface RuntimeContext { @@ -97,10 +100,12 @@ export interface RuntimeContext { warnHtmlMessage: boolean messageCompiler: MessageCompiler onWarn(msg: string, err?: Error): void - _datetimeFormatters: Map - _numberFormatters: Map - _fallbackLocaleStack?: Locale[] - _localeChainCache?: Map +} + +export interface RuntimeInternalContext { + __datetimeFormatters: Map + __numberFormatters: Map + __localeChainCache?: Map } export const NOT_REOSLVED = -1 @@ -121,7 +126,7 @@ function getDefaultLinkedModifiers(): LinkedModifiers { } export function createRuntimeContext( - options: RuntimeOptions = {} + options: RuntimeOptions & RuntimeInternalOptions = {} ): RuntimeContext { const locale = isString(options.locale) ? options.locale : 'en-US' const fallbackLocale = @@ -168,14 +173,14 @@ export function createRuntimeContext( ? options.messageCompiler : compile const onWarn = isFunction(options.onWarn) ? options.onWarn : warn - const _datetimeFormatters = isObject(options._datetimeFormatters) - ? options._datetimeFormatters + const __datetimeFormatters = isObject(options.__datetimeFormatters) + ? options.__datetimeFormatters : new Map() - const _numberFormatters = isObject(options._numberFormatters) - ? options._numberFormatters + const __numberFormatters = isObject(options.__numberFormatters) + ? options.__numberFormatters : new Map() - return { + const context = { locale, fallbackLocale, messages, @@ -193,9 +198,11 @@ export function createRuntimeContext( warnHtmlMessage, messageCompiler, onWarn, - _datetimeFormatters, - _numberFormatters + __datetimeFormatters, + __numberFormatters } + + return context } export function isTrarnslateFallbackWarn( @@ -232,19 +239,21 @@ export function handleMissing( } export function getLocaleChain( - context: RuntimeContext, + ctx: RuntimeContext, fallback: FallbackLocale, start: Locale = '' ): Locale[] { + const context = (ctx as unknown) as RuntimeInternalContext + if (start === '') { return [] } - if (!context._localeChainCache) { - context._localeChainCache = new Map() + if (!context.__localeChainCache) { + context.__localeChainCache = new Map() } - let chain = context._localeChainCache.get(start) + let chain = context.__localeChainCache.get(start) if (!chain) { chain = [] @@ -271,7 +280,7 @@ export function getLocaleChain( if (isArray(block)) { appendBlockToChain(chain, block, false) } - context._localeChainCache.set(start, chain) + context.__localeChainCache.set(start, chain) } return chain @@ -332,10 +341,11 @@ function appendItemToChain( } export function updateFallbackLocale( - context: RuntimeContext, + ctx: RuntimeContext, locale: Locale, fallback: FallbackLocale ): void { - context._localeChainCache = new Map() - getLocaleChain(context, fallback, locale) + const context = (ctx as unknown) as RuntimeInternalContext + context.__localeChainCache = new Map() + getLocaleChain(ctx, fallback, locale) } diff --git a/src/core/datetime.ts b/src/core/datetime.ts index 05390f3a7..c9dca1e58 100644 --- a/src/core/datetime.ts +++ b/src/core/datetime.ts @@ -6,7 +6,8 @@ import { handleMissing, isTrarnslateFallbackWarn, NOT_REOSLVED, - MISSING_RESOLVE_VALUE + MISSING_RESOLVE_VALUE, + RuntimeInternalContext } from './context' import { CoreWarnCodes, getWarnMessage } from './warnings' import { CoreErrorCodes, createCoreError } from './errors' @@ -98,13 +99,10 @@ export function datetime( context: RuntimeContext, ...args: unknown[] ): string | number | Intl.DateTimeFormatPart[] { + const { datetimeFormats, unresolving, fallbackLocale, onWarn } = context const { - datetimeFormats, - unresolving, - fallbackLocale, - onWarn, - _datetimeFormatters - } = context + __datetimeFormatters + } = (context as unknown) as RuntimeInternalContext if (__DEV__ && !Availabilities.dateTimeFormat) { onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_DATE)) @@ -160,13 +158,13 @@ export function datetime( id = `${id}__${JSON.stringify(orverrides)}` } - let formatter = _datetimeFormatters.get(id) + let formatter = __datetimeFormatters.get(id) if (!formatter) { formatter = new Intl.DateTimeFormat( targetLocale, Object.assign({}, format, orverrides) ) - _datetimeFormatters.set(id, formatter) + __datetimeFormatters.set(id, formatter) } return !part ? formatter.format(value) : formatter.formatToParts(value) } @@ -203,15 +201,16 @@ export function parseDateTimeArgs( } export function clearDateTimeFormat( - context: RuntimeContext, + ctx: RuntimeContext, locale: Locale, format: DateTimeFormat ): void { + const context = (ctx as unknown) as RuntimeInternalContext for (const key in format) { const id = `${locale}__${key}` - if (!context._datetimeFormatters.has(id)) { + if (!context.__datetimeFormatters.has(id)) { continue } - context._datetimeFormatters.delete(id) + context.__datetimeFormatters.delete(id) } } diff --git a/src/core/number.ts b/src/core/number.ts index 6f0e67b25..b83ebb9eb 100644 --- a/src/core/number.ts +++ b/src/core/number.ts @@ -6,7 +6,8 @@ import { handleMissing, isTrarnslateFallbackWarn, NOT_REOSLVED, - MISSING_RESOLVE_VALUE + MISSING_RESOLVE_VALUE, + RuntimeInternalContext } from './context' import { CoreWarnCodes, getWarnMessage } from './warnings' import { CoreErrorCodes, createCoreError } from './errors' @@ -96,13 +97,8 @@ export function number( context: RuntimeContext, ...args: unknown[] ): string | number | Intl.NumberFormatPart[] { - const { - numberFormats, - unresolving, - fallbackLocale, - onWarn, - _numberFormatters - } = context + const { numberFormats, unresolving, fallbackLocale, onWarn } = context + const { __numberFormatters } = (context as unknown) as RuntimeInternalContext if (__DEV__ && !Availabilities.numberFormat) { onWarn(getWarnMessage(CoreWarnCodes.CANNOT_FORMAT_NUMBER)) @@ -158,13 +154,13 @@ export function number( id = `${id}__${JSON.stringify(orverrides)}` } - let formatter = _numberFormatters.get(id) + let formatter = __numberFormatters.get(id) if (!formatter) { formatter = new Intl.NumberFormat( targetLocale, Object.assign({}, format, orverrides) ) - _numberFormatters.set(id, formatter) + __numberFormatters.set(id, formatter) } return !part ? formatter.format(value) : formatter.formatToParts(value) } @@ -201,15 +197,16 @@ export function parseNumberArgs( } export function clearNumberFormat( - context: RuntimeContext, + ctx: RuntimeContext, locale: Locale, format: NumberFormat ): void { + const context = (ctx as unknown) as RuntimeInternalContext for (const key in format) { const id = `${locale}__${key}` - if (!context._numberFormatters.has(id)) { + if (!context.__numberFormatters.has(id)) { continue } - context._numberFormatters.delete(id) + context.__numberFormatters.delete(id) } } From c2ff366223d65c4469053f3cff37edf0fee8e0bf Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Tue, 28 Jul 2020 12:31:22 +0900 Subject: [PATCH 13/20] bump up typescript-eslint --- package.json | 6 +++--- yarn.lock | 58 +++++++++++++++++++++++++++++++++------------------- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 99b861ed8..a3b7364d2 100644 --- a/package.json +++ b/package.json @@ -31,9 +31,9 @@ "@rollup/plugin-node-resolve": "^8.0.0", "@rollup/plugin-replace": "^2.3.0", "@types/jest": "^26.0.0", - "@typescript-eslint/eslint-plugin": "^3.0.0", - "@typescript-eslint/parser": "^3.0.0", - "@typescript-eslint/typescript-estree": "^3.0.0", + "@typescript-eslint/eslint-plugin": "^3.7.0", + "@typescript-eslint/parser": "^3.7.0", + "@typescript-eslint/typescript-estree": "^3.7.0", "brotli": "^1.3.2", "chalk": "^4.0.0", "convert-hrtime": "^3.0.0", diff --git a/yarn.lock b/yarn.lock index 4457344c9..8fded25e2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -925,50 +925,66 @@ dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/eslint-plugin@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.0.0.tgz#02f8ec6b5ce814bda80dfc22463f108bed1f699b" - integrity sha512-lcZ0M6jD4cqGccYOERKdMtg+VWpoq3NSnWVxpc/AwAy0zhkUYVioOUZmfNqiNH8/eBNGhCn6HXd6mKIGRgNc1Q== +"@typescript-eslint/eslint-plugin@^3.7.0": + version "3.7.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-3.7.1.tgz#d144c49a9a0ffe8dd704bb179c243df76c111bc9" + integrity sha512-3DB9JDYkMrc8Au00rGFiJLK2Ja9CoMP6Ut0sHsXp3ZtSugjNxvSSHTnKLfo4o+QmjYBJqEznDqsG1zj4F2xnsg== dependencies: - "@typescript-eslint/experimental-utils" "3.0.0" + "@typescript-eslint/experimental-utils" "3.7.1" + debug "^4.1.1" functional-red-black-tree "^1.0.1" regexpp "^3.0.0" semver "^7.3.2" tsutils "^3.17.1" -"@typescript-eslint/experimental-utils@3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-3.0.0.tgz#1ddf53eeb61ac8eaa9a77072722790ac4f641c03" - integrity sha512-BN0vmr9N79M9s2ctITtChRuP1+Dls0x/wlg0RXW1yQ7WJKPurg6X3Xirv61J2sjPif4F8SLsFMs5Nzte0WYoTQ== +"@typescript-eslint/experimental-utils@3.7.1": + version "3.7.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-3.7.1.tgz#ab036caaed4c870d22531d41f9352f3147364d61" + integrity sha512-TqE97pv7HrqWcGJbLbZt1v59tcqsSVpWTOf1AqrWK7n8nok2sGgVtYRuGXeNeLw3wXlLEbY1MKP3saB2HsO/Ng== dependencies: "@types/json-schema" "^7.0.3" - "@typescript-eslint/typescript-estree" "3.0.0" + "@typescript-eslint/types" "3.7.1" + "@typescript-eslint/typescript-estree" "3.7.1" eslint-scope "^5.0.0" eslint-utils "^2.0.0" -"@typescript-eslint/parser@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-3.0.0.tgz#fe9fdf18a1155c02c04220c14506a320cb6c6944" - integrity sha512-8RRCA9KLxoFNO0mQlrLZA0reGPd/MsobxZS/yPFj+0/XgMdS8+mO8mF3BDj2ZYQj03rkayhSJtF1HAohQ3iylw== +"@typescript-eslint/parser@^3.7.0": + version "3.7.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-3.7.1.tgz#5d9ccecb116d12d9c6073e9861c57c9b1aa88128" + integrity sha512-W4QV/gXvfIsccN8225784LNOorcm7ch68Fi3V4Wg7gmkWSQRKevO4RrRqWo6N/Z/myK1QAiGgeaXN57m+R/8iQ== dependencies: "@types/eslint-visitor-keys" "^1.0.0" - "@typescript-eslint/experimental-utils" "3.0.0" - "@typescript-eslint/typescript-estree" "3.0.0" + "@typescript-eslint/experimental-utils" "3.7.1" + "@typescript-eslint/types" "3.7.1" + "@typescript-eslint/typescript-estree" "3.7.1" eslint-visitor-keys "^1.1.0" -"@typescript-eslint/typescript-estree@3.0.0", "@typescript-eslint/typescript-estree@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-3.0.0.tgz#fa40e1b76ccff880130be054d9c398e96004bf42" - integrity sha512-nevQvHyNghsfLrrByzVIH4ZG3NROgJ8LZlfh3ddwPPH4CH7W4GAiSx5qu+xHuX5pWsq6q/eqMc1io840ZhAnUg== +"@typescript-eslint/types@3.7.1": + version "3.7.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-3.7.1.tgz#90375606b2fd73c1224fe9e397ee151e28fa1e0c" + integrity sha512-PZe8twm5Z4b61jt7GAQDor6KiMhgPgf4XmUb9zdrwTbgtC/Sj29gXP1dws9yEn4+aJeyXrjsD9XN7AWFhmnUfg== + +"@typescript-eslint/typescript-estree@3.7.1", "@typescript-eslint/typescript-estree@^3.7.0": + version "3.7.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-3.7.1.tgz#ce1ffbd0fa53f34d4ce851a7a364e392432f6eb3" + integrity sha512-m97vNZkI08dunYOr2lVZOHoyfpqRs0KDpd6qkGaIcLGhQ2WPtgHOd/eVbsJZ0VYCQvupKrObAGTOvk3tfpybYA== dependencies: + "@typescript-eslint/types" "3.7.1" + "@typescript-eslint/visitor-keys" "3.7.1" debug "^4.1.1" - eslint-visitor-keys "^1.1.0" glob "^7.1.6" is-glob "^4.0.1" lodash "^4.17.15" semver "^7.3.2" tsutils "^3.17.1" +"@typescript-eslint/visitor-keys@3.7.1": + version "3.7.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-3.7.1.tgz#b90191e74efdee656be8c5a30f428ed16dda46d1" + integrity sha512-xn22sQbEya+Utj2IqJHGLA3i1jDzR43RzWupxojbSWnj3nnPLavaQmWe5utw03CwYao3r00qzXfgJMGNkrzrAA== + dependencies: + eslint-visitor-keys "^1.1.0" + "@vue/compiler-core@3.0.0-beta.15": version "3.0.0-beta.15" resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.0.0-beta.15.tgz#8710a8e3ba15ba1a8b62bd17609d26bd27fdcc45" From 3ef01f5c74e9b7557ee52e2635f53f28d823ef74 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Mon, 3 Aug 2020 15:01:33 +0900 Subject: [PATCH 14/20] updates --- src/composer.ts | 203 +++++++++++++++++++++++++++--------------- src/core/context.ts | 143 +++++++++++++++++------------ src/core/datetime.ts | 28 +++--- src/core/number.ts | 28 +++--- src/core/translate.ts | 150 +++++++++++++++++-------------- src/directive.ts | 25 +++--- src/i18n.ts | 150 ++++++++++++++++++------------- src/legacy.ts | 91 ++++++++++++------- src/mixin.ts | 27 +++--- src/plugin.ts | 8 +- test/composer.test.ts | 28 +++--- 11 files changed, 527 insertions(+), 354 deletions(-) diff --git a/src/composer.ts b/src/composer.ts index bd927dff4..f8b763b76 100644 --- a/src/composer.ts +++ b/src/composer.ts @@ -38,7 +38,9 @@ import { createRuntimeContext, RuntimeContext, RuntimeMissingHandler, - LocaleMessage, + RuntimeOptions, + LocaleMessageValue, + LocaleMessageDictionary, PostTranslationHandler, MISSING_RESOLVE_VALUE, updateFallbackLocale, @@ -91,14 +93,14 @@ export type MissingHandler = ( type?: string ) => string | void -export type PreCompileHandler = () => { - messages: LocaleMessages - functions: MessageFunctions +export type PreCompileHandler = () => { + messages: LocaleMessages + functions: MessageFunctions } -export type CustomBlocks = - | Array - | PreCompileHandler +export type CustomBlocks = + | Array> + | PreCompileHandler /** * Composer Options @@ -106,30 +108,32 @@ export type CustomBlocks = * @remarks * This is options to create composer. */ -export interface ComposerOptions { +export interface ComposerOptions { locale?: Locale fallbackLocale?: FallbackLocale inheritLocale?: boolean - messages?: LocaleMessages + messages?: { + [K in keyof Messages]: LocaleMessageDictionary + } datetimeFormats?: DateTimeFormats numberFormats?: NumberFormats - modifiers?: LinkedModifiers + modifiers?: LinkedModifiers pluralRules?: PluralizationRules missing?: MissingHandler missingWarn?: boolean | RegExp fallbackWarn?: boolean | RegExp fallbackRoot?: boolean fallbackFormat?: boolean - postTranslation?: PostTranslationHandler + postTranslation?: PostTranslationHandler warnHtmlMessage?: boolean } /** * @internal */ -export interface ComposerInternalOptions { - __i18n?: CustomBlocks - __root?: Composer +export interface ComposerInternalOptions { + __i18n?: CustomBlocks + __root?: Composer } /** @@ -138,16 +142,16 @@ export interface ComposerInternalOptions { * @remarks * This is the interface for being used for Vue 3 Composition API. */ -export interface Composer { +export interface Composer { // properties locale: WritableComputedRef fallbackLocale: WritableComputedRef inheritLocale: boolean readonly availableLocales: Locale[] - readonly messages: ComputedRef + readonly messages: ComputedRef readonly datetimeFormats: ComputedRef readonly numberFormats: ComputedRef - readonly modifiers: LinkedModifiers + readonly modifiers: LinkedModifiers readonly pluralRules?: PluralizationRules readonly isGlobal: boolean missingWarn: boolean | RegExp @@ -180,17 +184,25 @@ export interface Composer { n(value: number, key: string, locale: Locale): string n(value: number, options: NumberOptions): string n(...args: unknown[]): string // for internal - getLocaleMessage(locale: Locale): LocaleMessage - setLocaleMessage(locale: Locale, message: LocaleMessage): void - mergeLocaleMessage(locale: Locale, message: LocaleMessage): void + getLocaleMessage(locale: Locale): LocaleMessageDictionary + setLocaleMessage( + locale: Locale, + message: LocaleMessageDictionary + ): void + mergeLocaleMessage( + locale: Locale, + message: LocaleMessageDictionary + ): void getDateTimeFormat(locale: Locale): DateTimeFormat setDateTimeFormat(locale: Locale, format: DateTimeFormat): void mergeDateTimeFormat(locale: Locale, format: DateTimeFormat): void getNumberFormat(locale: Locale): NumberFormat setNumberFormat(locale: Locale, format: NumberFormat): void mergeNumberFormat(locale: Locale, format: NumberFormat): void - getPostTranslationHandler(): PostTranslationHandler | null - setPostTranslationHandler(handler: PostTranslationHandler | null): void + getPostTranslationHandler(): PostTranslationHandler | null + setPostTranslationHandler( + handler: PostTranslationHandler | null + ): void getMissingHandler(): MissingHandler | null setMissingHandler(handler: MissingHandler | null): void } @@ -209,23 +221,28 @@ type ComposerWarnType = 'translate' | 'number format' | 'datetime format' let composerID = 0 -function defineRuntimeMissingHandler( +function defineRuntimeMissingHandler( missing: MissingHandler -): RuntimeMissingHandler { - return ( - ctx: RuntimeContext, +): RuntimeMissingHandler { + return (( + ctx: RuntimeContext, locale: Locale, key: Path, type: string ): string | void => { return missing(locale, key, getCurrentInstance() || undefined, type) - } + }) as RuntimeMissingHandler } -function getLocaleMessages( - options: ComposerOptions & ComposerInternalOptions, +// TODO: maybe, we need to improve type definitions +function getLocaleMessages< + Messages extends LocaleMessages, + Message = VueMessageType +>( + options: ComposerOptions & + ComposerInternalOptions, locale: Locale -): LocaleMessages { +): LocaleMessages { const { messages, __i18n } = options // prettier-ignore @@ -245,15 +262,15 @@ function getLocaleMessages( if (isFunction(__i18n)) { const { functions } = __i18n() - addPreCompileMessages(ret, functions as MessageFunctions) + addPreCompileMessages(ret, functions as MessageFunctions) } return ret } -export function addPreCompileMessages( - messages: LocaleMessages, - functions: MessageFunctions +export function addPreCompileMessages( + messages: LocaleMessages, + functions: MessageFunctions ): void { const keys = Object.keys(functions) keys.forEach(key => { @@ -291,10 +308,15 @@ export function addPreCompileMessages( * * @internal */ -export function createComposer( - options: ComposerOptions & ComposerInternalOptions = {} -): Composer { - const { __root } = options +export function createComposer< + Message = VueMessageType, + Options extends ComposerOptions = object, + Messages extends Record< + keyof Options['messages'], + LocaleMessageDictionary + > = Record> +>(options: Options = {} as Options): Composer { + const { __root } = options as ComposerInternalOptions const _isGlobal = __root === undefined let _inheritLocale = isBoolean(options.inheritLocale) @@ -322,8 +344,8 @@ export function createComposer( : _locale.value ) - const _messages = ref( - getLocaleMessages(options, _locale.value) + const _messages = ref>( + getLocaleMessages(options, _locale.value) ) const _datetimeFormats = ref( @@ -363,7 +385,7 @@ export function createComposer( // runtime missing let _missing = isFunction(options.missing) ? options.missing : null let _runtimeMissing = isFunction(options.missing) - ? defineRuntimeMissingHandler(options.missing) + ? defineRuntimeMissingHandler(options.missing) : null // postTranslation handler @@ -381,18 +403,20 @@ export function createComposer( ? __root.modifiers : isPlainObject(options.modifiers) ? options.modifiers - : {} as LinkedModifiers + : {} as LinkedModifiers // pluralRules const _pluralRules = options.pluralRules // runtime context - let _context: RuntimeContext // eslint-disable-line prefer-const - function getRuntimeContext(): RuntimeContext { - return createRuntimeContext({ + let _context: RuntimeContext // eslint-disable-line prefer-const + function getRuntimeContext(): RuntimeContext { + return createRuntimeContext({ locale: _locale.value, fallbackLocale: _fallbackLocale.value, - messages: _messages.value, + messages: _messages.value as { + [K in keyof Messages]: LocaleMessageValue + }, datetimeFormats: _datetimeFormats.value, numberFormats: _numberFormats.value, modifiers: _modifiers, @@ -410,10 +434,14 @@ export function createComposer( __numberFormatters: isPlainObject(_context) ? ((_context as unknown) as RuntimeInternalContext).__numberFormatters : undefined - }) + } as RuntimeOptions) as RuntimeContext } _context = getRuntimeContext() - updateFallbackLocale(_context, _locale.value, _fallbackLocale.value) + updateFallbackLocale( + _context, + _locale.value, + _fallbackLocale.value + ) /*! * define properties @@ -439,7 +467,7 @@ export function createComposer( }) // messages - const messages = computed(() => _messages.value) + const messages = computed(() => _messages.value as Messages) // datetimeFormats const datetimeFormats = computed(() => _datetimeFormats.value) @@ -452,12 +480,13 @@ export function createComposer( */ // getPostTranslationHandler - const getPostTranslationHandler = (): PostTranslationHandler | null => - isFunction(_postTranslation) ? _postTranslation : null + const getPostTranslationHandler = (): PostTranslationHandler< + Message + > | null => (isFunction(_postTranslation) ? _postTranslation : null) // setPostTranslationHandler function setPostTranslationHandler( - handler: PostTranslationHandler | null + handler: PostTranslationHandler | null ): void { _postTranslation = handler _context.postTranslation = handler @@ -514,7 +543,11 @@ export function createComposer( // t function t(...args: unknown[]): string { return defineComputed( - context => translate(context as RuntimeContext, ...args), + context => + translate( + context as RuntimeContext, + ...args + ), () => parseTranslateArgs(...args)[0], 'translate', root => root.t(...args), @@ -526,7 +559,11 @@ export function createComposer( // d function d(...args: unknown[]): string { return defineComputed( - context => datetime(context as RuntimeContext, ...args), + context => + datetime( + context as RuntimeContext, + ...args + ), () => parseDateTimeArgs(...args)[0], 'datetime format', root => root.d(...args), @@ -538,7 +575,11 @@ export function createComposer( // n function n(...args: unknown[]): string { return defineComputed( - context => number(context as RuntimeContext, ...args), + context => + number( + context as RuntimeContext, + ...args + ), () => parseNumberArgs(...args)[0], 'number format', root => root.n(...args), @@ -567,9 +608,9 @@ export function createComposer( context => { let ret: unknown try { - const _context = context as RuntimeContext + const _context = context as RuntimeContext _context.processor = processor - ret = translate(_context, ...args) + ret = translate(_context, ...args) } finally { _context.processor = null } @@ -586,7 +627,7 @@ export function createComposer( // __numberParts, using for `i18n-n` component function __numberParts(...args: unknown[]): string | Intl.NumberFormatPart[] { return defineComputed( - context => number(context as RuntimeContext, ...args), + context => number(context as RuntimeContext, ...args), () => parseNumberArgs(...args)[0], 'number format', root => root.__numberParts(...args), @@ -600,7 +641,7 @@ export function createComposer( ...args: unknown[] ): string | Intl.DateTimeFormatPart[] { return defineComputed( - context => datetime(context as RuntimeContext, ...args), + context => datetime(context as RuntimeContext, ...args), () => parseDateTimeArgs(...args)[0], 'datetime format', root => root.__datetimeParts(...args), @@ -610,22 +651,28 @@ export function createComposer( } // getLocaleMessage - const getLocaleMessage = (locale: Locale): LocaleMessage => + const getLocaleMessage = (locale: Locale): LocaleMessageDictionary => _messages.value[locale] || {} // setLocaleMessage - function setLocaleMessage(locale: Locale, message: LocaleMessage) { + function setLocaleMessage( + locale: Locale, + message: LocaleMessageDictionary + ) { _messages.value[locale] = message - _context.messages = _messages.value + _context.messages = _messages.value as typeof _context.messages } // mergeLocaleMessage - function mergeLocaleMessage(locale: Locale, message: LocaleMessage): void { + function mergeLocaleMessage( + locale: Locale, + message: LocaleMessageDictionary + ): void { _messages.value[locale] = Object.assign( _messages.value[locale] || {}, message ) - _context.messages = _messages.value + _context.messages = _messages.value as typeof _context.messages } // getDateTimeFormat @@ -636,7 +683,7 @@ export function createComposer( function setDateTimeFormat(locale: Locale, format: DateTimeFormat): void { _datetimeFormats.value[locale] = format _context.datetimeFormats = _datetimeFormats.value - clearDateTimeFormat(_context, locale, format) + clearDateTimeFormat(_context, locale, format) } // mergeDateTimeFormat @@ -646,7 +693,7 @@ export function createComposer( format ) _context.datetimeFormats = _datetimeFormats.value - clearDateTimeFormat(_context, locale, format) + clearDateTimeFormat(_context, locale, format) } // getNumberFormat @@ -657,7 +704,7 @@ export function createComposer( function setNumberFormat(locale: Locale, format: NumberFormat): void { _numberFormats.value[locale] = format _context.numberFormats = _numberFormats.value - clearNumberFormat(_context, locale, format) + clearNumberFormat(_context, locale, format) } // mergeNumberFormat @@ -667,7 +714,7 @@ export function createComposer( format ) _context.numberFormats = _numberFormats.value - clearNumberFormat(_context, locale, format) + clearNumberFormat(_context, locale, format) } // for debug @@ -679,14 +726,22 @@ export function createComposer( if (_inheritLocale) { _locale.value = val _context.locale = val - updateFallbackLocale(_context, _locale.value, _fallbackLocale.value) + updateFallbackLocale( + _context, + _locale.value, + _fallbackLocale.value + ) } }) watch(__root.fallbackLocale, (val: FallbackLocale) => { if (_inheritLocale) { _fallbackLocale.value = val _context.fallbackLocale = val - updateFallbackLocale(_context, _locale.value, _fallbackLocale.value) + updateFallbackLocale( + _context, + _locale.value, + _fallbackLocale.value + ) } }) } @@ -704,7 +759,11 @@ export function createComposer( if (val && __root) { _locale.value = __root.locale.value _fallbackLocale.value = __root.fallbackLocale.value - updateFallbackLocale(_context, _locale.value, _fallbackLocale.value) + updateFallbackLocale( + _context, + _locale.value, + _fallbackLocale.value + ) } }, get availableLocales(): Locale[] { @@ -713,7 +772,7 @@ export function createComposer( messages, datetimeFormats, numberFormats, - get modifiers(): LinkedModifiers { + get modifiers(): LinkedModifiers { return _modifiers }, get pluralRules(): PluralizationRules | undefined { diff --git a/src/core/context.ts b/src/core/context.ts index 85e5f8fee..0feb0dc92 100644 --- a/src/core/context.ts +++ b/src/core/context.ts @@ -21,6 +21,13 @@ import { } from '../utils' import { DateTimeFormats, NumberFormats } from './types' +// eslint-disable-next-line @typescript-eslint/no-explicit-any +type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ( + k: infer I +) => void + ? I + : never + export type Locale = string export type FallbackLocale = @@ -29,51 +36,60 @@ export type FallbackLocale = | { [locale in string]: Locale[] } | false -// TODO: should more design it's useful typing ... -export type LocaleMessageDictionary = { - [property: string]: LocaleMessage -} -export type LocaleMessage = +export type LocaleMessageValue = | string - | MessageFunction - | LocaleMessageDictionary - | LocaleMessage[] -export type LocaleMessages = Record + | MessageFunction + | LocaleMessageDictionary + | LocaleMessageArray +export type LocaleMessageDictionary = { + [property: string]: LocaleMessageValue +} +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface LocaleMessageArray + extends Array> {} +export type LocaleMessages = Record< + Locale, + LocaleMessageDictionary +> + +type NestedPath = { [K in keyof T]: T[K] } export type RuntimeMissingType = 'translate' | 'datetime' | 'number' -export type RuntimeMissingHandler = ( - context: RuntimeContext, +export type RuntimeMissingHandler = ( + context: RuntimeContext, locale: Locale, key: Path, type: RuntimeMissingType, ...values: unknown[] ) => string | void -export type PostTranslationHandler = ( - translated: MessageType -) => MessageType +export type PostTranslationHandler = ( + translated: MessageType +) => MessageType -export type MessageCompiler = ( +export type MessageCompiler = ( source: string, options?: CompileOptions -) => MessageFunction +) => MessageFunction -export interface RuntimeOptions { +export interface RuntimeOptions { locale?: Locale fallbackLocale?: FallbackLocale - messages?: LocaleMessages + messages?: { + [K in keyof Messages]: LocaleMessageDictionary + } datetimeFormats?: DateTimeFormats numberFormats?: NumberFormats - modifiers?: LinkedModifiers + modifiers?: LinkedModifiers pluralRules?: PluralizationRules - missing?: RuntimeMissingHandler + missing?: RuntimeMissingHandler missingWarn?: boolean | RegExp fallbackWarn?: boolean | RegExp fallbackFormat?: boolean unresolving?: boolean - postTranslation?: PostTranslationHandler - processor?: MessageProcessor + postTranslation?: PostTranslationHandler + processor?: MessageProcessor warnHtmlMessage?: boolean - messageCompiler?: MessageCompiler + messageCompiler?: MessageCompiler onWarn?: (msg: string, err?: Error) => void } @@ -82,23 +98,23 @@ export interface RuntimeInternalOptions { __numberFormatters?: Map } -export interface RuntimeContext { +export interface RuntimeContext { locale: Locale fallbackLocale: FallbackLocale - messages: LocaleMessages + messages: Messages datetimeFormats: DateTimeFormats numberFormats: NumberFormats - modifiers: LinkedModifiers + modifiers: LinkedModifiers pluralRules?: PluralizationRules - missing: RuntimeMissingHandler | null + missing: RuntimeMissingHandler | null missingWarn: boolean | RegExp fallbackWarn: boolean | RegExp fallbackFormat: boolean unresolving: boolean - postTranslation: PostTranslationHandler | null - processor: MessageProcessor | null + postTranslation: PostTranslationHandler | null + processor: MessageProcessor | null warnHtmlMessage: boolean - messageCompiler: MessageCompiler + messageCompiler: MessageCompiler onWarn(msg: string, err?: Error): void } @@ -111,23 +127,33 @@ export interface RuntimeInternalContext { export const NOT_REOSLVED = -1 export const MISSING_RESOLVE_VALUE = '' -function getDefaultLinkedModifiers(): LinkedModifiers { +function getDefaultLinkedModifiers(): LinkedModifiers< + Message +> { return { - upper: (val: T): MessageType => - (isString(val) ? val.toUpperCase() : val) as MessageType, - lower: (val: T): MessageType => - (isString(val) ? val.toLowerCase() : val) as MessageType, + upper: (val: Message): MessageType => + (isString(val) ? val.toUpperCase() : val) as MessageType, + lower: (val: Message): MessageType => + (isString(val) ? val.toLowerCase() : val) as MessageType, // prettier-ignore - capitalize: (val: T): MessageType => + capitalize: (val: Message): MessageType => (isString(val) ? `${val.charAt(0).toLocaleUpperCase()}${val.substr(1)}` - : val) as MessageType + : val) as MessageType } } -export function createRuntimeContext( - options: RuntimeOptions & RuntimeInternalOptions = {} -): RuntimeContext { +export function createRuntimeContext< + Message = string, + Options extends RuntimeOptions = object, + Messages extends Record< + keyof Options['messages'], + LocaleMessageDictionary + > = Record> +>( + options: Options = {} as Options +): RuntimeContext { + // setup options const locale = isString(options.locale) ? options.locale : 'en-US' const fallbackLocale = isArray(options.fallbackLocale) || @@ -138,7 +164,7 @@ export function createRuntimeContext( : locale const messages = isPlainObject(options.messages) ? options.messages - : { [locale]: {} } + : ({ [locale]: {} } as Messages) const datetimeFormats = isPlainObject(options.datetimeFormats) ? options.datetimeFormats : { [locale]: {} } @@ -146,9 +172,9 @@ export function createRuntimeContext( ? options.numberFormats : { [locale]: {} } const modifiers = Object.assign( - {} as LinkedModifiers, - options.modifiers || ({} as LinkedModifiers), - getDefaultLinkedModifiers() + {} as LinkedModifiers, + options.modifiers || ({} as LinkedModifiers), + getDefaultLinkedModifiers() ) const pluralRules = options.pluralRules || {} const missing = isFunction(options.missing) ? options.missing : null @@ -173,11 +199,14 @@ export function createRuntimeContext( ? options.messageCompiler : compile const onWarn = isFunction(options.onWarn) ? options.onWarn : warn - const __datetimeFormatters = isObject(options.__datetimeFormatters) - ? options.__datetimeFormatters + + // setup internal options + const internalOptions = options as RuntimeInternalOptions + const __datetimeFormatters = isObject(internalOptions.__datetimeFormatters) + ? internalOptions.__datetimeFormatters : new Map() - const __numberFormatters = isObject(options.__numberFormatters) - ? options.__numberFormatters + const __numberFormatters = isObject(internalOptions.__numberFormatters) + ? internalOptions.__numberFormatters : new Map() const context = { @@ -200,7 +229,7 @@ export function createRuntimeContext( onWarn, __datetimeFormatters, __numberFormatters - } + } as RuntimeContext return context } @@ -219,8 +248,8 @@ export function isTranslateMissingWarn( return missing instanceof RegExp ? missing.test(key) : missing } -export function handleMissing( - context: RuntimeContext, +export function handleMissing( + context: RuntimeContext, key: Path, locale: Locale, missingWarn: boolean | RegExp, @@ -228,7 +257,7 @@ export function handleMissing( ): unknown { const { missing, onWarn } = context if (missing !== null) { - const ret = missing(context, locale, key, type) + const ret = missing(context, locale, key, type) return isString(ret) ? ret : key } else { if (__DEV__ && isTranslateMissingWarn(missingWarn, key)) { @@ -238,8 +267,8 @@ export function handleMissing( } } -export function getLocaleChain( - ctx: RuntimeContext, +export function getLocaleChain( + ctx: RuntimeContext, fallback: FallbackLocale, start: Locale = '' ): Locale[] { @@ -340,12 +369,12 @@ function appendItemToChain( return follow } -export function updateFallbackLocale( - ctx: RuntimeContext, +export function updateFallbackLocale( + ctx: RuntimeContext, locale: Locale, fallback: FallbackLocale ): void { const context = (ctx as unknown) as RuntimeInternalContext context.__localeChainCache = new Map() - getLocaleChain(ctx, fallback, locale) + getLocaleChain(ctx, fallback, locale) } diff --git a/src/core/datetime.ts b/src/core/datetime.ts index c9dca1e58..444f0e21a 100644 --- a/src/core/datetime.ts +++ b/src/core/datetime.ts @@ -69,34 +69,34 @@ export type DateTimeOptions = { } // `datetime` function overloads -export function datetime( - context: RuntimeContext, +export function datetime( + context: RuntimeContext, value: number | Date ): string | number | Intl.DateTimeFormatPart[] -export function datetime( - context: RuntimeContext, +export function datetime( + context: RuntimeContext, value: number | Date, key: string ): string | number | Intl.DateTimeFormatPart[] -export function datetime( - context: RuntimeContext, +export function datetime( + context: RuntimeContext, value: number | Date, key: string, locale: Locale ): string | number | Intl.DateTimeFormatPart[] -export function datetime( - context: RuntimeContext, +export function datetime( + context: RuntimeContext, value: number | Date, options: DateTimeOptions ): string | number | Intl.DateTimeFormatPart[] -export function datetime( - context: RuntimeContext, +export function datetime( + context: RuntimeContext, ...args: unknown[] ): string | number | Intl.DateTimeFormatPart[] // for internal // implementation of `datetime` function -export function datetime( - context: RuntimeContext, +export function datetime( + context: RuntimeContext, ...args: unknown[] ): string | number | Intl.DateTimeFormatPart[] { const { datetimeFormats, unresolving, fallbackLocale, onWarn } = context @@ -200,8 +200,8 @@ export function parseDateTimeArgs( return [options.key || '', value, options, orverrides] } -export function clearDateTimeFormat( - ctx: RuntimeContext, +export function clearDateTimeFormat( + ctx: RuntimeContext, locale: Locale, format: DateTimeFormat ): void { diff --git a/src/core/number.ts b/src/core/number.ts index b83ebb9eb..d60b42b4b 100644 --- a/src/core/number.ts +++ b/src/core/number.ts @@ -67,34 +67,34 @@ export type NumberOptions = { } // `number` function overloads -export function number( - context: RuntimeContext, +export function number( + context: RuntimeContext, value: number ): string | number | Intl.NumberFormatPart[] -export function number( - context: RuntimeContext, +export function number( + context: RuntimeContext, value: number, key: string ): string | number | Intl.NumberFormatPart[] -export function number( - context: RuntimeContext, +export function number( + context: RuntimeContext, value: number, key: string, locale: Locale ): string | number | Intl.NumberFormatPart[] -export function number( - context: RuntimeContext, +export function number( + context: RuntimeContext, value: number, options: NumberOptions ): string | number | Intl.NumberFormatPart[] -export function number( - context: RuntimeContext, +export function number( + context: RuntimeContext, ...args: unknown[] ): string | number | Intl.NumberFormatPart[] // for internal // implementation of `number` function -export function number( - context: RuntimeContext, +export function number( + context: RuntimeContext, ...args: unknown[] ): string | number | Intl.NumberFormatPart[] { const { numberFormats, unresolving, fallbackLocale, onWarn } = context @@ -196,8 +196,8 @@ export function parseNumberArgs( return [options.key || '', value, options, orverrides] } -export function clearNumberFormat( - ctx: RuntimeContext, +export function clearNumberFormat( + ctx: RuntimeContext, locale: Locale, format: NumberFormat ): void { diff --git a/src/core/translate.ts b/src/core/translate.ts index d507a00d9..5d59028b7 100644 --- a/src/core/translate.ts +++ b/src/core/translate.ts @@ -14,9 +14,10 @@ import { RuntimeContext, isTrarnslateFallbackWarn, handleMissing, - LocaleMessage, + LocaleMessageValue, getLocaleChain, - NOT_REOSLVED + NOT_REOSLVED, + LocaleMessages } from './context' import { CoreWarnCodes, getWarnMessage } from './warnings' import { CoreErrorCodes, createCoreError } from './errors' @@ -88,88 +89,88 @@ export type TranslateOptions = { } // `translate` function overloads -export function translate( - context: RuntimeContext, +export function translate( + context: RuntimeContext, key: Path -): MessageType | number -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, plural: number -): MessageType | number -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, plural: number, options: TranslateOptions -): MessageType | number -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, defaultMsg: string -): MessageType | number -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, defaultMsg: string, options: TranslateOptions -): MessageType | number -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, list: unknown[] -): MessageType | number -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, list: unknown[], plural: number -): MessageType | number -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, list: unknown[], defaultMsg: string -): MessageType | number -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, list: unknown[], options: TranslateOptions -): MessageType | number -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, named: NamedValue -): MessageType | number -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, named: NamedValue, plural: number -): MessageType | number -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, named: NamedValue, defaultMsg: string -): MessageType | number -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, key: Path, named: NamedValue, options: TranslateOptions -): MessageType | number -export function translate( - context: RuntimeContext, +): MessageType | number +export function translate( + context: RuntimeContext, ...args: unknown[] -): MessageType | number // for internal +): MessageType | number // for internal // implementationo of `translate` function -export function translate( - context: RuntimeContext, +export function translate( + context: RuntimeContext, ...args: unknown[] -): MessageType | number { +): MessageType | number { const { messages, fallbackFormat, @@ -202,10 +203,14 @@ export function translate( const enableDefaultMsg = fallbackFormat || defaultMsgOrKey !== '' const locale = isString(options.locale) ? options.locale : context.locale - const locales = getLocaleChain(context, fallbackLocale, locale) + const locales = getLocaleChain( + context, + fallbackLocale, + locale + ) // resolve message format - let message: LocaleMessage = {} + let message: LocaleMessageValue = {} let targetLocale: Locale | undefined let format: PathValue = null for (let i = 0; i < locales.length; i++) { @@ -222,19 +227,26 @@ export function translate( }) ) } - message = messages[targetLocale] || {} + message = + ((messages as unknown) as LocaleMessages)[targetLocale] || {} if ((format = resolveValue(message, key)) === null) { // if null, resolve with object key path format = (message as any)[key] // eslint-disable-line @typescript-eslint/no-explicit-any } if (isString(format) || isFunction(format)) break - handleMissing(context, key, targetLocale, missingWarn, 'translate') + handleMissing( + context, + key, + targetLocale, + missingWarn, + 'translate' + ) } let cacheBaseKey = key // if you use default message, set it as message format! - if (!(isString(format) || isMessageFunction(format))) { + if (!(isString(format) || isMessageFunction(format))) { if (enableDefaultMsg) { format = defaultMsgOrKey cacheBaseKey = format @@ -243,10 +255,10 @@ export function translate( // checking message format and target locale if ( - !(isString(format) || isMessageFunction(format)) || + !(isString(format) || isMessageFunction(format)) || !isString(targetLocale) ) { - return unresolving ? NOT_REOSLVED : (key as MessageType) + return unresolving ? NOT_REOSLVED : (key as MessageType) } // setup compile error detecting @@ -257,7 +269,7 @@ export function translate( // compile message format let msg - if (!isMessageFunction(format)) { + if (!isMessageFunction(format)) { msg = messageCompiler( format, getCompileOptions( @@ -279,18 +291,18 @@ export function translate( // if occured compile error, return the message format if (occured) { - return format as MessageType + return format as MessageType } // evaluate message with context - const ctxOptions = getMessageContextOptions( + const ctxOptions = getMessageContextOptions( context, targetLocale, message, options ) - const msgContext = createMessageContext(ctxOptions) - const messaged = (msg as MessageFunction)(msgContext) + const msgContext = createMessageContext(ctxOptions) + const messaged = (msg as MessageFunction)(msgContext) // if use post translation option, procee it with handler return postTranslation ? postTranslation(messaged) : messaged @@ -358,15 +370,15 @@ function getCompileOptions( } as CompileOptions } -function getMessageContextOptions( - context: RuntimeContext, +function getMessageContextOptions( + context: RuntimeContext, locale: Locale, - message: LocaleMessage, + message: LocaleMessageValue, options: TranslateOptions -): MessageContextOptions { +): MessageContextOptions { const { modifiers, pluralRules, messageCompiler } = context - const resolveMessage = (key: string): MessageFunction => { + const resolveMessage = (key: string): MessageFunction => { const val = resolveValue(message, key) if (isString(val)) { let occured = false @@ -383,16 +395,18 @@ function getMessageContextOptions( errorDetector ) ) - return !occured ? msg : (NOOP_MESSAGE_FUNCTION as MessageFunction) - } else if (isMessageFunction(val)) { + return !occured + ? msg + : (NOOP_MESSAGE_FUNCTION as MessageFunction) + } else if (isMessageFunction(val)) { return val } else { // TODO: should be implemented warning message - return NOOP_MESSAGE_FUNCTION as MessageFunction + return NOOP_MESSAGE_FUNCTION as MessageFunction } } - const ctxOptions: MessageContextOptions = { + const ctxOptions: MessageContextOptions = { locale, modifiers, pluralRules, diff --git a/src/directive.ts b/src/directive.ts index b93e96099..a78ae34f4 100644 --- a/src/directive.ts +++ b/src/directive.ts @@ -19,22 +19,27 @@ type VTDirectiveValue = { choice?: number } -function getComposer( - i18n: I18n & I18nInternal, +function getComposer( + i18n: I18n, instance: ComponentInternalInstance -): Composer | null { +): Composer | null { + const i18nInternal = (i18n as unknown) as I18nInternal if (i18n.mode === 'composable') { - return i18n._getComposer(instance) || i18n.global + return (i18nInternal.__getInstance>( + instance + ) || i18n.global) as Composer } else { - const vueI18n = i18n._getLegacy(instance) - return vueI18n != null - ? (vueI18n as VueI18n & VueI18nInternal).__composer - : i18n.global + const vueI18n = i18nInternal.__getInstance>( + instance + ) + return (vueI18n != null + ? ((vueI18n as unknown) as VueI18nInternal).__composer + : i18n.global) as Composer } } -export function vTDirective( - i18n: I18n & I18nInternal +export function vTDirective( + i18n: I18n ): ObjectDirective { const bind = ( el: HTMLElement, diff --git a/src/i18n.ts b/src/i18n.ts index 54de42512..090e57e30 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -8,9 +8,10 @@ import { ComponentOptions, App } from 'vue' +import { LocaleMessageDictionary } from './core/context' import { + VueMessageType, Composer, - ComposerInternal, ComposerOptions, ComposerInternalOptions, createComposer @@ -35,8 +36,8 @@ import { isEmptyObject, warn } from './utils' * so you can specify these options. * */ -export type I18nOptions = I18nAdditionalOptions & - (ComposerOptions | VueI18nOptions) +export type I18nOptions = I18nAdditionalOptions & + (ComposerOptions | VueI18nOptions) /** * I18n Additional Options for `createI18n` @@ -58,7 +59,7 @@ export type I18nMode = 'legacy' | 'composable' /** * I18n interface */ -export interface I18n { +export interface I18n { /** * I18n API mode * @@ -72,7 +73,7 @@ export interface I18n { /** * Global composer */ - readonly global: Composer + readonly global: Composer /** * @internal */ @@ -85,12 +86,20 @@ export interface I18n { * @internal */ export interface I18nInternal { - _getComposer(instance: ComponentInternalInstance): Composer | null - _setComposer(instance: ComponentInternalInstance, composer: Composer): void - _deleteComposer(instance: ComponentInternalInstance): void - _getLegacy(instance: ComponentInternalInstance): VueI18n | null - _setLegacy(instance: ComponentInternalInstance, legacy: VueI18n): void - _deleteLegacy(instance: ComponentInternalInstance): void + __getInstance< + Messages, + Instance extends VueI18n | Composer + >( + component: ComponentInternalInstance + ): Instance | null + __setInstance< + Messages, + Instance extends VueI18n | Composer + >( + component: ComponentInternalInstance, + instance: Instance + ): void + __deleteInstance(component: ComponentInternalInstance): void } /** @@ -105,7 +114,8 @@ export type I18nScope = 'local' | 'parent' | 'global' * `UseI18nOptions` is inherited {@link ComposerAdditionalOptions} and {@link ComposerOptions}, * so you can specify these options. */ -export type UseI18nOptions = ComposerAdditionalOptions & ComposerOptions +export type UseI18nOptions = ComposerAdditionalOptions & + ComposerOptions /** * Composer additional options for `useI18n` @@ -121,9 +131,7 @@ export interface ComposerAdditionalOptions { * I18n instance injectin key * @internal */ -export const I18nSymbol: InjectionKey = Symbol.for( - 'vue-i18n' -) +export const I18nSymbol: InjectionKey = Symbol.for('vue-i18n') /** * I18n factory function @@ -192,10 +200,18 @@ export const I18nSymbol: InjectionKey = Symbol.for( * app.mount('#app') * ``` */ -export function createI18n(options: I18nOptions = {}): I18n { +export function createI18n< + Options extends I18nOptions = {}, + Messages extends Record< + keyof Options['messages'], + LocaleMessageDictionary + > = Record> +>(options: Options = {} as Options): I18n { const __legacyMode = !!options.legacy - const __composers = new Map() - const __legaceis = new Map() + const __instances = new Map< + ComponentInternalInstance, + VueI18n | Composer + >() const __global = __legacyMode ? createVueI18n(options) : createComposer(options) @@ -206,42 +222,38 @@ export function createI18n(options: I18nOptions = {}): I18n { return __legacyMode ? 'legacy' : 'composable' }, install(app: App, ...options: unknown[]): void { - apply(app, i18n, ...options) + apply(app, i18n, ...options) if (__legacyMode) { app.mixin( defineMixin( - __global as VueI18n & VueI18nInternal, - (__global as VueI18n & VueI18nInternal).__composer, - i18n + __global as VueI18n, + ((__global as unknown) as VueI18nInternal) + .__composer as Composer, + i18n as I18nInternal ) ) } }, - get global(): Composer { + get global(): Composer { return __legacyMode - ? (__global as VueI18n & VueI18nInternal).__composer - : (__global as Composer) + ? (((__global as unknown) as VueI18nInternal) + .__composer as Composer) + : (__global as Composer) }, - _getComposer(instance: ComponentInternalInstance): Composer | null { - return __composers.get(instance) || null + __getInstance< + M extends Messages, + Instance extends VueI18n | Composer + >(component: ComponentInternalInstance): Instance | null { + return ((__instances.get(component) as unknown) as Instance) || null }, - _setComposer( - instance: ComponentInternalInstance, - composer: Composer - ): void { - __composers.set(instance, composer) + __setInstance< + M extends Messages, + Instance extends VueI18n | Composer + >(component: ComponentInternalInstance, instance: Instance): void { + __instances.set(component, instance) }, - _deleteComposer(instance: ComponentInternalInstance): void { - __composers.delete(instance) - }, - _getLegacy(instance: ComponentInternalInstance): VueI18n | null { - return __legaceis.get(instance) || null - }, - _setLegacy(instance: ComponentInternalInstance, legacy: VueI18n): void { - __legaceis.set(instance, legacy) - }, - _deleteLegacy(instance: ComponentInternalInstance): void { - __legaceis.delete(instance) + __deleteInstance(component: ComponentInternalInstance): void { + __instances.delete(component) } } @@ -293,8 +305,14 @@ export function createI18n(options: I18nOptions = {}): I18n { * * ``` */ -export function useI18n(options: UseI18nOptions = {}): Composer { - const i18n = inject(I18nSymbol) +export function useI18n< + Options extends UseI18nOptions = object, + Messages extends Record< + keyof Options['messages'], + LocaleMessageDictionary + > = Record> +>(options: Options = {} as Options): Composer { + const i18n = inject(I18nSymbol) as I18n if (!i18n) { throw createI18nError(I18nErrorCodes.NOT_INSLALLED) } @@ -337,10 +355,14 @@ export function useI18n(options: UseI18nOptions = {}): Composer { throw createI18nError(I18nErrorCodes.NOT_AVAILABLE_IN_LEGACY_MODE) } - let composer = i18n._getComposer(instance) + const i18nInternal = (i18n as unknown) as I18nInternal + let composer = i18nInternal.__getInstance>( + instance + ) if (composer == null) { const type = instance.type as ComponentOptions - const composerOptions: ComposerOptions & ComposerInternalOptions = { + const composerOptions: ComposerOptions & + ComposerInternalOptions = { ...options } if (type.__i18n) { @@ -351,29 +373,35 @@ export function useI18n(options: UseI18nOptions = {}): Composer { composerOptions.__root = global } - composer = createComposer(composerOptions) - setupLifeCycle(i18n, instance, composer) + composer = createComposer(composerOptions) as Composer + setupLifeCycle(i18nInternal, instance, composer) - i18n._setComposer(instance, composer) + i18nInternal.__setInstance>(instance, composer) } - return composer as Composer & ComposerInternal + return composer as Composer } -function getComposer( - i18n: I18n & I18nInternal, +function getComposer( + i18n: I18n, target: ComponentInternalInstance -): Composer | null { - let composer: Composer | null = null +): Composer | null { + let composer: Composer | null = null const root = target.root let current: ComponentInternalInstance | null = target.parent while (current != null) { + const i18nInternal = (i18n as unknown) as I18nInternal if (i18n.mode === 'composable') { - composer = i18n._getComposer(current) + composer = i18nInternal.__getInstance>( + current + ) } else { - const vueI18n = i18n._getLegacy(current) + const vueI18n = i18nInternal.__getInstance>( + current + ) if (vueI18n != null) { - composer = (vueI18n as VueI18n & VueI18nInternal).__composer + composer = (vueI18n as VueI18n & VueI18nInternal) + .__composer as Composer } } if (composer != null) { @@ -387,10 +415,10 @@ function getComposer( return composer } -function setupLifeCycle( +function setupLifeCycle( i18n: I18nInternal, target: ComponentInternalInstance, - composer: Composer + composer: Composer ): void { onMounted(() => { // inject composer instance to DOM for intlify-devtools @@ -404,6 +432,6 @@ function setupLifeCycle( if (target.proxy && target.proxy.$el.__intlify__) { delete target.proxy.$el.__intlify__ } - i18n._deleteComposer(target) + i18n.__deleteInstance(target) }, target) } diff --git a/src/legacy.ts b/src/legacy.ts index e10a1012e..05e88089c 100644 --- a/src/legacy.ts +++ b/src/legacy.ts @@ -14,7 +14,6 @@ import { import { Locale, LocaleMessages, - LocaleMessage, LocaleMessageDictionary, PostTranslationHandler, FallbackLocale @@ -50,7 +49,9 @@ import { export type TranslateResult = string export type Choice = number -export type LocaleMessageObject = LocaleMessageDictionary +export type LocaleMessageObject = LocaleMessageDictionary< + Message +> export type PluralizationRulesMap = { [locale: string]: PluralizationRule } export type WarnHtmlInMessageLevel = 'off' | 'warn' | 'error' export type DateTimeFormatResult = string @@ -59,9 +60,9 @@ export interface Formatter { // eslint-disable-next-line @typescript-eslint/no-explicit-any interpolate(message: string, values: any, path: string): Array | null } -export type ComponentInstanceCreatedListener = ( - target: VueI18n, - global: VueI18n +export type ComponentInstanceCreatedListener = ( + target: VueI18n, + global: VueI18n ) => void /** @@ -70,10 +71,12 @@ export type ComponentInstanceCreatedListener = ( * @remarks * This option is compatible with the constructor options of `VueI18n` class (offered with vue-i18n@8.x). */ -export interface VueI18nOptions { +export interface VueI18nOptions { locale?: Locale fallbackLocale?: FallbackLocale - messages?: LocaleMessages + messages?: { + [K in keyof Messages]: LocaleMessageDictionary + } datetimeFormats?: DateTimeFormats numberFormats?: NumberFormats availableLocales?: Locale[] @@ -86,7 +89,9 @@ export interface VueI18nOptions { formatFallbackMessages?: boolean preserveDirectiveContent?: boolean warnHtmlInMessage?: WarnHtmlInMessageLevel - sharedMessages?: LocaleMessages + sharedMessages?: { + [K in keyof Messages]: LocaleMessageDictionary + } pluralizationRules?: PluralizationRules postTranslation?: PostTranslationHandler sync?: boolean @@ -99,12 +104,12 @@ export interface VueI18nOptions { * @remarks * This interface is compatible with interface of `VueI18n` class (offered with vue-i18n@8.x). */ -export interface VueI18n { +export interface VueI18n { // properties locale: Locale fallbackLocale: FallbackLocale readonly availableLocales: Locale[] - readonly messages: LocaleMessages + readonly messages: Messages readonly datetimeFormats: DateTimeFormats readonly numberFormats: NumberFormats formatter: Formatter @@ -134,9 +139,15 @@ export interface VueI18n { tc(key: Path, choice: number, named: Record): TranslateResult tc(...args: unknown[]): TranslateResult // for $tc te(key: Path, locale?: Locale): boolean - getLocaleMessage(locale: Locale): LocaleMessage - setLocaleMessage(locale: Locale, message: LocaleMessage): void - mergeLocaleMessage(locale: Locale, message: LocaleMessage): void + getLocaleMessage(locale: Locale): LocaleMessageDictionary + setLocaleMessage( + locale: Locale, + message: LocaleMessageDictionary + ): void + mergeLocaleMessage( + locale: Locale, + message: LocaleMessageDictionary + ): void d(value: number | Date): DateTimeFormatResult d(value: number | Date, key: string): DateTimeFormatResult d(value: number | Date, key: string, locale: Locale): DateTimeFormatResult @@ -159,10 +170,10 @@ export interface VueI18n { /** * @internal */ -export interface VueI18nInternal { +export interface VueI18nInternal { __id: number - __composer: Composer - __onComponentInstanceCreated(target: VueI18n): void + __composer: Composer + __onComponentInstanceCreated(target: VueI18n): void } /** @@ -170,9 +181,9 @@ export interface VueI18nInternal { * * @internal */ -function convertComposerOptions( - options: VueI18nOptions & ComposerInternalOptions -): ComposerOptions & ComposerInternalOptions { +function convertComposerOptions( + options: VueI18nOptions & ComposerInternalOptions +): ComposerOptions & ComposerInternalOptions { const locale = isString(options.locale) ? options.locale : 'en-US' const fallbackLocale = isString(options.fallbackLocale) || @@ -215,13 +226,15 @@ function convertComposerOptions( let messages = options.messages if (isPlainObject(options.sharedMessages)) { - const sharedMessages = options.sharedMessages + const sharedMessages = options.sharedMessages as LocaleMessages< + VueMessageType + > const locales: Locale[] = Object.keys(sharedMessages) messages = locales.reduce((messages, locale) => { - const message = messages[locale] || { [locale]: {} } + const message = messages[locale] || (messages[locale] = {}) Object.assign(message, sharedMessages[locale]) return messages - }, messages || {}) + }, (messages || {}) as LocaleMessages) as typeof options.messages } const { __i18n, __root } = options @@ -253,10 +266,16 @@ function convertComposerOptions( * * @internal */ -export function createVueI18n( - options: VueI18nOptions & ComposerInternalOptions = {} -): VueI18n { - const composer = createComposer(convertComposerOptions(options)) +export function createVueI18n< + Options extends VueI18nOptions = object, + Messages extends Record< + keyof Options['messages'], + LocaleMessageDictionary + > = Record> +>(options: Options = {} as Options): VueI18n { + const composer = createComposer( + convertComposerOptions(options) + ) as Composer // defines VueI18n const vueI18n = { @@ -281,7 +300,7 @@ export function createVueI18n( }, // messages - get messages(): LocaleMessages { + get messages(): Messages { return composer.messages.value }, @@ -388,7 +407,7 @@ export function createVueI18n( }, // for internal - __id: (composer as Composer & ComposerInternal).__id, + __id: ((composer as unknown) as ComposerInternal).__id, __composer: composer, /** @@ -465,17 +484,23 @@ export function createVueI18n( }, // getLocaleMessage - getLocaleMessage(locale: Locale): LocaleMessage { + getLocaleMessage(locale: Locale): LocaleMessageDictionary { return composer.getLocaleMessage(locale) }, // setLocaleMessage - setLocaleMessage(locale: Locale, message: LocaleMessage): void { + setLocaleMessage( + locale: Locale, + message: LocaleMessageDictionary + ): void { composer.setLocaleMessage(locale, message) }, // mergeLocaleMessasge - mergeLocaleMessage(locale: Locale, message: LocaleMessage): void { + mergeLocaleMessage( + locale: Locale, + message: LocaleMessageDictionary + ): void { composer.mergeLocaleMessage(locale, message) }, @@ -528,10 +553,10 @@ export function createVueI18n( }, // for internal - __onComponentInstanceCreated(target: VueI18n): void { + __onComponentInstanceCreated(target: VueI18n): void { const { componentInstanceCreatedListener } = options if (componentInstanceCreatedListener) { - componentInstanceCreatedListener(target, vueI18n) + componentInstanceCreatedListener(target, vueI18n) } } } diff --git a/src/mixin.ts b/src/mixin.ts index 5f33649b7..22da1e8da 100644 --- a/src/mixin.ts +++ b/src/mixin.ts @@ -138,11 +138,12 @@ declare module '@vue/runtime-core' { } // supports compatibility for legacy vue-i18n APIs -export function defineMixin( - legacy: VueI18n & VueI18nInternal, - composer: Composer, +export function defineMixin( + vuei18n: VueI18n, + composer: Composer, i18n: I18nInternal ): ComponentOptions { + const legacy = (vuei18n as unknown) as VueI18nInternal return { beforeCreate(): void { const instance = getCurrentInstance() @@ -153,8 +154,8 @@ export function defineMixin( const options = this.$options if (options.i18n) { - const optionsI18n = options.i18n as VueI18nOptions & - ComposerInternalOptions + const optionsI18n = options.i18n as VueI18nOptions & + ComposerInternalOptions if (options.__i18n) { optionsI18n.__i18n = options.__i18n } @@ -162,15 +163,21 @@ export function defineMixin( this.$i18n = createVueI18n(optionsI18n) legacy.__onComponentInstanceCreated(this.$i18n) - i18n._setLegacy(instance, this.$i18n) + i18n.__setInstance>( + instance, + this.$i18n as VueI18n + ) } else if (options.__i18n) { this.$i18n = createVueI18n({ - __i18n: options.__i18n, + __i18n: (options as ComposerInternalOptions).__i18n, __root: composer - }) + } as VueI18nOptions) legacy.__onComponentInstanceCreated(this.$i18n) - i18n._setLegacy(instance, this.$i18n) + i18n.__setInstance>( + instance, + this.$i18n as VueI18n + ) } else { // set global this.$i18n = legacy @@ -206,7 +213,7 @@ export function defineMixin( delete this.$d delete this.$n - i18n._deleteLegacy(instance) + i18n.__deleteInstance(instance) delete this.$i18n } } diff --git a/src/plugin.ts b/src/plugin.ts index dab77815a..e70efcb15 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -1,5 +1,5 @@ import { App } from 'vue' -import { I18nSymbol, I18n, I18nInternal } from './i18n' +import { I18nSymbol, I18n } from './i18n' import { Translation, NumberFormat, DatetimeFormat } from './components' import { vTDirective } from './directive' import { I18nWarnCodes, getWarnMessage } from './warnings' @@ -16,9 +16,9 @@ export interface I18nPluginOptions { globalInstall?: boolean } -export function apply( +export function apply( app: App, - i18n: I18n & I18nInternal, + i18n: I18n, ...options: unknown[] ): void { const pluginOptions = isPlainObject(options[0]) @@ -48,7 +48,7 @@ export function apply( } // install directive - app.directive('t', vTDirective(i18n)) + app.directive('t', vTDirective(i18n)) // setup global provider app.provide(I18nSymbol, i18n) diff --git a/test/composer.test.ts b/test/composer.test.ts index c6c2e21bd..529140362 100644 --- a/test/composer.test.ts +++ b/test/composer.test.ts @@ -11,7 +11,7 @@ import { createComposer, MissingHandler, addPreCompileMessages, - Composer, + ComposerOptions, ComposerInternal } from '../src/composer' import { generateFormatCacheKey } from '../src/utils' @@ -833,7 +833,7 @@ describe('getNumberFormat / setNumberFormat / mergeNumberFormat', () => { describe('__i18n', () => { test('default value', () => { - const { messages } = createComposer({ + const options = { __i18n: [ JSON.stringify({ en: { hello: 'Hello,world!' } }), JSON.stringify({ @@ -847,7 +847,10 @@ describe('__i18n', () => { } }) ] - }) + } + const { messages } = createComposer( + options as ComposerOptions + ) expect(messages.value).toEqual({ en: { hello: 'Hello,world!' }, ja: { @@ -862,7 +865,7 @@ describe('__i18n', () => { }) test('locale messages object', () => { - const { messages } = createComposer({ + const options = { __i18n: [ { en: { hello: 'Hello,world!' } }, { @@ -876,7 +879,10 @@ describe('__i18n', () => { } } ] - }) + } + const { messages } = createComposer( + options as ComposerOptions + ) expect(messages.value).toEqual({ en: { hello: 'Hello,world!' }, ja: { @@ -902,7 +908,7 @@ describe('__transrateVNode', () => { } }) expect( - (composer as Composer & ComposerInternal).__transrateVNode('hello', { + ((composer as unknown) as ComposerInternal).__transrateVNode('hello', { name: createVNode(Text, null, 'kazupon', 0) }) ).toMatchObject([ @@ -920,7 +926,7 @@ describe('__transrateVNode', () => { } }) expect( - (composer as Composer & ComposerInternal).__transrateVNode('hello', { + ((composer as unknown) as ComposerInternal).__transrateVNode('hello', { name: createVNode(Text, null, 'kazupon', 0) }) ).toMatchSnapshot() @@ -941,7 +947,7 @@ describe('__numberParts', () => { } }) expect( - (composer as Composer & ComposerInternal).__numberParts(0.99, { + ((composer as unknown) as ComposerInternal).__numberParts(0.99, { key: 'percent', part: true }) @@ -956,7 +962,7 @@ describe('__numberParts', () => { } }) expect( - (composer as Composer & ComposerInternal).__numberParts(0.99, { + ((composer as unknown) as ComposerInternal).__numberParts(0.99, { key: 'percent', part: true }) @@ -983,7 +989,7 @@ describe('__datetimeParts', () => { }) const dt = new Date(Date.UTC(2012, 11, 20, 3, 0, 0)) expect( - (composer as Composer & ComposerInternal).__datetimeParts(dt, { + ((composer as unknown) as ComposerInternal).__datetimeParts(dt, { key: 'short', part: true }) @@ -1011,7 +1017,7 @@ describe('__datetimeParts', () => { }) const dt = new Date(Date.UTC(2012, 11, 20, 3, 0, 0)) expect( - (composer as Composer & ComposerInternal).__datetimeParts(dt, { + ((composer as unknown) as ComposerInternal).__datetimeParts(dt, { key: 'short', part: true }) From f4706b55dbf7abe6cdc23501f80207491a89c259 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Mon, 3 Aug 2020 15:19:39 +0900 Subject: [PATCH 15/20] bump to vue@rc --- package.json | 4 +- src/composer.ts | 2 +- yarn.lock | 118 +++++++++++++++++++++++++++++------------------- 3 files changed, 74 insertions(+), 50 deletions(-) diff --git a/package.json b/package.json index a3b7364d2..6a0d10d69 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "tsd": "^0.13.1", "typescript": "^3.9.7", "typescript-eslint-language-service": "^3.0.0", - "vue": "^3.0.0-beta.15" + "vue": "^3.0.0-rc.5" }, "engines": { "node": ">= 10" @@ -88,7 +88,7 @@ "main": "dist/vue-i18n.cjs.js", "module": "dist/vue-i18n.esm-bundler.js", "peerDependencies": { - "vue": "^3.0.0-beta.15" + "vue": "^3.0.0-rc.5" }, "repository": { "type": "git", diff --git a/src/composer.ts b/src/composer.ts index f8b763b76..3fd9e94af 100644 --- a/src/composer.ts +++ b/src/composer.ts @@ -652,7 +652,7 @@ export function createComposer< // getLocaleMessage const getLocaleMessage = (locale: Locale): LocaleMessageDictionary => - _messages.value[locale] || {} + (_messages.value[locale] || {}) as LocaleMessageDictionary // setLocaleMessage function setLocaleMessage( diff --git a/yarn.lock b/yarn.lock index 8fded25e2..f6b5be513 100644 --- a/yarn.lock +++ b/yarn.lock @@ -121,6 +121,11 @@ dependencies: "@babel/types" "^7.8.3" +"@babel/helper-validator-identifier@^7.10.4": + version "7.10.4" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz#a78c7a7251e01f616512d31b10adcf52ada5e0d2" + integrity sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw== + "@babel/helper-validator-identifier@^7.9.0", "@babel/helper-validator-identifier@^7.9.5": version "7.9.5" resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz#90977a8e6fbf6b431a7dc31752eee233bf052d80" @@ -149,6 +154,11 @@ resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.9.6.tgz#3b1bbb30dabe600cd72db58720998376ff653bc7" integrity sha512-AoeIEJn8vt+d/6+PXDRPaksYhnlbMIiejioBZvvMQsOjW/JYK6k/0dKnvvP3EhK5GfMBWDPtrxRtegWdAcdq9Q== +"@babel/parser@^7.10.4": + version "7.11.0" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.11.0.tgz#a9d7e11aead25d3b422d17b2c6502c8dddef6a5d" + integrity sha512-qvRvi4oI8xii8NllyEc4MDJjuZiNaRzyb7Y7lup1NqJV8TZHF4O27CcP+72WPn/k1zkgJ6WJfnIbk4jTsVAZHw== + "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz#a983fb1aeb2ec3f6ed042a210f640e90e786fe0d" @@ -259,6 +269,15 @@ lodash "^4.17.13" to-fast-properties "^2.0.0" +"@babel/types@^7.10.4": + version "7.11.0" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.11.0.tgz#2ae6bf1ba9ae8c3c43824e5861269871b206e90d" + integrity sha512-O53yME4ZZI0jO1EVGtF1ePGl0LHirG4P1ibcD80XyzZcKhcMFeCXmh4Xb1ifGBIV233Qg12x4rBfQgA+tmOukA== + dependencies: + "@babel/helper-validator-identifier" "^7.10.4" + lodash "^4.17.19" + to-fast-properties "^2.0.0" + "@bcoe/v8-coverage@^0.2.3": version "0.2.3" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" @@ -985,53 +1004,53 @@ dependencies: eslint-visitor-keys "^1.1.0" -"@vue/compiler-core@3.0.0-beta.15": - version "3.0.0-beta.15" - resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.0.0-beta.15.tgz#8710a8e3ba15ba1a8b62bd17609d26bd27fdcc45" - integrity sha512-NLNW7tAMHl8ybRgTPTIWLsi8aXHbFngY2x95eEHAdxhNasTY5NsgmQBBH9TBAUQEn6Wo8ybmuvQoNzgcw979Zg== +"@vue/compiler-core@3.0.0-rc.5": + version "3.0.0-rc.5" + resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.0.0-rc.5.tgz#dd4f1816fcae34a81bc60e584f97993cad284d54" + integrity sha512-dNz5AObEYg0Oglw3emIsBhTAOVfObrfxDaAzR0UTRDDq+Ohfr6KTSaVQAH88Ym+oa08ZlLZBFc6ARe9doAOIxg== dependencies: - "@babel/parser" "^7.8.6" - "@babel/types" "^7.8.6" - "@vue/shared" "3.0.0-beta.15" - estree-walker "^0.8.1" + "@babel/parser" "^7.10.4" + "@babel/types" "^7.10.4" + "@vue/shared" "3.0.0-rc.5" + estree-walker "^2.0.1" source-map "^0.6.1" -"@vue/compiler-dom@3.0.0-beta.15": - version "3.0.0-beta.15" - resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.0.0-beta.15.tgz#ee6dc9ae1dabb5c5c257d7cc20c5f3e95d5e5f4f" - integrity sha512-0qVaCosZ6XrkmlSOndGlNh33JQ2oao82uWxC/qw4QWBGm6a1DcKkZFIZFYLQWg5ZIcSrEQrR1VzUidBaZw9AIg== +"@vue/compiler-dom@3.0.0-rc.5": + version "3.0.0-rc.5" + resolved "https://registry.yarnpkg.com/@vue/compiler-dom/-/compiler-dom-3.0.0-rc.5.tgz#83905e8601123a3654b90fbd80708a16530ce21a" + integrity sha512-z8n+R1GhFnWuKURLYxfVSEfP7nSNM91qteobxwys55fhlZZuReouMnUwgrn+ois/IL6RdFlT9H+n4+N6yLrdJA== dependencies: - "@vue/compiler-core" "3.0.0-beta.15" - "@vue/shared" "3.0.0-beta.15" + "@vue/compiler-core" "3.0.0-rc.5" + "@vue/shared" "3.0.0-rc.5" -"@vue/reactivity@3.0.0-beta.15": - version "3.0.0-beta.15" - resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.0.0-beta.15.tgz#4ee0942783d7ff09acab5b8755706597ba6234f6" - integrity sha512-Xa0LG8RTNlPYsuqOBhhV03xKhMmuSU0vtKXoIi1yxp9gGU7ga/TMmnhELb66AiupiXdLJwRcdv00KhPF/2y0dA== +"@vue/reactivity@3.0.0-rc.5": + version "3.0.0-rc.5" + resolved "https://registry.yarnpkg.com/@vue/reactivity/-/reactivity-3.0.0-rc.5.tgz#45cff8d839d7ad130b1e499239090050fdecff13" + integrity sha512-oe9C+1jtWUdYL/iNc0OPWbwgOk2rOW2uQ+exx3I6Jo6PKOmnAiPkMElalf9vRnO53rnUphVecMp8BlTJvcNgDw== dependencies: - "@vue/shared" "3.0.0-beta.15" + "@vue/shared" "3.0.0-rc.5" -"@vue/runtime-core@3.0.0-beta.15": - version "3.0.0-beta.15" - resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.0.0-beta.15.tgz#35c2ef61dadf07dfe9129dbea6fb8c1b88cc5bd6" - integrity sha512-jDkqSs1hsS9fRCgzah7VINafxWj7bYoDyweVuBqm6KPcHRfGkRZZxl2NltbbVaLH76Qvm4PPSnqGgEx7QtFSgg== +"@vue/runtime-core@3.0.0-rc.5": + version "3.0.0-rc.5" + resolved "https://registry.yarnpkg.com/@vue/runtime-core/-/runtime-core-3.0.0-rc.5.tgz#dd59af3a5fc089d1cdc05a657320c0dc17e5c362" + integrity sha512-MRIWreFigxdRuI2moFociUL5rVBfgYPrT7rWfQ0XfOyW46b+AiuCJyZvgbsRXwkAERfW1Tb/mY5forYjX2thOg== dependencies: - "@vue/reactivity" "3.0.0-beta.15" - "@vue/shared" "3.0.0-beta.15" + "@vue/reactivity" "3.0.0-rc.5" + "@vue/shared" "3.0.0-rc.5" -"@vue/runtime-dom@3.0.0-beta.15": - version "3.0.0-beta.15" - resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.0.0-beta.15.tgz#e3ce740c5e3766020719b174686bd65c75975c7e" - integrity sha512-161rUw1sWfbv51Ua8gKXaPc+seRJQcV+MLokTJtqYtNCajya0Mx6vdXJajBWqjDT8/Udx0sb7Wm/K/0DfGBUTw== +"@vue/runtime-dom@3.0.0-rc.5": + version "3.0.0-rc.5" + resolved "https://registry.yarnpkg.com/@vue/runtime-dom/-/runtime-dom-3.0.0-rc.5.tgz#2fd75a1f29b23abf0ffe5ccdedabda11721c5b5b" + integrity sha512-0jwpO3MBqMToq7qC816Z8Y6G8aN4ZKbv7MupgRaepzxhiK0sXcjLQmOATP3g/NyX52UCBJS4wAwsxidqGnAabA== dependencies: - "@vue/runtime-core" "3.0.0-beta.15" - "@vue/shared" "3.0.0-beta.15" + "@vue/runtime-core" "3.0.0-rc.5" + "@vue/shared" "3.0.0-rc.5" csstype "^2.6.8" -"@vue/shared@3.0.0-beta.15": - version "3.0.0-beta.15" - resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.0.0-beta.15.tgz#77444ab234e229c3fdcc9f394678e167a55757af" - integrity sha512-wViILT5GgxMtnXVQ1xupj43wvnZ41g3NLWaBObs7l+eTxz5vq5yx72qH6HRpsfhR2Mg39jE0cfNLFEpC4lJIUQ== +"@vue/shared@3.0.0-rc.5": + version "3.0.0-rc.5" + resolved "https://registry.yarnpkg.com/@vue/shared/-/shared-3.0.0-rc.5.tgz#cea2378e3e37363ddc1f5dd158edc9c9b5b3fff0" + integrity sha512-ZhcgGzBpp+pUzisZgQpM4ctIGgLpYjBj7/rZfbhEPxFHF/BuTV2jmhXvAl8aF9xDAejIcw85xCy92gDSwKtPag== JSONStream@^1.0.4: version "1.3.5" @@ -2715,16 +2734,16 @@ estraverse@^5.1.0: resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.1.0.tgz#374309d39fd935ae500e7b92e8a6b4c720e59642" integrity sha512-FyohXK+R0vE+y1nHLoBM7ZTyqRpqAlhdZHCWIWEviFLiGB8b04H6bQs8G+XTthacvT8VuwvteiP7RJSxMs8UEw== -estree-walker@^0.8.1: - version "0.8.1" - resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.8.1.tgz#6230ce2ec9a5cb03888afcaf295f97d90aa52b79" - integrity sha512-H6cJORkqvrNziu0KX2hqOMAlA2CiuAxHeGJXSIoKA/KLv229Dw806J3II6mKTm5xiDX1At1EXCfsOQPB+tMB+g== - estree-walker@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700" integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg== +estree-walker@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.1.tgz#f8e030fb21cefa183b44b7ad516b747434e7a3e0" + integrity sha512-tF0hv+Yi2Ot1cwj9eYHtxC0jB9bmjacjQs6ZBTj82H8JwUywFuc+7E83NWfNMwHXZc11mjfFcVXPe9gEP4B8dg== + esutils@^2.0.2: version "2.0.3" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" @@ -4805,6 +4824,11 @@ lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@~4.17 resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== +lodash@^4.17.19: + version "4.17.19" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" + integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== + log-symbols@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.0.0.tgz#69b3cc46d20f448eccdb75ea1fa733d9e821c920" @@ -7522,14 +7546,14 @@ vue-eslint-parser@^7.0.0: esquery "^1.0.1" lodash "^4.17.15" -vue@^3.0.0-beta.15: - version "3.0.0-beta.15" - resolved "https://registry.yarnpkg.com/vue/-/vue-3.0.0-beta.15.tgz#99f107534755d3a237b51fc1279c43af2fefde6e" - integrity sha512-KTmvfNpkvD6mao8vloqjUMjrHEivS1HZvHmYeHPRHqU2HRvNcrZuwXYvETt3dGOTu0Oj7zAWQXP+uZ34CW75sw== +vue@^3.0.0-rc.5: + version "3.0.0-rc.5" + resolved "https://registry.yarnpkg.com/vue/-/vue-3.0.0-rc.5.tgz#973175d45a892b3bd23ef5de7faa4add9c66275f" + integrity sha512-8t8Y4sHMBGD5iLZ7JfBGmKBJlzesPoL+/nW9EV8s+4LwnKC4rGlRp+Lj2rcign4iQaj0GFaL7DrQ8IoOfVX6+w== dependencies: - "@vue/compiler-dom" "3.0.0-beta.15" - "@vue/runtime-dom" "3.0.0-beta.15" - "@vue/shared" "3.0.0-beta.15" + "@vue/compiler-dom" "3.0.0-rc.5" + "@vue/runtime-dom" "3.0.0-rc.5" + "@vue/shared" "3.0.0-rc.5" w3c-hr-time@^1.0.2: version "1.0.2" From 12537f2c241549daf3e31de401b9eea2f2740eb8 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Tue, 4 Aug 2020 00:27:47 +0900 Subject: [PATCH 16/20] split runtime context --- src/composer.ts | 158 +++++++++++++++++++++++++------------- src/core/context.ts | 119 +++++++++++++++++++++++------ src/core/datetime.ts | 40 +++++----- src/core/number.ts | 40 +++++----- src/core/translate.ts | 48 +++++------- src/directive.ts | 40 ++++++---- src/i18n.ts | 171 ++++++++++++++++++++++++++++++------------ src/legacy.ts | 71 ++++++++++++------ src/mixin.ts | 36 ++++++--- src/plugin.ts | 9 ++- test/composer.test.ts | 7 +- 11 files changed, 502 insertions(+), 237 deletions(-) diff --git a/src/composer.ts b/src/composer.ts index 3fd9e94af..b13915d1a 100644 --- a/src/composer.ts +++ b/src/composer.ts @@ -19,8 +19,8 @@ import { import { WritableComputedRef, ComputedRef } from '@vue/reactivity' import { Path, parse as parsePath } from './path' import { - DateTimeFormats, - NumberFormats, + DateTimeFormats as DateTimeFormatsType, + NumberFormats as NumberFormatsType, DateTimeFormat, NumberFormat } from './core/types' @@ -37,9 +37,12 @@ import { LocaleMessages, createRuntimeContext, RuntimeContext, + RuntimeCommonContext, + RuntimeTranslationContext, + RuntimeDateTimeContext, + RuntimeNumberContext, RuntimeMissingHandler, RuntimeOptions, - LocaleMessageValue, LocaleMessageDictionary, PostTranslationHandler, MISSING_RESOLVE_VALUE, @@ -108,15 +111,13 @@ export type CustomBlocks = * @remarks * This is options to create composer. */ -export interface ComposerOptions { +export interface ComposerOptions { locale?: Locale fallbackLocale?: FallbackLocale inheritLocale?: boolean - messages?: { - [K in keyof Messages]: LocaleMessageDictionary - } - datetimeFormats?: DateTimeFormats - numberFormats?: NumberFormats + messages?: LocaleMessages + datetimeFormats?: DateTimeFormatsType + numberFormats?: NumberFormatsType modifiers?: LinkedModifiers pluralRules?: PluralizationRules missing?: MissingHandler @@ -131,9 +132,14 @@ export interface ComposerOptions { /** * @internal */ -export interface ComposerInternalOptions { +export interface ComposerInternalOptions< + Messages = {}, + DateTimeFormats = {}, + NumberFormats = {}, + Message = VueMessageType +> { __i18n?: CustomBlocks - __root?: Composer + __root?: Composer } /** @@ -142,7 +148,12 @@ export interface ComposerInternalOptions { * @remarks * This is the interface for being used for Vue 3 Composition API. */ -export interface Composer { +export interface Composer< + Messages = {}, + DateTimeFormats = {}, + NumberFormats = {}, + Message = VueMessageType +> { // properties locale: WritableComputedRef fallbackLocale: WritableComputedRef @@ -221,11 +232,11 @@ type ComposerWarnType = 'translate' | 'number format' | 'datetime format' let composerID = 0 -function defineRuntimeMissingHandler( +function defineRuntimeMissingHandler( missing: MissingHandler ): RuntimeMissingHandler { return (( - ctx: RuntimeContext, + ctx: RuntimeCommonContext, locale: Locale, key: Path, type: string @@ -237,10 +248,12 @@ function defineRuntimeMissingHandler( // TODO: maybe, we need to improve type definitions function getLocaleMessages< Messages extends LocaleMessages, + DateTimeFormats extends DateTimeFormatsType, + NumberFormats extends NumberFormatsType, Message = VueMessageType >( - options: ComposerOptions & - ComposerInternalOptions, + options: ComposerOptions & + ComposerInternalOptions, locale: Locale ): LocaleMessages { const { messages, __i18n } = options @@ -310,13 +323,33 @@ export function addPreCompileMessages( */ export function createComposer< Message = VueMessageType, - Options extends ComposerOptions = object, + Options extends ComposerOptions = object, Messages extends Record< keyof Options['messages'], LocaleMessageDictionary - > = Record> ->(options: Options = {} as Options): Composer { - const { __root } = options as ComposerInternalOptions + > = Record>, + DateTimeFormats extends Record< + keyof Options['datetimeFormats'], + DateTimeFormat + > = Record, + NumberFormats extends Record< + keyof Options['numberFormats'], + NumberFormat + > = Record +>( + options: Options = {} as Options +): Composer< + Options['messages'], + Options['datetimeFormats'], + Options['numberFormats'], + Message +> { + const { __root } = options as ComposerInternalOptions< + Messages, + DateTimeFormats, + NumberFormats, + Message + > const _isGlobal = __root === undefined let _inheritLocale = isBoolean(options.inheritLocale) @@ -345,16 +378,19 @@ export function createComposer< ) const _messages = ref>( - getLocaleMessages(options, _locale.value) + getLocaleMessages( + options, + _locale.value + ) ) - const _datetimeFormats = ref( + const _datetimeFormats = ref( isPlainObject(options.datetimeFormats) ? options.datetimeFormats : { [_locale.value]: {} } ) - const _numberFormats = ref( + const _numberFormats = ref( isPlainObject(options.numberFormats) ? options.numberFormats : { [_locale.value]: {} } @@ -385,7 +421,7 @@ export function createComposer< // runtime missing let _missing = isFunction(options.missing) ? options.missing : null let _runtimeMissing = isFunction(options.missing) - ? defineRuntimeMissingHandler(options.missing) + ? defineRuntimeMissingHandler(options.missing) : null // postTranslation handler @@ -409,14 +445,23 @@ export function createComposer< const _pluralRules = options.pluralRules // runtime context - let _context: RuntimeContext // eslint-disable-line prefer-const - function getRuntimeContext(): RuntimeContext { + // eslint-disable-next-line prefer-const + let _context: RuntimeContext< + Messages, + DateTimeFormats, + NumberFormats, + Message + > + function getRuntimeContext(): RuntimeContext< + Messages, + DateTimeFormats, + NumberFormats, + Message + > { return createRuntimeContext({ locale: _locale.value, fallbackLocale: _fallbackLocale.value, - messages: _messages.value as { - [K in keyof Messages]: LocaleMessageValue - }, + messages: _messages.value, datetimeFormats: _datetimeFormats.value, numberFormats: _numberFormats.value, modifiers: _modifiers, @@ -434,14 +479,15 @@ export function createComposer< __numberFormatters: isPlainObject(_context) ? ((_context as unknown) as RuntimeInternalContext).__numberFormatters : undefined - } as RuntimeOptions) as RuntimeContext + } as RuntimeOptions) as RuntimeContext< + Messages, + DateTimeFormats, + NumberFormats, + Message + > } _context = getRuntimeContext() - updateFallbackLocale( - _context, - _locale.value, - _fallbackLocale.value - ) + updateFallbackLocale(_context, _locale.value, _fallbackLocale.value) /*! * define properties @@ -470,10 +516,14 @@ export function createComposer< const messages = computed(() => _messages.value as Messages) // datetimeFormats - const datetimeFormats = computed(() => _datetimeFormats.value) + const datetimeFormats = computed( + () => _datetimeFormats.value as DateTimeFormats + ) // numberFormats - const numberFormats = computed(() => _numberFormats.value) + const numberFormats = computed( + () => _numberFormats.value as NumberFormats + ) /** * define methods @@ -545,7 +595,7 @@ export function createComposer< return defineComputed( context => translate( - context as RuntimeContext, + context as RuntimeTranslationContext, ...args ), () => parseTranslateArgs(...args)[0], @@ -560,8 +610,8 @@ export function createComposer< function d(...args: unknown[]): string { return defineComputed( context => - datetime( - context as RuntimeContext, + datetime( + context as RuntimeDateTimeContext, ...args ), () => parseDateTimeArgs(...args)[0], @@ -576,8 +626,8 @@ export function createComposer< function n(...args: unknown[]): string { return defineComputed( context => - number( - context as RuntimeContext, + number( + context as RuntimeNumberContext, ...args ), () => parseNumberArgs(...args)[0], @@ -608,7 +658,7 @@ export function createComposer< context => { let ret: unknown try { - const _context = context as RuntimeContext + const _context = context as RuntimeTranslationContext _context.processor = processor ret = translate(_context, ...args) } finally { @@ -682,8 +732,8 @@ export function createComposer< // setDateTimeFormat function setDateTimeFormat(locale: Locale, format: DateTimeFormat): void { _datetimeFormats.value[locale] = format - _context.datetimeFormats = _datetimeFormats.value - clearDateTimeFormat(_context, locale, format) + _context.datetimeFormats = _datetimeFormats.value as typeof _context.datetimeFormats + clearDateTimeFormat(_context, locale, format) } // mergeDateTimeFormat @@ -692,8 +742,8 @@ export function createComposer< _datetimeFormats.value[locale] || {}, format ) - _context.datetimeFormats = _datetimeFormats.value - clearDateTimeFormat(_context, locale, format) + _context.datetimeFormats = _datetimeFormats.value as typeof _context.datetimeFormats + clearDateTimeFormat(_context, locale, format) } // getNumberFormat @@ -703,8 +753,8 @@ export function createComposer< // setNumberFormat function setNumberFormat(locale: Locale, format: NumberFormat): void { _numberFormats.value[locale] = format - _context.numberFormats = _numberFormats.value - clearNumberFormat(_context, locale, format) + _context.numberFormats = _numberFormats.value as typeof _context.numberFormats + clearNumberFormat(_context, locale, format) } // mergeNumberFormat @@ -713,8 +763,8 @@ export function createComposer< _numberFormats.value[locale] || {}, format ) - _context.numberFormats = _numberFormats.value - clearNumberFormat(_context, locale, format) + _context.numberFormats = _numberFormats.value as typeof _context.numberFormats + clearNumberFormat(_context, locale, format) } // for debug @@ -726,7 +776,7 @@ export function createComposer< if (_inheritLocale) { _locale.value = val _context.locale = val - updateFallbackLocale( + updateFallbackLocale( _context, _locale.value, _fallbackLocale.value @@ -737,7 +787,7 @@ export function createComposer< if (_inheritLocale) { _fallbackLocale.value = val _context.fallbackLocale = val - updateFallbackLocale( + updateFallbackLocale( _context, _locale.value, _fallbackLocale.value @@ -759,7 +809,7 @@ export function createComposer< if (val && __root) { _locale.value = __root.locale.value _fallbackLocale.value = __root.fallbackLocale.value - updateFallbackLocale( + updateFallbackLocale( _context, _locale.value, _fallbackLocale.value diff --git a/src/core/context.ts b/src/core/context.ts index 0feb0dc92..0508d46b2 100644 --- a/src/core/context.ts +++ b/src/core/context.ts @@ -19,7 +19,7 @@ import { isPlainObject, isObject } from '../utils' -import { DateTimeFormats, NumberFormats } from './types' +import { NumberFormat, DateTimeFormat } from './types' // eslint-disable-next-line @typescript-eslint/no-explicit-any type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ( @@ -55,8 +55,8 @@ export type LocaleMessages = Record< type NestedPath = { [K in keyof T]: T[K] } export type RuntimeMissingType = 'translate' | 'datetime' | 'number' -export type RuntimeMissingHandler = ( - context: RuntimeContext, +export type RuntimeMissingHandler = ( + context: RuntimeCommonContext, locale: Locale, key: Path, type: RuntimeMissingType, @@ -71,12 +71,15 @@ export type MessageCompiler = ( options?: CompileOptions ) => MessageFunction -export interface RuntimeOptions { +export interface RuntimeOptions< + Messages = {}, + DateTimeFormats = {}, + NumberFormats = {}, + Message = string +> { locale?: Locale fallbackLocale?: FallbackLocale - messages?: { - [K in keyof Messages]: LocaleMessageDictionary - } + messages?: LocaleMessages datetimeFormats?: DateTimeFormats numberFormats?: NumberFormats modifiers?: LinkedModifiers @@ -98,7 +101,55 @@ export interface RuntimeInternalOptions { __numberFormatters?: Map } -export interface RuntimeContext { +export interface RuntimeCommonContext { + locale: Locale + fallbackLocale: FallbackLocale + missing: RuntimeMissingHandler | null + missingWarn: boolean | RegExp + fallbackWarn: boolean | RegExp + fallbackFormat: boolean + unresolving: boolean + onWarn(msg: string, err?: Error): void +} + +export interface RuntimeTranslationContext + extends RuntimeCommonContext { + messages: Messages + modifiers: LinkedModifiers + pluralRules?: PluralizationRules + postTranslation: PostTranslationHandler | null + processor: MessageProcessor | null + warnHtmlMessage: boolean + messageCompiler: MessageCompiler +} + +export interface RuntimeDateTimeContext + extends RuntimeCommonContext { + datetimeFormats: DateTimeFormats +} + +export interface RuntimeNumberContext + extends RuntimeCommonContext { + numberFormats: NumberFormats +} + +export interface RuntimeContext< + Messages = {}, + DateTimeFormats = {}, + NumberFormats = {}, + Message = string +> + extends RuntimeTranslationContext, + RuntimeDateTimeContext, + RuntimeNumberContext {} + +/* +export interface RuntimeContext< + Messages = {}, + DateTimeFormats = {}, + NumberFormats = {}, + Message = string +> { locale: Locale fallbackLocale: FallbackLocale messages: Messages @@ -117,6 +168,7 @@ export interface RuntimeContext { messageCompiler: MessageCompiler onWarn(msg: string, err?: Error): void } +*/ export interface RuntimeInternalContext { __datetimeFormatters: Map @@ -145,14 +197,32 @@ function getDefaultLinkedModifiers(): LinkedModifiers< export function createRuntimeContext< Message = string, - Options extends RuntimeOptions = object, + Options extends RuntimeOptions< + Messages, + DateTimeFormats, + NumberFormats, + Message + > = object, Messages extends Record< keyof Options['messages'], LocaleMessageDictionary - > = Record> + > = Record>, + DateTimeFormats extends Record< + keyof Options['datetimeFormats'], + DateTimeFormat + > = Record, + NumberFormats extends Record< + keyof Options['numberFormats'], + NumberFormat + > = Record >( options: Options = {} as Options -): RuntimeContext { +): RuntimeContext< + Options['messages'], + Options['datetimeFormats'], + Options['numberFormats'], + Message +> { // setup options const locale = isString(options.locale) ? options.locale : 'en-US' const fallbackLocale = @@ -167,10 +237,10 @@ export function createRuntimeContext< : ({ [locale]: {} } as Messages) const datetimeFormats = isPlainObject(options.datetimeFormats) ? options.datetimeFormats - : { [locale]: {} } + : ({ [locale]: {} } as DateTimeFormats) const numberFormats = isPlainObject(options.numberFormats) ? options.numberFormats - : { [locale]: {} } + : ({ [locale]: {} } as NumberFormats) const modifiers = Object.assign( {} as LinkedModifiers, options.modifiers || ({} as LinkedModifiers), @@ -229,7 +299,12 @@ export function createRuntimeContext< onWarn, __datetimeFormatters, __numberFormatters - } as RuntimeContext + } as RuntimeContext< + Options['messages'], + Options['datetimeFormats'], + Options['numberFormats'], + Message + > return context } @@ -248,8 +323,8 @@ export function isTranslateMissingWarn( return missing instanceof RegExp ? missing.test(key) : missing } -export function handleMissing( - context: RuntimeContext, +export function handleMissing( + context: RuntimeCommonContext, key: Path, locale: Locale, missingWarn: boolean | RegExp, @@ -257,7 +332,7 @@ export function handleMissing( ): unknown { const { missing, onWarn } = context if (missing !== null) { - const ret = missing(context, locale, key, type) + const ret = missing(context, locale, key, type) return isString(ret) ? ret : key } else { if (__DEV__ && isTranslateMissingWarn(missingWarn, key)) { @@ -267,8 +342,8 @@ export function handleMissing( } } -export function getLocaleChain( - ctx: RuntimeContext, +export function getLocaleChain( + ctx: RuntimeCommonContext, fallback: FallbackLocale, start: Locale = '' ): Locale[] { @@ -369,12 +444,12 @@ function appendItemToChain( return follow } -export function updateFallbackLocale( - ctx: RuntimeContext, +export function updateFallbackLocale( + ctx: RuntimeCommonContext, locale: Locale, fallback: FallbackLocale ): void { const context = (ctx as unknown) as RuntimeInternalContext context.__localeChainCache = new Map() - getLocaleChain(ctx, fallback, locale) + getLocaleChain(ctx, fallback, locale) } diff --git a/src/core/datetime.ts b/src/core/datetime.ts index 444f0e21a..b26e82b49 100644 --- a/src/core/datetime.ts +++ b/src/core/datetime.ts @@ -1,6 +1,11 @@ -import { Availabilities, DateTimeFormat, DateTimeFormatOptions } from './types' import { - RuntimeContext, + Availabilities, + DateTimeFormat, + DateTimeFormats as DateTimeFormatsType, + DateTimeFormatOptions +} from './types' +import { + RuntimeDateTimeContext, Locale, getLocaleChain, handleMissing, @@ -69,34 +74,34 @@ export type DateTimeOptions = { } // `datetime` function overloads -export function datetime( - context: RuntimeContext, +export function datetime( + context: RuntimeDateTimeContext, value: number | Date ): string | number | Intl.DateTimeFormatPart[] -export function datetime( - context: RuntimeContext, +export function datetime( + context: RuntimeDateTimeContext, value: number | Date, key: string ): string | number | Intl.DateTimeFormatPart[] -export function datetime( - context: RuntimeContext, +export function datetime( + context: RuntimeDateTimeContext, value: number | Date, key: string, locale: Locale ): string | number | Intl.DateTimeFormatPart[] -export function datetime( - context: RuntimeContext, +export function datetime( + context: RuntimeDateTimeContext, value: number | Date, options: DateTimeOptions ): string | number | Intl.DateTimeFormatPart[] -export function datetime( - context: RuntimeContext, +export function datetime( + context: RuntimeDateTimeContext, ...args: unknown[] ): string | number | Intl.DateTimeFormatPart[] // for internal // implementation of `datetime` function -export function datetime( - context: RuntimeContext, +export function datetime( + context: RuntimeDateTimeContext, ...args: unknown[] ): string | number | Intl.DateTimeFormatPart[] { const { datetimeFormats, unresolving, fallbackLocale, onWarn } = context @@ -142,7 +147,8 @@ export function datetime( }) ) } - datetimeFormat = datetimeFormats[targetLocale] || {} + datetimeFormat = + ((datetimeFormats as unknown) as DateTimeFormatsType)[targetLocale] || {} format = datetimeFormat[key] if (isPlainObject(format)) break handleMissing(context, key, targetLocale, missingWarn, 'datetime') @@ -200,8 +206,8 @@ export function parseDateTimeArgs( return [options.key || '', value, options, orverrides] } -export function clearDateTimeFormat( - ctx: RuntimeContext, +export function clearDateTimeFormat( + ctx: RuntimeDateTimeContext, locale: Locale, format: DateTimeFormat ): void { diff --git a/src/core/number.ts b/src/core/number.ts index d60b42b4b..3ce76cce2 100644 --- a/src/core/number.ts +++ b/src/core/number.ts @@ -1,6 +1,11 @@ -import { Availabilities, NumberFormat, NumberFormatOptions } from './types' import { - RuntimeContext, + Availabilities, + NumberFormat, + NumberFormats as NumberFormatsType, + NumberFormatOptions +} from './types' +import { + RuntimeNumberContext, Locale, getLocaleChain, handleMissing, @@ -67,34 +72,34 @@ export type NumberOptions = { } // `number` function overloads -export function number( - context: RuntimeContext, +export function number( + context: RuntimeNumberContext, value: number ): string | number | Intl.NumberFormatPart[] -export function number( - context: RuntimeContext, +export function number( + context: RuntimeNumberContext, value: number, key: string ): string | number | Intl.NumberFormatPart[] -export function number( - context: RuntimeContext, +export function number( + context: RuntimeNumberContext, value: number, key: string, locale: Locale ): string | number | Intl.NumberFormatPart[] -export function number( - context: RuntimeContext, +export function number( + context: RuntimeNumberContext, value: number, options: NumberOptions ): string | number | Intl.NumberFormatPart[] -export function number( - context: RuntimeContext, +export function number( + context: RuntimeNumberContext, ...args: unknown[] ): string | number | Intl.NumberFormatPart[] // for internal // implementation of `number` function -export function number( - context: RuntimeContext, +export function number( + context: RuntimeNumberContext, ...args: unknown[] ): string | number | Intl.NumberFormatPart[] { const { numberFormats, unresolving, fallbackLocale, onWarn } = context @@ -138,7 +143,8 @@ export function number( }) ) } - numberFormat = numberFormats[targetLocale] || {} + numberFormat = + ((numberFormats as unknown) as NumberFormatsType)[targetLocale] || {} format = numberFormat[key] if (isPlainObject(format)) break handleMissing(context, key, targetLocale, missingWarn, 'number') @@ -196,8 +202,8 @@ export function parseNumberArgs( return [options.key || '', value, options, orverrides] } -export function clearNumberFormat( - ctx: RuntimeContext, +export function clearNumberFormat( + ctx: RuntimeNumberContext, locale: Locale, format: NumberFormat ): void { diff --git a/src/core/translate.ts b/src/core/translate.ts index 5d59028b7..96b3f424d 100644 --- a/src/core/translate.ts +++ b/src/core/translate.ts @@ -11,7 +11,7 @@ import { } from '../message/runtime' import { Locale, - RuntimeContext, + RuntimeTranslationContext, isTrarnslateFallbackWarn, handleMissing, LocaleMessageValue, @@ -90,85 +90,85 @@ export type TranslateOptions = { // `translate` function overloads export function translate( - context: RuntimeContext, + context: RuntimeTranslationContext, key: Path ): MessageType | number export function translate( - context: RuntimeContext, + context: RuntimeTranslationContext, key: Path, plural: number ): MessageType | number export function translate( - context: RuntimeContext, + context: RuntimeTranslationContext, key: Path, plural: number, options: TranslateOptions ): MessageType | number export function translate( - context: RuntimeContext, + context: RuntimeTranslationContext, key: Path, defaultMsg: string ): MessageType | number export function translate( - context: RuntimeContext, + context: RuntimeTranslationContext, key: Path, defaultMsg: string, options: TranslateOptions ): MessageType | number export function translate( - context: RuntimeContext, + context: RuntimeTranslationContext, key: Path, list: unknown[] ): MessageType | number export function translate( - context: RuntimeContext, + context: RuntimeTranslationContext, key: Path, list: unknown[], plural: number ): MessageType | number export function translate( - context: RuntimeContext, + context: RuntimeTranslationContext, key: Path, list: unknown[], defaultMsg: string ): MessageType | number export function translate( - context: RuntimeContext, + context: RuntimeTranslationContext, key: Path, list: unknown[], options: TranslateOptions ): MessageType | number export function translate( - context: RuntimeContext, + context: RuntimeTranslationContext, key: Path, named: NamedValue ): MessageType | number export function translate( - context: RuntimeContext, + context: RuntimeTranslationContext, key: Path, named: NamedValue, plural: number ): MessageType | number export function translate( - context: RuntimeContext, + context: RuntimeTranslationContext, key: Path, named: NamedValue, defaultMsg: string ): MessageType | number export function translate( - context: RuntimeContext, + context: RuntimeTranslationContext, key: Path, named: NamedValue, options: TranslateOptions ): MessageType | number export function translate( - context: RuntimeContext, + context: RuntimeTranslationContext, ...args: unknown[] ): MessageType | number // for internal // implementationo of `translate` function export function translate( - context: RuntimeContext, + context: RuntimeTranslationContext, ...args: unknown[] ): MessageType | number { const { @@ -203,11 +203,7 @@ export function translate( const enableDefaultMsg = fallbackFormat || defaultMsgOrKey !== '' const locale = isString(options.locale) ? options.locale : context.locale - const locales = getLocaleChain( - context, - fallbackLocale, - locale - ) + const locales = getLocaleChain(context, fallbackLocale, locale) // resolve message format let message: LocaleMessageValue = {} @@ -234,13 +230,7 @@ export function translate( format = (message as any)[key] // eslint-disable-line @typescript-eslint/no-explicit-any } if (isString(format) || isFunction(format)) break - handleMissing( - context, - key, - targetLocale, - missingWarn, - 'translate' - ) + handleMissing(context, key, targetLocale, missingWarn, 'translate') } let cacheBaseKey = key @@ -371,7 +361,7 @@ function getCompileOptions( } function getMessageContextOptions( - context: RuntimeContext, + context: RuntimeTranslationContext, locale: Locale, message: LocaleMessageValue, options: TranslateOptions diff --git a/src/directive.ts b/src/directive.ts index a78ae34f4..285e989b3 100644 --- a/src/directive.ts +++ b/src/directive.ts @@ -19,27 +19,41 @@ type VTDirectiveValue = { choice?: number } -function getComposer( - i18n: I18n, +function getComposer( + i18n: I18n, instance: ComponentInternalInstance -): Composer | null { +): Composer | null { const i18nInternal = (i18n as unknown) as I18nInternal if (i18n.mode === 'composable') { - return (i18nInternal.__getInstance>( - instance - ) || i18n.global) as Composer + return (i18nInternal.__getInstance< + Messages, + DateTimeFormats, + NumberFormats, + Composer + >(instance) || i18n.global) as Composer< + Messages, + DateTimeFormats, + NumberFormats + > } else { - const vueI18n = i18nInternal.__getInstance>( - instance - ) + const vueI18n = i18nInternal.__getInstance< + Messages, + DateTimeFormats, + NumberFormats, + VueI18n + >(instance) return (vueI18n != null - ? ((vueI18n as unknown) as VueI18nInternal).__composer - : i18n.global) as Composer + ? ((vueI18n as unknown) as VueI18nInternal< + Messages, + DateTimeFormats, + NumberFormats + >).__composer + : i18n.global) as Composer } } -export function vTDirective( - i18n: I18n +export function vTDirective( + i18n: I18n ): ObjectDirective { const bind = ( el: HTMLElement, diff --git a/src/i18n.ts b/src/i18n.ts index 090e57e30..8494cf0c2 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -9,6 +9,7 @@ import { App } from 'vue' import { LocaleMessageDictionary } from './core/context' +import { DateTimeFormat, NumberFormat } from './core/types' import { VueMessageType, Composer, @@ -36,8 +37,8 @@ import { isEmptyObject, warn } from './utils' * so you can specify these options. * */ -export type I18nOptions = I18nAdditionalOptions & - (ComposerOptions | VueI18nOptions) +export type I18nOptions = I18nAdditionalOptions & + (ComposerOptions | VueI18nOptions) /** * I18n Additional Options for `createI18n` @@ -59,7 +60,7 @@ export type I18nMode = 'legacy' | 'composable' /** * I18n interface */ -export interface I18n { +export interface I18n { /** * I18n API mode * @@ -73,7 +74,7 @@ export interface I18n { /** * Global composer */ - readonly global: Composer + readonly global: Composer /** * @internal */ @@ -88,13 +89,21 @@ export interface I18n { export interface I18nInternal { __getInstance< Messages, - Instance extends VueI18n | Composer + DateTimeFormats, + NumberFormats, + Instance extends + | VueI18n + | Composer >( component: ComponentInternalInstance ): Instance | null __setInstance< Messages, - Instance extends VueI18n | Composer + DateTimeFormats, + NumberFormats, + Instance extends + | VueI18n + | Composer >( component: ComponentInternalInstance, instance: Instance @@ -114,8 +123,7 @@ export type I18nScope = 'local' | 'parent' | 'global' * `UseI18nOptions` is inherited {@link ComposerAdditionalOptions} and {@link ComposerOptions}, * so you can specify these options. */ -export type UseI18nOptions = ComposerAdditionalOptions & - ComposerOptions +export type UseI18nOptions = ComposerAdditionalOptions & ComposerOptions /** * Composer additional options for `useI18n` @@ -201,12 +209,29 @@ export const I18nSymbol: InjectionKey = Symbol.for('vue-i18n') * ``` */ export function createI18n< - Options extends I18nOptions = {}, + Options extends I18nOptions = {}, Messages extends Record< keyof Options['messages'], LocaleMessageDictionary - > = Record> ->(options: Options = {} as Options): I18n { + > = Record< + keyof Options['messages'], + LocaleMessageDictionary + >, + DateTimeFormats extends Record< + keyof Options['datetimeFormats'], + DateTimeFormat + > = Record, + NumberFormats extends Record< + keyof Options['numberFormats'], + NumberFormat + > = Record +>( + options: Options = {} as Options +): I18n< + Options['messages'], + Options['datetimeFormats'], + Options['numberFormats'] +> { const __legacyMode = !!options.legacy const __instances = new Map< ComponentInternalInstance, @@ -222,23 +247,29 @@ export function createI18n< return __legacyMode ? 'legacy' : 'composable' }, install(app: App, ...options: unknown[]): void { - apply(app, i18n, ...options) + apply(app, i18n, ...options) if (__legacyMode) { app.mixin( - defineMixin( - __global as VueI18n, - ((__global as unknown) as VueI18nInternal) - .__composer as Composer, + defineMixin( + __global as VueI18n, + ((__global as unknown) as VueI18nInternal< + Messages, + DateTimeFormats, + NumberFormats + >).__composer as Composer, i18n as I18nInternal ) ) } }, - get global(): Composer { + get global(): Composer { return __legacyMode - ? (((__global as unknown) as VueI18nInternal) - .__composer as Composer) - : (__global as Composer) + ? (((__global as unknown) as VueI18nInternal< + Messages, + DateTimeFormats, + NumberFormats + >).__composer as Composer) + : (__global as Composer) }, __getInstance< M extends Messages, @@ -306,13 +337,34 @@ export function createI18n< * ``` */ export function useI18n< - Options extends UseI18nOptions = object, + Options extends UseI18nOptions = object, Messages extends Record< keyof Options['messages'], LocaleMessageDictionary - > = Record> ->(options: Options = {} as Options): Composer { - const i18n = inject(I18nSymbol) as I18n + > = Record< + keyof Options['messages'], + LocaleMessageDictionary + >, + DateTimeFormats extends Record< + keyof Options['datetimeFormats'], + DateTimeFormat + > = Record, + NumberFormats extends Record< + keyof Options['numberFormats'], + NumberFormat + > = Record +>( + options: Options = {} as Options +): Composer< + Options['messages'], + Options['datetimeFormats'], + Options['numberFormats'] +> { + const i18n = inject(I18nSymbol) as I18n< + Messages, + DateTimeFormats, + NumberFormats + > if (!i18n) { throw createI18nError(I18nErrorCodes.NOT_INSLALLED) } @@ -356,13 +408,16 @@ export function useI18n< } const i18nInternal = (i18n as unknown) as I18nInternal - let composer = i18nInternal.__getInstance>( - instance - ) + let composer = i18nInternal.__getInstance< + Messages, + DateTimeFormats, + NumberFormats, + Composer + >(instance) if (composer == null) { const type = instance.type as ComponentOptions - const composerOptions: ComposerOptions & - ComposerInternalOptions = { + const composerOptions: ComposerOptions & + ComposerInternalOptions = { ...options } if (type.__i18n) { @@ -373,35 +428,59 @@ export function useI18n< composerOptions.__root = global } - composer = createComposer(composerOptions) as Composer - setupLifeCycle(i18nInternal, instance, composer) + composer = createComposer(composerOptions) as Composer< + Messages, + DateTimeFormats, + NumberFormats + > + setupLifeCycle( + i18nInternal, + instance, + composer + ) - i18nInternal.__setInstance>(instance, composer) + i18nInternal.__setInstance< + Messages, + DateTimeFormats, + NumberFormats, + Composer + >(instance, composer) } return composer as Composer } -function getComposer( - i18n: I18n, +function getComposer( + i18n: I18n, target: ComponentInternalInstance -): Composer | null { - let composer: Composer | null = null +): Composer | null { + let composer: Composer | null = null const root = target.root let current: ComponentInternalInstance | null = target.parent while (current != null) { const i18nInternal = (i18n as unknown) as I18nInternal if (i18n.mode === 'composable') { - composer = i18nInternal.__getInstance>( - current - ) + composer = i18nInternal.__getInstance< + Messages, + DateTimeFormats, + NumberFormats, + Composer + >(current) } else { - const vueI18n = i18nInternal.__getInstance>( - current - ) + const vueI18n = i18nInternal.__getInstance< + Messages, + DateTimeFormats, + NumberFormats, + VueI18n + >(current) if (vueI18n != null) { - composer = (vueI18n as VueI18n & VueI18nInternal) - .__composer as Composer + composer = (vueI18n as VueI18n< + Messages, + DateTimeFormats, + NumberFormats + > & + VueI18nInternal) + .__composer as Composer } } if (composer != null) { @@ -415,10 +494,10 @@ function getComposer( return composer } -function setupLifeCycle( +function setupLifeCycle( i18n: I18nInternal, target: ComponentInternalInstance, - composer: Composer + composer: Composer ): void { onMounted(() => { // inject composer instance to DOM for intlify-devtools diff --git a/src/legacy.ts b/src/legacy.ts index 05e88089c..2b1405866 100644 --- a/src/legacy.ts +++ b/src/legacy.ts @@ -20,8 +20,8 @@ import { } from './core/context' import { TranslateOptions } from './core/translate' import { - DateTimeFormats, - NumberFormats, + DateTimeFormats as DateTimeFormatsType, + NumberFormats as NumberFormatsType, DateTimeFormat, NumberFormat } from './core/types' @@ -71,14 +71,12 @@ export type ComponentInstanceCreatedListener = ( * @remarks * This option is compatible with the constructor options of `VueI18n` class (offered with vue-i18n@8.x). */ -export interface VueI18nOptions { +export interface VueI18nOptions { locale?: Locale fallbackLocale?: FallbackLocale - messages?: { - [K in keyof Messages]: LocaleMessageDictionary - } - datetimeFormats?: DateTimeFormats - numberFormats?: NumberFormats + messages?: LocaleMessages + datetimeFormats?: DateTimeFormatsType + numberFormats?: NumberFormatsType availableLocales?: Locale[] modifiers?: LinkedModifiers formatter?: Formatter @@ -89,9 +87,7 @@ export interface VueI18nOptions { formatFallbackMessages?: boolean preserveDirectiveContent?: boolean warnHtmlInMessage?: WarnHtmlInMessageLevel - sharedMessages?: { - [K in keyof Messages]: LocaleMessageDictionary - } + sharedMessages?: LocaleMessages pluralizationRules?: PluralizationRules postTranslation?: PostTranslationHandler sync?: boolean @@ -104,7 +100,11 @@ export interface VueI18nOptions { * @remarks * This interface is compatible with interface of `VueI18n` class (offered with vue-i18n@8.x). */ -export interface VueI18n { +export interface VueI18n< + Messages = {}, + DateTimeFormats = {}, + NumberFormats = {} +> { // properties locale: Locale fallbackLocale: FallbackLocale @@ -170,9 +170,13 @@ export interface VueI18n { /** * @internal */ -export interface VueI18nInternal { +export interface VueI18nInternal< + Messages = {}, + DateTimeFormats = {}, + NumberFormats = {} +> { __id: number - __composer: Composer + __composer: Composer __onComponentInstanceCreated(target: VueI18n): void } @@ -181,9 +185,15 @@ export interface VueI18nInternal { * * @internal */ -function convertComposerOptions( - options: VueI18nOptions & ComposerInternalOptions -): ComposerOptions & ComposerInternalOptions { +function convertComposerOptions< + Messages = {}, + DateTimeFormats = {}, + NumberFormats = {} +>( + options: VueI18nOptions & + ComposerInternalOptions +): ComposerOptions & + ComposerInternalOptions { const locale = isString(options.locale) ? options.locale : 'en-US' const fallbackLocale = isString(options.fallbackLocale) || @@ -267,15 +277,32 @@ function convertComposerOptions( * @internal */ export function createVueI18n< - Options extends VueI18nOptions = object, + Options extends VueI18nOptions = object, Messages extends Record< keyof Options['messages'], LocaleMessageDictionary - > = Record> ->(options: Options = {} as Options): VueI18n { + > = Record< + keyof Options['messages'], + LocaleMessageDictionary + >, + DateTimeFormats extends Record< + keyof Options['datetimeFormats'], + DateTimeFormat + > = Record, + NumberFormats extends Record< + keyof Options['numberFormats'], + NumberFormat + > = Record +>( + options: Options = {} as Options +): VueI18n< + Options['messages'], + Options['datetimeFormats'], + Options['numberFormats'] +> { const composer = createComposer( - convertComposerOptions(options) - ) as Composer + convertComposerOptions(options) + ) as Composer // defines VueI18n const vueI18n = { diff --git a/src/mixin.ts b/src/mixin.ts index 22da1e8da..1372f8ecc 100644 --- a/src/mixin.ts +++ b/src/mixin.ts @@ -138,12 +138,16 @@ declare module '@vue/runtime-core' { } // supports compatibility for legacy vue-i18n APIs -export function defineMixin( - vuei18n: VueI18n, - composer: Composer, +export function defineMixin( + vuei18n: VueI18n, + composer: Composer, i18n: I18nInternal ): ComponentOptions { - const legacy = (vuei18n as unknown) as VueI18nInternal + const legacy = (vuei18n as unknown) as VueI18nInternal< + Messages, + DateTimeFormats, + NumberFormats + > return { beforeCreate(): void { const instance = getCurrentInstance() @@ -154,8 +158,8 @@ export function defineMixin( const options = this.$options if (options.i18n) { - const optionsI18n = options.i18n as VueI18nOptions & - ComposerInternalOptions + const optionsI18n = options.i18n as VueI18nOptions & + ComposerInternalOptions if (options.__i18n) { optionsI18n.__i18n = options.__i18n } @@ -163,20 +167,30 @@ export function defineMixin( this.$i18n = createVueI18n(optionsI18n) legacy.__onComponentInstanceCreated(this.$i18n) - i18n.__setInstance>( + i18n.__setInstance< + Messages, + DateTimeFormats, + NumberFormats, + VueI18n + >( instance, - this.$i18n as VueI18n + this.$i18n as VueI18n ) } else if (options.__i18n) { this.$i18n = createVueI18n({ __i18n: (options as ComposerInternalOptions).__i18n, __root: composer - } as VueI18nOptions) + } as VueI18nOptions) legacy.__onComponentInstanceCreated(this.$i18n) - i18n.__setInstance>( + i18n.__setInstance< + Messages, + DateTimeFormats, + NumberFormats, + VueI18n + >( instance, - this.$i18n as VueI18n + this.$i18n as VueI18n ) } else { // set global diff --git a/src/plugin.ts b/src/plugin.ts index e70efcb15..14033924d 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -16,9 +16,9 @@ export interface I18nPluginOptions { globalInstall?: boolean } -export function apply( +export function apply( app: App, - i18n: I18n, + i18n: I18n, ...options: unknown[] ): void { const pluginOptions = isPlainObject(options[0]) @@ -48,7 +48,10 @@ export function apply( } // install directive - app.directive('t', vTDirective(i18n)) + app.directive( + 't', + vTDirective(i18n) + ) // setup global provider app.provide(I18nSymbol, i18n) diff --git a/test/composer.test.ts b/test/composer.test.ts index 529140362..b5ec80dc0 100644 --- a/test/composer.test.ts +++ b/test/composer.test.ts @@ -12,7 +12,8 @@ import { MissingHandler, addPreCompileMessages, ComposerOptions, - ComposerInternal + ComposerInternal, + VueMessageType } from '../src/composer' import { generateFormatCacheKey } from '../src/utils' import { watch, nextTick, Text, createVNode } from 'vue' @@ -849,7 +850,7 @@ describe('__i18n', () => { ] } const { messages } = createComposer( - options as ComposerOptions + options as ComposerOptions ) expect(messages.value).toEqual({ en: { hello: 'Hello,world!' }, @@ -881,7 +882,7 @@ describe('__i18n', () => { ] } const { messages } = createComposer( - options as ComposerOptions + options as ComposerOptions ) expect(messages.value).toEqual({ en: { hello: 'Hello,world!' }, From c97754c7821f351ace970c01f591f2ef3547ec7b Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Tue, 4 Aug 2020 16:07:59 +0900 Subject: [PATCH 17/20] fix --- src/composer.ts | 2 +- src/core/context.ts | 54 +++++++++------------------------------------ 2 files changed, 12 insertions(+), 44 deletions(-) diff --git a/src/composer.ts b/src/composer.ts index b13915d1a..82343ea48 100644 --- a/src/composer.ts +++ b/src/composer.ts @@ -479,7 +479,7 @@ export function createComposer< __numberFormatters: isPlainObject(_context) ? ((_context as unknown) as RuntimeInternalContext).__numberFormatters : undefined - } as RuntimeOptions) as RuntimeContext< + } as RuntimeOptions) as RuntimeContext< Messages, DateTimeFormats, NumberFormats, diff --git a/src/core/context.ts b/src/core/context.ts index 0508d46b2..c73f45ab8 100644 --- a/src/core/context.ts +++ b/src/core/context.ts @@ -19,7 +19,12 @@ import { isPlainObject, isObject } from '../utils' -import { NumberFormat, DateTimeFormat } from './types' +import { + NumberFormat, + DateTimeFormat, + DateTimeFormats as DateTimeFormatsType, + NumberFormats as NumberFormatsType +} from './types' // eslint-disable-next-line @typescript-eslint/no-explicit-any type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ( @@ -71,17 +76,12 @@ export type MessageCompiler = ( options?: CompileOptions ) => MessageFunction -export interface RuntimeOptions< - Messages = {}, - DateTimeFormats = {}, - NumberFormats = {}, - Message = string -> { +export interface RuntimeOptions { locale?: Locale fallbackLocale?: FallbackLocale - messages?: LocaleMessages - datetimeFormats?: DateTimeFormats - numberFormats?: NumberFormats + messages?: LocaleMessages + datetimeFormats?: DateTimeFormatsType + numberFormats?: NumberFormatsType modifiers?: LinkedModifiers pluralRules?: PluralizationRules missing?: RuntimeMissingHandler @@ -143,33 +143,6 @@ export interface RuntimeContext< RuntimeDateTimeContext, RuntimeNumberContext {} -/* -export interface RuntimeContext< - Messages = {}, - DateTimeFormats = {}, - NumberFormats = {}, - Message = string -> { - locale: Locale - fallbackLocale: FallbackLocale - messages: Messages - datetimeFormats: DateTimeFormats - numberFormats: NumberFormats - modifiers: LinkedModifiers - pluralRules?: PluralizationRules - missing: RuntimeMissingHandler | null - missingWarn: boolean | RegExp - fallbackWarn: boolean | RegExp - fallbackFormat: boolean - unresolving: boolean - postTranslation: PostTranslationHandler | null - processor: MessageProcessor | null - warnHtmlMessage: boolean - messageCompiler: MessageCompiler - onWarn(msg: string, err?: Error): void -} -*/ - export interface RuntimeInternalContext { __datetimeFormatters: Map __numberFormatters: Map @@ -197,12 +170,7 @@ function getDefaultLinkedModifiers(): LinkedModifiers< export function createRuntimeContext< Message = string, - Options extends RuntimeOptions< - Messages, - DateTimeFormats, - NumberFormats, - Message - > = object, + Options extends RuntimeOptions = object, Messages extends Record< keyof Options['messages'], LocaleMessageDictionary From 6766c9c3c2c319e5f3264492348fa738f0411831 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Tue, 4 Aug 2020 16:36:55 +0900 Subject: [PATCH 18/20] fix lint error --- src/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 101d751c0..e8aaa57c2 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -5,7 +5,7 @@ const RE_ARGS = /\{([0-9a-zA-Z]+)\}/g -/* eslint-disable @typescript-eslint/no-explicit-any */ +// eslint-disable-next-line export function format(message: string, ...args: any): string { if (args.length === 1 && isObject(args[0])) { args = args[0] From 1099292571b1e2e79c6ca7a4cdce15bc31286039 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Tue, 4 Aug 2020 16:39:21 +0900 Subject: [PATCH 19/20] update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ecff34a08..859cceb41 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,7 @@ yarn add vue-i18n@next - [x] number function - [x] warnHtmlMessage - [x] improve translate `args` typing - - [ ] improve locale messages typing: `LocaleMessages` / `LocaleMessage` / `LocaleMessageDictiory` + - [x] improve locale messages typing: `LocaleMessages` / `LocaleMessage` / `LocaleMessageDictiory` - [x] postTranslation context option - Composable API: I18n Composer - properties From 466c30ddfb13456e0d9f8df80a124fcfa1d47ff0 Mon Sep 17 00:00:00 2001 From: kazuya kawaguchi Date: Tue, 4 Aug 2020 16:43:04 +0900 Subject: [PATCH 20/20] update api docs --- docs/vue-i18n.availabilities.md | 11 --- docs/vue-i18n.baseformatprops.locale.md | 11 +++ docs/vue-i18n.baseformatprops.md | 20 +++++ docs/vue-i18n.baseformatprops.scope.md | 11 +++ docs/vue-i18n.baseformatprops.tag.md | 11 +++ docs/vue-i18n.clearcompilecache.md | 15 ++++ docs/vue-i18n.cleardatetimeformat.md | 24 ++++++ docs/vue-i18n.clearnumberformat.md | 24 ++++++ docs/vue-i18n.compile.md | 4 +- docs/vue-i18n.compileerror.code.md | 2 +- docs/vue-i18n.compileerror.md | 2 +- docs/vue-i18n.compileerrorcodes.md | 3 +- docs/vue-i18n.componeti18nscope.md | 11 +++ docs/vue-i18n.composer.getlocalemessage.md | 4 +- ...i18n.composer.getposttranslationhandler.md | 4 +- docs/vue-i18n.composer.md | 6 +- docs/vue-i18n.composer.mergelocalemessage.md | 4 +- docs/vue-i18n.composer.messages.md | 2 +- docs/vue-i18n.composer.modifiers.md | 2 +- docs/vue-i18n.composer.setlocalemessage.md | 4 +- ...i18n.composer.setposttranslationhandler.md | 4 +- ...ue-i18n.composeroptions.datetimeformats.md | 2 +- docs/vue-i18n.composeroptions.md | 12 +-- docs/vue-i18n.composeroptions.messages.md | 2 +- docs/vue-i18n.composeroptions.modifiers.md | 2 +- .../vue-i18n.composeroptions.numberformats.md | 2 +- ...ue-i18n.composeroptions.posttranslation.md | 2 +- docs/vue-i18n.createi18n.md | 6 +- docs/vue-i18n.createruntimecontext.md | 22 +++++ docs/vue-i18n.currencydisplay.md | 13 --- ...8n.currencynumberformatoptions.currency.md | 11 --- ...encynumberformatoptions.currencydisplay.md | 11 --- ...rrencynumberformatoptions.formatmatcher.md | 11 --- ...rrencynumberformatoptions.localematcher.md | 11 --- docs/vue-i18n.currencynumberformatoptions.md | 22 ----- ...-i18n.currencynumberformatoptions.style.md | 11 --- docs/vue-i18n.customblocks.md | 11 +++ docs/vue-i18n.datetime.md | 23 ++++++ docs/vue-i18n.datetime_1.md | 24 ++++++ docs/vue-i18n.datetime_2.md | 25 ++++++ docs/vue-i18n.datetime_3.md | 24 ++++++ docs/vue-i18n.datetime_4.md | 23 ++++++ docs/vue-i18n.datetimedigital.md | 11 --- docs/vue-i18n.datetimeformat.md | 78 ++++++++++++++++-- docs/vue-i18n.datetimeformatoptions.md | 11 --- docs/vue-i18n.datetimeformatprops.md | 11 +++ docs/vue-i18n.datetimehumanreadable.md | 11 --- docs/vue-i18n.datetimeoptions.md | 37 +++++++++ docs/vue-i18n.formattableprops.format.md | 11 +++ docs/vue-i18n.formattableprops.md | 19 +++++ docs/vue-i18n.formattableprops.value.md | 11 +++ docs/vue-i18n.formattednumberpart.md | 14 ---- docs/vue-i18n.formattednumberparttype.md | 11 --- docs/vue-i18n.getlocalechain.md | 24 ++++++ docs/vue-i18n.handlemissing.md | 26 ++++++ docs/vue-i18n.i18n.global.md | 2 +- docs/vue-i18n.i18n.md | 4 +- docs/vue-i18n.i18n.mode.md | 2 + docs/vue-i18n.i18nadditionaloptions.legacy.md | 2 + docs/vue-i18n.i18nadditionaloptions.md | 2 +- docs/vue-i18n.i18npluginoptions._i18n-t_.md | 11 --- ...ue-i18n.i18npluginoptions.globalinstall.md | 11 +++ docs/vue-i18n.i18npluginoptions.md | 3 +- ....i18npluginoptions.usei18ncomponentname.md | 11 +++ docs/vue-i18n.intlavailability.md | 16 ---- docs/vue-i18n.istranslatemissingwarn.md | 23 ++++++ docs/vue-i18n.istrarnslatefallbackwarn.md | 23 ++++++ docs/vue-i18n.linkedmodifiers.md | 4 +- docs/vue-i18n.localemessage.md | 11 --- docs/vue-i18n.localemessagearray.md | 11 +++ docs/vue-i18n.localemessagedictionary.md | 4 +- docs/vue-i18n.localemessageobject.md | 2 +- docs/vue-i18n.localemessages.md | 2 +- docs/vue-i18n.localemessagevalue.md | 11 +++ docs/vue-i18n.md | 82 +++++++++++++++---- docs/vue-i18n.messagecompiler.md | 11 +++ docs/vue-i18n.messagefunction.md | 7 +- docs/vue-i18n.messagefunctions.md | 2 +- docs/vue-i18n.missing_resolve_value.md | 11 +++ docs/vue-i18n.not_reoslved.md | 11 +++ docs/vue-i18n.number.md | 23 ++++++ docs/vue-i18n.number_1.md | 24 ++++++ docs/vue-i18n.number_2.md | 25 ++++++ docs/vue-i18n.number_3.md | 24 ++++++ docs/vue-i18n.number_4.md | 23 ++++++ docs/vue-i18n.numberformat.md | 76 ++++++++++++++++- docs/vue-i18n.numberformatoptions.md | 11 --- docs/vue-i18n.numberformatprops.md | 11 +++ docs/vue-i18n.numberformattopartsresult.md | 13 --- docs/vue-i18n.numberoptions.md | 37 +++++++++ docs/vue-i18n.parsedatetimeargs.md | 22 +++++ docs/vue-i18n.parsenumberargs.md | 22 +++++ docs/vue-i18n.parser.md | 13 ++- docs/vue-i18n.parser.parse.md | 22 +++++ docs/vue-i18n.parsetranslateargs.md | 22 +++++ docs/vue-i18n.posttranslationhandler.md | 2 +- ...18n.runtimecommoncontext.fallbackformat.md | 11 +++ ...18n.runtimecommoncontext.fallbacklocale.md | 11 +++ ...-i18n.runtimecommoncontext.fallbackwarn.md | 11 +++ docs/vue-i18n.runtimecommoncontext.locale.md | 11 +++ docs/vue-i18n.runtimecommoncontext.md | 30 +++++++ docs/vue-i18n.runtimecommoncontext.missing.md | 11 +++ ...e-i18n.runtimecommoncontext.missingwarn.md | 11 +++ docs/vue-i18n.runtimecommoncontext.onwarn.md | 23 ++++++ ...e-i18n.runtimecommoncontext.unresolving.md | 11 +++ docs/vue-i18n.runtimecontext.md | 11 +++ ....runtimedatetimecontext.datetimeformats.md | 11 +++ docs/vue-i18n.runtimedatetimecontext.md | 18 ++++ ...imeinternalcontext.__datetimeformatters.md | 11 +++ ...ntimeinternalcontext.__localechaincache.md | 11 +++ ...ntimeinternalcontext.__numberformatters.md | 11 +++ docs/vue-i18n.runtimeinternalcontext.md | 20 +++++ ...imeinternaloptions.__datetimeformatters.md | 11 +++ ...ntimeinternaloptions.__numberformatters.md | 11 +++ docs/vue-i18n.runtimeinternaloptions.md | 19 +++++ docs/vue-i18n.runtimemissinghandler.md | 11 +++ docs/vue-i18n.runtimemissingtype.md | 11 +++ docs/vue-i18n.runtimenumbercontext.md | 18 ++++ ...i18n.runtimenumbercontext.numberformats.md | 11 +++ ...vue-i18n.runtimeoptions.datetimeformats.md | 11 +++ .../vue-i18n.runtimeoptions.fallbackformat.md | 11 +++ .../vue-i18n.runtimeoptions.fallbacklocale.md | 11 +++ docs/vue-i18n.runtimeoptions.fallbackwarn.md | 11 +++ docs/vue-i18n.runtimeoptions.locale.md | 11 +++ docs/vue-i18n.runtimeoptions.md | 34 ++++++++ ...vue-i18n.runtimeoptions.messagecompiler.md | 11 +++ docs/vue-i18n.runtimeoptions.messages.md | 11 +++ docs/vue-i18n.runtimeoptions.missing.md | 11 +++ docs/vue-i18n.runtimeoptions.missingwarn.md | 11 +++ docs/vue-i18n.runtimeoptions.modifiers.md | 11 +++ docs/vue-i18n.runtimeoptions.numberformats.md | 11 +++ docs/vue-i18n.runtimeoptions.onwarn.md | 11 +++ docs/vue-i18n.runtimeoptions.pluralrules.md | 11 +++ ...vue-i18n.runtimeoptions.posttranslation.md | 11 +++ docs/vue-i18n.runtimeoptions.processor.md | 11 +++ docs/vue-i18n.runtimeoptions.unresolving.md | 11 +++ ...vue-i18n.runtimeoptions.warnhtmlmessage.md | 11 +++ docs/vue-i18n.runtimetranslationcontext.md | 24 ++++++ ...ntimetranslationcontext.messagecompiler.md | 11 +++ ...i18n.runtimetranslationcontext.messages.md | 11 +++ ...18n.runtimetranslationcontext.modifiers.md | 11 +++ ...n.runtimetranslationcontext.pluralrules.md | 11 +++ ...ntimetranslationcontext.posttranslation.md | 11 +++ ...18n.runtimetranslationcontext.processor.md | 11 +++ ...ntimetranslationcontext.warnhtmlmessage.md | 11 +++ ...-i18n.specificdatetimeformatoptions.day.md | 11 --- ...-i18n.specificdatetimeformatoptions.era.md | 11 --- ...ificdatetimeformatoptions.formatmatcher.md | 11 --- ...i18n.specificdatetimeformatoptions.hour.md | 11 --- ...ificdatetimeformatoptions.localematcher.md | 11 --- .../vue-i18n.specificdatetimeformatoptions.md | 28 ------- ...8n.specificdatetimeformatoptions.minute.md | 11 --- ...18n.specificdatetimeformatoptions.month.md | 11 --- ...8n.specificdatetimeformatoptions.second.md | 11 --- ...cificdatetimeformatoptions.timezonename.md | 11 --- ...n.specificdatetimeformatoptions.weekday.md | 11 --- ...i18n.specificdatetimeformatoptions.year.md | 11 --- ...8n.specificnumberformatoptions.currency.md | 11 --- ...ificnumberformatoptions.currencydisplay.md | 11 --- ...ecificnumberformatoptions.formatmatcher.md | 11 --- ...ecificnumberformatoptions.localematcher.md | 11 --- docs/vue-i18n.specificnumberformatoptions.md | 22 ----- ...-i18n.specificnumberformatoptions.style.md | 11 --- docs/vue-i18n.translate.md | 23 ++++++ docs/vue-i18n.translate_1.md | 24 ++++++ docs/vue-i18n.translate_10.md | 25 ++++++ docs/vue-i18n.translate_11.md | 25 ++++++ docs/vue-i18n.translate_12.md | 25 ++++++ docs/vue-i18n.translate_13.md | 23 ++++++ docs/vue-i18n.translate_2.md | 25 ++++++ docs/vue-i18n.translate_3.md | 24 ++++++ docs/vue-i18n.translate_4.md | 25 ++++++ docs/vue-i18n.translate_5.md | 24 ++++++ docs/vue-i18n.translate_6.md | 25 ++++++ docs/vue-i18n.translate_7.md | 25 ++++++ docs/vue-i18n.translate_8.md | 25 ++++++ docs/vue-i18n.translate_9.md | 24 ++++++ docs/vue-i18n.translateoptions.md | 45 ++++++++++ docs/vue-i18n.translation.md | 82 +++++++++++++++++++ docs/vue-i18n.translationprops.keypath.md | 11 +++ docs/vue-i18n.translationprops.md | 19 +++++ docs/vue-i18n.translationprops.plural.md | 11 +++ docs/vue-i18n.updatefallbacklocale.md | 24 ++++++ docs/vue-i18n.usei18n.md | 6 +- docs/vue-i18n.vuei18n.getlocalemessage.md | 4 +- docs/vue-i18n.vuei18n.md | 6 +- docs/vue-i18n.vuei18n.mergelocalemessage.md | 4 +- docs/vue-i18n.vuei18n.messages.md | 2 +- docs/vue-i18n.vuei18n.posttranslation.md | 2 +- docs/vue-i18n.vuei18n.setlocalemessage.md | 4 +- docs/vue-i18n.vuei18n.t_5.md | 4 +- docs/vue-i18n.vuei18n.tc_3.md | 4 +- docs/vue-i18n.vuei18n.tc_7.md | 4 +- ...ptions.componentinstancecreatedlistener.md | 11 +++ ...vue-i18n.vuei18noptions.datetimeformats.md | 2 +- docs/vue-i18n.vuei18noptions.md | 13 +-- docs/vue-i18n.vuei18noptions.messages.md | 2 +- docs/vue-i18n.vuei18noptions.modifiers.md | 2 +- docs/vue-i18n.vuei18noptions.numberformats.md | 2 +- ...vue-i18n.vuei18noptions.posttranslation.md | 2 +- .../vue-i18n.vuei18noptions.sharedmessages.md | 2 +- 201 files changed, 2284 insertions(+), 562 deletions(-) delete mode 100644 docs/vue-i18n.availabilities.md create mode 100644 docs/vue-i18n.baseformatprops.locale.md create mode 100644 docs/vue-i18n.baseformatprops.md create mode 100644 docs/vue-i18n.baseformatprops.scope.md create mode 100644 docs/vue-i18n.baseformatprops.tag.md create mode 100644 docs/vue-i18n.clearcompilecache.md create mode 100644 docs/vue-i18n.cleardatetimeformat.md create mode 100644 docs/vue-i18n.clearnumberformat.md create mode 100644 docs/vue-i18n.componeti18nscope.md create mode 100644 docs/vue-i18n.createruntimecontext.md delete mode 100644 docs/vue-i18n.currencydisplay.md delete mode 100644 docs/vue-i18n.currencynumberformatoptions.currency.md delete mode 100644 docs/vue-i18n.currencynumberformatoptions.currencydisplay.md delete mode 100644 docs/vue-i18n.currencynumberformatoptions.formatmatcher.md delete mode 100644 docs/vue-i18n.currencynumberformatoptions.localematcher.md delete mode 100644 docs/vue-i18n.currencynumberformatoptions.md delete mode 100644 docs/vue-i18n.currencynumberformatoptions.style.md create mode 100644 docs/vue-i18n.customblocks.md create mode 100644 docs/vue-i18n.datetime.md create mode 100644 docs/vue-i18n.datetime_1.md create mode 100644 docs/vue-i18n.datetime_2.md create mode 100644 docs/vue-i18n.datetime_3.md create mode 100644 docs/vue-i18n.datetime_4.md delete mode 100644 docs/vue-i18n.datetimedigital.md delete mode 100644 docs/vue-i18n.datetimeformatoptions.md create mode 100644 docs/vue-i18n.datetimeformatprops.md delete mode 100644 docs/vue-i18n.datetimehumanreadable.md create mode 100644 docs/vue-i18n.datetimeoptions.md create mode 100644 docs/vue-i18n.formattableprops.format.md create mode 100644 docs/vue-i18n.formattableprops.md create mode 100644 docs/vue-i18n.formattableprops.value.md delete mode 100644 docs/vue-i18n.formattednumberpart.md delete mode 100644 docs/vue-i18n.formattednumberparttype.md create mode 100644 docs/vue-i18n.getlocalechain.md create mode 100644 docs/vue-i18n.handlemissing.md delete mode 100644 docs/vue-i18n.i18npluginoptions._i18n-t_.md create mode 100644 docs/vue-i18n.i18npluginoptions.globalinstall.md create mode 100644 docs/vue-i18n.i18npluginoptions.usei18ncomponentname.md delete mode 100644 docs/vue-i18n.intlavailability.md create mode 100644 docs/vue-i18n.istranslatemissingwarn.md create mode 100644 docs/vue-i18n.istrarnslatefallbackwarn.md delete mode 100644 docs/vue-i18n.localemessage.md create mode 100644 docs/vue-i18n.localemessagearray.md create mode 100644 docs/vue-i18n.localemessagevalue.md create mode 100644 docs/vue-i18n.messagecompiler.md create mode 100644 docs/vue-i18n.missing_resolve_value.md create mode 100644 docs/vue-i18n.not_reoslved.md create mode 100644 docs/vue-i18n.number.md create mode 100644 docs/vue-i18n.number_1.md create mode 100644 docs/vue-i18n.number_2.md create mode 100644 docs/vue-i18n.number_3.md create mode 100644 docs/vue-i18n.number_4.md delete mode 100644 docs/vue-i18n.numberformatoptions.md create mode 100644 docs/vue-i18n.numberformatprops.md delete mode 100644 docs/vue-i18n.numberformattopartsresult.md create mode 100644 docs/vue-i18n.numberoptions.md create mode 100644 docs/vue-i18n.parsedatetimeargs.md create mode 100644 docs/vue-i18n.parsenumberargs.md create mode 100644 docs/vue-i18n.parser.parse.md create mode 100644 docs/vue-i18n.parsetranslateargs.md create mode 100644 docs/vue-i18n.runtimecommoncontext.fallbackformat.md create mode 100644 docs/vue-i18n.runtimecommoncontext.fallbacklocale.md create mode 100644 docs/vue-i18n.runtimecommoncontext.fallbackwarn.md create mode 100644 docs/vue-i18n.runtimecommoncontext.locale.md create mode 100644 docs/vue-i18n.runtimecommoncontext.md create mode 100644 docs/vue-i18n.runtimecommoncontext.missing.md create mode 100644 docs/vue-i18n.runtimecommoncontext.missingwarn.md create mode 100644 docs/vue-i18n.runtimecommoncontext.onwarn.md create mode 100644 docs/vue-i18n.runtimecommoncontext.unresolving.md create mode 100644 docs/vue-i18n.runtimecontext.md create mode 100644 docs/vue-i18n.runtimedatetimecontext.datetimeformats.md create mode 100644 docs/vue-i18n.runtimedatetimecontext.md create mode 100644 docs/vue-i18n.runtimeinternalcontext.__datetimeformatters.md create mode 100644 docs/vue-i18n.runtimeinternalcontext.__localechaincache.md create mode 100644 docs/vue-i18n.runtimeinternalcontext.__numberformatters.md create mode 100644 docs/vue-i18n.runtimeinternalcontext.md create mode 100644 docs/vue-i18n.runtimeinternaloptions.__datetimeformatters.md create mode 100644 docs/vue-i18n.runtimeinternaloptions.__numberformatters.md create mode 100644 docs/vue-i18n.runtimeinternaloptions.md create mode 100644 docs/vue-i18n.runtimemissinghandler.md create mode 100644 docs/vue-i18n.runtimemissingtype.md create mode 100644 docs/vue-i18n.runtimenumbercontext.md create mode 100644 docs/vue-i18n.runtimenumbercontext.numberformats.md create mode 100644 docs/vue-i18n.runtimeoptions.datetimeformats.md create mode 100644 docs/vue-i18n.runtimeoptions.fallbackformat.md create mode 100644 docs/vue-i18n.runtimeoptions.fallbacklocale.md create mode 100644 docs/vue-i18n.runtimeoptions.fallbackwarn.md create mode 100644 docs/vue-i18n.runtimeoptions.locale.md create mode 100644 docs/vue-i18n.runtimeoptions.md create mode 100644 docs/vue-i18n.runtimeoptions.messagecompiler.md create mode 100644 docs/vue-i18n.runtimeoptions.messages.md create mode 100644 docs/vue-i18n.runtimeoptions.missing.md create mode 100644 docs/vue-i18n.runtimeoptions.missingwarn.md create mode 100644 docs/vue-i18n.runtimeoptions.modifiers.md create mode 100644 docs/vue-i18n.runtimeoptions.numberformats.md create mode 100644 docs/vue-i18n.runtimeoptions.onwarn.md create mode 100644 docs/vue-i18n.runtimeoptions.pluralrules.md create mode 100644 docs/vue-i18n.runtimeoptions.posttranslation.md create mode 100644 docs/vue-i18n.runtimeoptions.processor.md create mode 100644 docs/vue-i18n.runtimeoptions.unresolving.md create mode 100644 docs/vue-i18n.runtimeoptions.warnhtmlmessage.md create mode 100644 docs/vue-i18n.runtimetranslationcontext.md create mode 100644 docs/vue-i18n.runtimetranslationcontext.messagecompiler.md create mode 100644 docs/vue-i18n.runtimetranslationcontext.messages.md create mode 100644 docs/vue-i18n.runtimetranslationcontext.modifiers.md create mode 100644 docs/vue-i18n.runtimetranslationcontext.pluralrules.md create mode 100644 docs/vue-i18n.runtimetranslationcontext.posttranslation.md create mode 100644 docs/vue-i18n.runtimetranslationcontext.processor.md create mode 100644 docs/vue-i18n.runtimetranslationcontext.warnhtmlmessage.md delete mode 100644 docs/vue-i18n.specificdatetimeformatoptions.day.md delete mode 100644 docs/vue-i18n.specificdatetimeformatoptions.era.md delete mode 100644 docs/vue-i18n.specificdatetimeformatoptions.formatmatcher.md delete mode 100644 docs/vue-i18n.specificdatetimeformatoptions.hour.md delete mode 100644 docs/vue-i18n.specificdatetimeformatoptions.localematcher.md delete mode 100644 docs/vue-i18n.specificdatetimeformatoptions.md delete mode 100644 docs/vue-i18n.specificdatetimeformatoptions.minute.md delete mode 100644 docs/vue-i18n.specificdatetimeformatoptions.month.md delete mode 100644 docs/vue-i18n.specificdatetimeformatoptions.second.md delete mode 100644 docs/vue-i18n.specificdatetimeformatoptions.timezonename.md delete mode 100644 docs/vue-i18n.specificdatetimeformatoptions.weekday.md delete mode 100644 docs/vue-i18n.specificdatetimeformatoptions.year.md delete mode 100644 docs/vue-i18n.specificnumberformatoptions.currency.md delete mode 100644 docs/vue-i18n.specificnumberformatoptions.currencydisplay.md delete mode 100644 docs/vue-i18n.specificnumberformatoptions.formatmatcher.md delete mode 100644 docs/vue-i18n.specificnumberformatoptions.localematcher.md delete mode 100644 docs/vue-i18n.specificnumberformatoptions.md delete mode 100644 docs/vue-i18n.specificnumberformatoptions.style.md create mode 100644 docs/vue-i18n.translate.md create mode 100644 docs/vue-i18n.translate_1.md create mode 100644 docs/vue-i18n.translate_10.md create mode 100644 docs/vue-i18n.translate_11.md create mode 100644 docs/vue-i18n.translate_12.md create mode 100644 docs/vue-i18n.translate_13.md create mode 100644 docs/vue-i18n.translate_2.md create mode 100644 docs/vue-i18n.translate_3.md create mode 100644 docs/vue-i18n.translate_4.md create mode 100644 docs/vue-i18n.translate_5.md create mode 100644 docs/vue-i18n.translate_6.md create mode 100644 docs/vue-i18n.translate_7.md create mode 100644 docs/vue-i18n.translate_8.md create mode 100644 docs/vue-i18n.translate_9.md create mode 100644 docs/vue-i18n.translateoptions.md create mode 100644 docs/vue-i18n.translation.md create mode 100644 docs/vue-i18n.translationprops.keypath.md create mode 100644 docs/vue-i18n.translationprops.md create mode 100644 docs/vue-i18n.translationprops.plural.md create mode 100644 docs/vue-i18n.updatefallbacklocale.md create mode 100644 docs/vue-i18n.vuei18noptions.componentinstancecreatedlistener.md diff --git a/docs/vue-i18n.availabilities.md b/docs/vue-i18n.availabilities.md deleted file mode 100644 index 0bf9509e6..000000000 --- a/docs/vue-i18n.availabilities.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [Availabilities](./vue-i18n.availabilities.md) - -## Availabilities variable - -Signature: - -```typescript -Availabilities: IntlAvailability -``` diff --git a/docs/vue-i18n.baseformatprops.locale.md b/docs/vue-i18n.baseformatprops.locale.md new file mode 100644 index 000000000..12e320337 --- /dev/null +++ b/docs/vue-i18n.baseformatprops.locale.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [BaseFormatProps](./vue-i18n.baseformatprops.md) > [locale](./vue-i18n.baseformatprops.locale.md) + +## BaseFormatProps.locale property + +Signature: + +```typescript +locale?: Locale; +``` diff --git a/docs/vue-i18n.baseformatprops.md b/docs/vue-i18n.baseformatprops.md new file mode 100644 index 000000000..05071a904 --- /dev/null +++ b/docs/vue-i18n.baseformatprops.md @@ -0,0 +1,20 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [BaseFormatProps](./vue-i18n.baseformatprops.md) + +## BaseFormatProps interface + +Signature: + +```typescript +export interface BaseFormatProps +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [locale](./vue-i18n.baseformatprops.locale.md) | Locale | | +| [scope](./vue-i18n.baseformatprops.scope.md) | ComponetI18nScope | | +| [tag](./vue-i18n.baseformatprops.tag.md) | string | | + diff --git a/docs/vue-i18n.baseformatprops.scope.md b/docs/vue-i18n.baseformatprops.scope.md new file mode 100644 index 000000000..c3462873c --- /dev/null +++ b/docs/vue-i18n.baseformatprops.scope.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [BaseFormatProps](./vue-i18n.baseformatprops.md) > [scope](./vue-i18n.baseformatprops.scope.md) + +## BaseFormatProps.scope property + +Signature: + +```typescript +scope?: ComponetI18nScope; +``` diff --git a/docs/vue-i18n.baseformatprops.tag.md b/docs/vue-i18n.baseformatprops.tag.md new file mode 100644 index 000000000..05ec30505 --- /dev/null +++ b/docs/vue-i18n.baseformatprops.tag.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [BaseFormatProps](./vue-i18n.baseformatprops.md) > [tag](./vue-i18n.baseformatprops.tag.md) + +## BaseFormatProps.tag property + +Signature: + +```typescript +tag?: string; +``` diff --git a/docs/vue-i18n.clearcompilecache.md b/docs/vue-i18n.clearcompilecache.md new file mode 100644 index 000000000..331af4850 --- /dev/null +++ b/docs/vue-i18n.clearcompilecache.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [clearCompileCache](./vue-i18n.clearcompilecache.md) + +## clearCompileCache() function + +Signature: + +```typescript +export declare function clearCompileCache(): void; +``` +Returns: + +`void` + diff --git a/docs/vue-i18n.cleardatetimeformat.md b/docs/vue-i18n.cleardatetimeformat.md new file mode 100644 index 000000000..6f5ac894d --- /dev/null +++ b/docs/vue-i18n.cleardatetimeformat.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [clearDateTimeFormat](./vue-i18n.cleardatetimeformat.md) + +## clearDateTimeFormat() function + +Signature: + +```typescript +export declare function clearDateTimeFormat(ctx: RuntimeDateTimeContext, locale: Locale, format: DateTimeFormat): void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| ctx | RuntimeDateTimeContext<DateTimeFormats, Message> | | +| locale | Locale | | +| format | DateTimeFormat | | + +Returns: + +`void` + diff --git a/docs/vue-i18n.clearnumberformat.md b/docs/vue-i18n.clearnumberformat.md new file mode 100644 index 000000000..4bdc6b96c --- /dev/null +++ b/docs/vue-i18n.clearnumberformat.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [clearNumberFormat](./vue-i18n.clearnumberformat.md) + +## clearNumberFormat() function + +Signature: + +```typescript +export declare function clearNumberFormat(ctx: RuntimeNumberContext, locale: Locale, format: NumberFormat): void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| ctx | RuntimeNumberContext<NumberFormats, Message> | | +| locale | Locale | | +| format | NumberFormat | | + +Returns: + +`void` + diff --git a/docs/vue-i18n.compile.md b/docs/vue-i18n.compile.md index 8deab810f..8049cc2a3 100644 --- a/docs/vue-i18n.compile.md +++ b/docs/vue-i18n.compile.md @@ -7,7 +7,7 @@ Signature: ```typescript -export declare function compile(source: string, options?: CompileOptions): MessageFunction; +export declare function compile(source: string, options?: CompileOptions): MessageFunction; ``` ## Parameters @@ -19,5 +19,5 @@ export declare function compile(source: string, options?: CompileOptions): Messa Returns: -`MessageFunction` +`MessageFunction` diff --git a/docs/vue-i18n.compileerror.code.md b/docs/vue-i18n.compileerror.code.md index 3b16f6c74..4ad51a2f4 100644 --- a/docs/vue-i18n.compileerror.code.md +++ b/docs/vue-i18n.compileerror.code.md @@ -7,5 +7,5 @@ Signature: ```typescript -code: CompileErrorCodes; +code: number; ``` diff --git a/docs/vue-i18n.compileerror.md b/docs/vue-i18n.compileerror.md index 32137808b..723017876 100644 --- a/docs/vue-i18n.compileerror.md +++ b/docs/vue-i18n.compileerror.md @@ -14,7 +14,7 @@ export interface CompileError extends SyntaxError | Property | Type | Description | | --- | --- | --- | -| [code](./vue-i18n.compileerror.code.md) | CompileErrorCodes | | +| [code](./vue-i18n.compileerror.code.md) | number | | | [domain](./vue-i18n.compileerror.domain.md) | CompileDomain | | | [location](./vue-i18n.compileerror.location.md) | SourceLocation | | diff --git a/docs/vue-i18n.compileerrorcodes.md b/docs/vue-i18n.compileerrorcodes.md index 77caeb395..de88f1063 100644 --- a/docs/vue-i18n.compileerrorcodes.md +++ b/docs/vue-i18n.compileerrorcodes.md @@ -14,7 +14,7 @@ export declare const enum CompileErrorCodes | Member | Value | Description | | --- | --- | --- | -| \_\_EXTEND\_POINT\_\_ | 11 | | +| \_\_EXTEND\_POINT\_\_ | 12 | | | EMPTY\_PLACEHOLDER | 7 | | | EXPECTED\_TOKEN | 0 | | | INVALID\_LINKED\_FORMAT | 9 | | @@ -23,6 +23,7 @@ export declare const enum CompileErrorCodes | MUST\_HAVE\_MESSAGES\_IN\_PLURAL | 10 | | | NOT\_ALLOW\_NEST\_PLACEHOLDER | 8 | | | UNBALANCED\_CLOSING\_BRACE | 5 | | +| UNEXPECTED\_LEXICAL\_ANALYSIS | 11 | | | UNKNOWN\_ESCAPE\_SEQUENCE | 3 | | | UNTERMINATED\_CLOSING\_BRACE | 6 | | | UNTERMINATED\_SINGLE\_QUOTE\_IN\_PLACEHOLDER | 2 | | diff --git a/docs/vue-i18n.componeti18nscope.md b/docs/vue-i18n.componeti18nscope.md new file mode 100644 index 000000000..887648c01 --- /dev/null +++ b/docs/vue-i18n.componeti18nscope.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [ComponetI18nScope](./vue-i18n.componeti18nscope.md) + +## ComponetI18nScope type + +Signature: + +```typescript +export declare type ComponetI18nScope = Exclude; +``` diff --git a/docs/vue-i18n.composer.getlocalemessage.md b/docs/vue-i18n.composer.getlocalemessage.md index 51c5dad0d..262e3fe38 100644 --- a/docs/vue-i18n.composer.getlocalemessage.md +++ b/docs/vue-i18n.composer.getlocalemessage.md @@ -7,7 +7,7 @@ Signature: ```typescript -getLocaleMessage(locale: Locale): LocaleMessage; +getLocaleMessage(locale: Locale): LocaleMessageDictionary; ``` ## Parameters @@ -18,5 +18,5 @@ getLocaleMessage(locale: Locale): LocaleMessage; Returns: -`LocaleMessage` +`LocaleMessageDictionary` diff --git a/docs/vue-i18n.composer.getposttranslationhandler.md b/docs/vue-i18n.composer.getposttranslationhandler.md index 867ee5040..c28aa475f 100644 --- a/docs/vue-i18n.composer.getposttranslationhandler.md +++ b/docs/vue-i18n.composer.getposttranslationhandler.md @@ -7,9 +7,9 @@ Signature: ```typescript -getPostTranslationHandler(): PostTranslationHandler | null; +getPostTranslationHandler(): PostTranslationHandler | null; ``` Returns: -`PostTranslationHandler | null` +`PostTranslationHandler | null` diff --git a/docs/vue-i18n.composer.md b/docs/vue-i18n.composer.md index 77e37a4a8..e431682e8 100644 --- a/docs/vue-i18n.composer.md +++ b/docs/vue-i18n.composer.md @@ -9,7 +9,7 @@ Composer Interfaces Signature: ```typescript -export interface Composer +export interface Composer ``` ## Remarks @@ -29,9 +29,9 @@ This is the interface for being used for Vue 3 Composition API. | [inheritLocale](./vue-i18n.composer.inheritlocale.md) | boolean | | | [isGlobal](./vue-i18n.composer.isglobal.md) | boolean | | | [locale](./vue-i18n.composer.locale.md) | WritableComputedRef<Locale> | | -| [messages](./vue-i18n.composer.messages.md) | ComputedRef<LocaleMessages> | | +| [messages](./vue-i18n.composer.messages.md) | ComputedRef<Messages> | | | [missingWarn](./vue-i18n.composer.missingwarn.md) | boolean | RegExp | | -| [modifiers](./vue-i18n.composer.modifiers.md) | LinkedModifiers | | +| [modifiers](./vue-i18n.composer.modifiers.md) | LinkedModifiers<Message> | | | [numberFormats](./vue-i18n.composer.numberformats.md) | ComputedRef<NumberFormats> | | | [pluralRules](./vue-i18n.composer.pluralrules.md) | PluralizationRules | | | [warnHtmlMessage](./vue-i18n.composer.warnhtmlmessage.md) | boolean | | diff --git a/docs/vue-i18n.composer.mergelocalemessage.md b/docs/vue-i18n.composer.mergelocalemessage.md index f1a908391..f0a0ce9fe 100644 --- a/docs/vue-i18n.composer.mergelocalemessage.md +++ b/docs/vue-i18n.composer.mergelocalemessage.md @@ -7,7 +7,7 @@ Signature: ```typescript -mergeLocaleMessage(locale: Locale, message: LocaleMessage): void; +mergeLocaleMessage(locale: Locale, message: LocaleMessageDictionary): void; ``` ## Parameters @@ -15,7 +15,7 @@ mergeLocaleMessage(locale: Locale, message: LocaleMessage): void; | Parameter | Type | Description | | --- | --- | --- | | locale | Locale | | -| message | LocaleMessage | | +| message | LocaleMessageDictionary<Message> | | Returns: diff --git a/docs/vue-i18n.composer.messages.md b/docs/vue-i18n.composer.messages.md index 0ea55ece7..bd5cbaacc 100644 --- a/docs/vue-i18n.composer.messages.md +++ b/docs/vue-i18n.composer.messages.md @@ -7,5 +7,5 @@ Signature: ```typescript -readonly messages: ComputedRef; +readonly messages: ComputedRef; ``` diff --git a/docs/vue-i18n.composer.modifiers.md b/docs/vue-i18n.composer.modifiers.md index 99fbd38f8..16fbde6fb 100644 --- a/docs/vue-i18n.composer.modifiers.md +++ b/docs/vue-i18n.composer.modifiers.md @@ -7,5 +7,5 @@ Signature: ```typescript -readonly modifiers: LinkedModifiers; +readonly modifiers: LinkedModifiers; ``` diff --git a/docs/vue-i18n.composer.setlocalemessage.md b/docs/vue-i18n.composer.setlocalemessage.md index e646de36b..287922df8 100644 --- a/docs/vue-i18n.composer.setlocalemessage.md +++ b/docs/vue-i18n.composer.setlocalemessage.md @@ -7,7 +7,7 @@ Signature: ```typescript -setLocaleMessage(locale: Locale, message: LocaleMessage): void; +setLocaleMessage(locale: Locale, message: LocaleMessageDictionary): void; ``` ## Parameters @@ -15,7 +15,7 @@ setLocaleMessage(locale: Locale, message: LocaleMessage): void; | Parameter | Type | Description | | --- | --- | --- | | locale | Locale | | -| message | LocaleMessage | | +| message | LocaleMessageDictionary<Message> | | Returns: diff --git a/docs/vue-i18n.composer.setposttranslationhandler.md b/docs/vue-i18n.composer.setposttranslationhandler.md index 51dd0bd1d..c309bf7b4 100644 --- a/docs/vue-i18n.composer.setposttranslationhandler.md +++ b/docs/vue-i18n.composer.setposttranslationhandler.md @@ -7,14 +7,14 @@ Signature: ```typescript -setPostTranslationHandler(handler: PostTranslationHandler | null): void; +setPostTranslationHandler(handler: PostTranslationHandler | null): void; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | -| handler | PostTranslationHandler | null | | +| handler | PostTranslationHandler<Message> | null | | Returns: diff --git a/docs/vue-i18n.composeroptions.datetimeformats.md b/docs/vue-i18n.composeroptions.datetimeformats.md index befbfa38a..b45cab0e5 100644 --- a/docs/vue-i18n.composeroptions.datetimeformats.md +++ b/docs/vue-i18n.composeroptions.datetimeformats.md @@ -7,5 +7,5 @@ Signature: ```typescript -datetimeFormats?: DateTimeFormats; +datetimeFormats?: DateTimeFormatsType; ``` diff --git a/docs/vue-i18n.composeroptions.md b/docs/vue-i18n.composeroptions.md index 847704ae3..45c59ce33 100644 --- a/docs/vue-i18n.composeroptions.md +++ b/docs/vue-i18n.composeroptions.md @@ -9,7 +9,7 @@ Composer Options Signature: ```typescript -export interface ComposerOptions +export interface ComposerOptions ``` ## Remarks @@ -20,19 +20,19 @@ This is options to create composer. | Property | Type | Description | | --- | --- | --- | -| [datetimeFormats](./vue-i18n.composeroptions.datetimeformats.md) | DateTimeFormats | | +| [datetimeFormats](./vue-i18n.composeroptions.datetimeformats.md) | DateTimeFormatsType | | | [fallbackFormat](./vue-i18n.composeroptions.fallbackformat.md) | boolean | | | [fallbackLocale](./vue-i18n.composeroptions.fallbacklocale.md) | FallbackLocale | | | [fallbackRoot](./vue-i18n.composeroptions.fallbackroot.md) | boolean | | | [fallbackWarn](./vue-i18n.composeroptions.fallbackwarn.md) | boolean | RegExp | | | [inheritLocale](./vue-i18n.composeroptions.inheritlocale.md) | boolean | | | [locale](./vue-i18n.composeroptions.locale.md) | Locale | | -| [messages](./vue-i18n.composeroptions.messages.md) | LocaleMessages | | +| [messages](./vue-i18n.composeroptions.messages.md) | LocaleMessages<Message> | | | [missing](./vue-i18n.composeroptions.missing.md) | MissingHandler | | | [missingWarn](./vue-i18n.composeroptions.missingwarn.md) | boolean | RegExp | | -| [modifiers](./vue-i18n.composeroptions.modifiers.md) | LinkedModifiers | | -| [numberFormats](./vue-i18n.composeroptions.numberformats.md) | NumberFormats | | +| [modifiers](./vue-i18n.composeroptions.modifiers.md) | LinkedModifiers<Message> | | +| [numberFormats](./vue-i18n.composeroptions.numberformats.md) | NumberFormatsType | | | [pluralRules](./vue-i18n.composeroptions.pluralrules.md) | PluralizationRules | | -| [postTranslation](./vue-i18n.composeroptions.posttranslation.md) | PostTranslationHandler | | +| [postTranslation](./vue-i18n.composeroptions.posttranslation.md) | PostTranslationHandler<Message> | | | [warnHtmlMessage](./vue-i18n.composeroptions.warnhtmlmessage.md) | boolean | | diff --git a/docs/vue-i18n.composeroptions.messages.md b/docs/vue-i18n.composeroptions.messages.md index 4b260c3e3..b72dfc0e0 100644 --- a/docs/vue-i18n.composeroptions.messages.md +++ b/docs/vue-i18n.composeroptions.messages.md @@ -7,5 +7,5 @@ Signature: ```typescript -messages?: LocaleMessages; +messages?: LocaleMessages; ``` diff --git a/docs/vue-i18n.composeroptions.modifiers.md b/docs/vue-i18n.composeroptions.modifiers.md index 66fcb6e79..5159817c4 100644 --- a/docs/vue-i18n.composeroptions.modifiers.md +++ b/docs/vue-i18n.composeroptions.modifiers.md @@ -7,5 +7,5 @@ Signature: ```typescript -modifiers?: LinkedModifiers; +modifiers?: LinkedModifiers; ``` diff --git a/docs/vue-i18n.composeroptions.numberformats.md b/docs/vue-i18n.composeroptions.numberformats.md index bcadaa30d..5dc0298e6 100644 --- a/docs/vue-i18n.composeroptions.numberformats.md +++ b/docs/vue-i18n.composeroptions.numberformats.md @@ -7,5 +7,5 @@ Signature: ```typescript -numberFormats?: NumberFormats; +numberFormats?: NumberFormatsType; ``` diff --git a/docs/vue-i18n.composeroptions.posttranslation.md b/docs/vue-i18n.composeroptions.posttranslation.md index 827dd752b..83473f530 100644 --- a/docs/vue-i18n.composeroptions.posttranslation.md +++ b/docs/vue-i18n.composeroptions.posttranslation.md @@ -7,5 +7,5 @@ Signature: ```typescript -postTranslation?: PostTranslationHandler; +postTranslation?: PostTranslationHandler; ``` diff --git a/docs/vue-i18n.createi18n.md b/docs/vue-i18n.createi18n.md index c967bf716..a658d70c6 100644 --- a/docs/vue-i18n.createi18n.md +++ b/docs/vue-i18n.createi18n.md @@ -9,18 +9,18 @@ I18n factory function Signature: ```typescript -export declare function createI18n(options?: I18nOptions): I18n; +export declare function createI18n> = Record>, DateTimeFormats extends Record = Record, NumberFormats extends Record = Record>(options?: Options): I18n; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | -| options | I18nOptions | see the [I18nOptions](./vue-i18n.i18noptions.md) | +| options | Options | see the [I18nOptions](./vue-i18n.i18noptions.md) | Returns: -`I18n` +`I18n` [I18n](./vue-i18n.i18n.md) object diff --git a/docs/vue-i18n.createruntimecontext.md b/docs/vue-i18n.createruntimecontext.md new file mode 100644 index 000000000..a838f8e87 --- /dev/null +++ b/docs/vue-i18n.createruntimecontext.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [createRuntimeContext](./vue-i18n.createruntimecontext.md) + +## createRuntimeContext() function + +Signature: + +```typescript +export declare function createRuntimeContext = object, Messages extends Record> = Record>, DateTimeFormats extends Record = Record, NumberFormats extends Record = Record>(options?: Options): RuntimeContext; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| options | Options | | + +Returns: + +`RuntimeContext` + diff --git a/docs/vue-i18n.currencydisplay.md b/docs/vue-i18n.currencydisplay.md deleted file mode 100644 index 1ded3ecbc..000000000 --- a/docs/vue-i18n.currencydisplay.md +++ /dev/null @@ -1,13 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [CurrencyDisplay](./vue-i18n.currencydisplay.md) - -## CurrencyDisplay type - -number - -Signature: - -```typescript -export declare type CurrencyDisplay = 'symbol' | 'code' | 'name'; -``` diff --git a/docs/vue-i18n.currencynumberformatoptions.currency.md b/docs/vue-i18n.currencynumberformatoptions.currency.md deleted file mode 100644 index 86fb99a13..000000000 --- a/docs/vue-i18n.currencynumberformatoptions.currency.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [CurrencyNumberFormatOptions](./vue-i18n.currencynumberformatoptions.md) > [currency](./vue-i18n.currencynumberformatoptions.currency.md) - -## CurrencyNumberFormatOptions.currency property - -Signature: - -```typescript -currency: string; -``` diff --git a/docs/vue-i18n.currencynumberformatoptions.currencydisplay.md b/docs/vue-i18n.currencynumberformatoptions.currencydisplay.md deleted file mode 100644 index b3b6f31ba..000000000 --- a/docs/vue-i18n.currencynumberformatoptions.currencydisplay.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [CurrencyNumberFormatOptions](./vue-i18n.currencynumberformatoptions.md) > [currencyDisplay](./vue-i18n.currencynumberformatoptions.currencydisplay.md) - -## CurrencyNumberFormatOptions.currencyDisplay property - -Signature: - -```typescript -currencyDisplay?: CurrencyDisplay; -``` diff --git a/docs/vue-i18n.currencynumberformatoptions.formatmatcher.md b/docs/vue-i18n.currencynumberformatoptions.formatmatcher.md deleted file mode 100644 index 47ec04d34..000000000 --- a/docs/vue-i18n.currencynumberformatoptions.formatmatcher.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [CurrencyNumberFormatOptions](./vue-i18n.currencynumberformatoptions.md) > [formatMatcher](./vue-i18n.currencynumberformatoptions.formatmatcher.md) - -## CurrencyNumberFormatOptions.formatMatcher property - -Signature: - -```typescript -formatMatcher?: 'basic' | 'best-fit'; -``` diff --git a/docs/vue-i18n.currencynumberformatoptions.localematcher.md b/docs/vue-i18n.currencynumberformatoptions.localematcher.md deleted file mode 100644 index 4caedbf12..000000000 --- a/docs/vue-i18n.currencynumberformatoptions.localematcher.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [CurrencyNumberFormatOptions](./vue-i18n.currencynumberformatoptions.md) > [localeMatcher](./vue-i18n.currencynumberformatoptions.localematcher.md) - -## CurrencyNumberFormatOptions.localeMatcher property - -Signature: - -```typescript -localeMatcher?: 'lookup' | 'best-fit'; -``` diff --git a/docs/vue-i18n.currencynumberformatoptions.md b/docs/vue-i18n.currencynumberformatoptions.md deleted file mode 100644 index 5098277d7..000000000 --- a/docs/vue-i18n.currencynumberformatoptions.md +++ /dev/null @@ -1,22 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [CurrencyNumberFormatOptions](./vue-i18n.currencynumberformatoptions.md) - -## CurrencyNumberFormatOptions interface - -Signature: - -```typescript -export interface CurrencyNumberFormatOptions extends Intl.NumberFormatOptions -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [currency](./vue-i18n.currencynumberformatoptions.currency.md) | string | | -| [currencyDisplay](./vue-i18n.currencynumberformatoptions.currencydisplay.md) | CurrencyDisplay | | -| [formatMatcher](./vue-i18n.currencynumberformatoptions.formatmatcher.md) | 'basic' | 'best-fit' | | -| [localeMatcher](./vue-i18n.currencynumberformatoptions.localematcher.md) | 'lookup' | 'best-fit' | | -| [style](./vue-i18n.currencynumberformatoptions.style.md) | 'currency' | | - diff --git a/docs/vue-i18n.currencynumberformatoptions.style.md b/docs/vue-i18n.currencynumberformatoptions.style.md deleted file mode 100644 index 01de5a709..000000000 --- a/docs/vue-i18n.currencynumberformatoptions.style.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [CurrencyNumberFormatOptions](./vue-i18n.currencynumberformatoptions.md) > [style](./vue-i18n.currencynumberformatoptions.style.md) - -## CurrencyNumberFormatOptions.style property - -Signature: - -```typescript -style: 'currency'; -``` diff --git a/docs/vue-i18n.customblocks.md b/docs/vue-i18n.customblocks.md new file mode 100644 index 000000000..e00e40923 --- /dev/null +++ b/docs/vue-i18n.customblocks.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [CustomBlocks](./vue-i18n.customblocks.md) + +## CustomBlocks type + +Signature: + +```typescript +export declare type CustomBlocks = Array> | PreCompileHandler; +``` diff --git a/docs/vue-i18n.datetime.md b/docs/vue-i18n.datetime.md new file mode 100644 index 000000000..447afe5bc --- /dev/null +++ b/docs/vue-i18n.datetime.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [datetime](./vue-i18n.datetime.md) + +## datetime() function + +Signature: + +```typescript +export declare function datetime(context: RuntimeDateTimeContext, value: number | Date): string | number | Intl.DateTimeFormatPart[]; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeDateTimeContext<DateTimeFormats, Message> | | +| value | number | Date | | + +Returns: + +`string | number | Intl.DateTimeFormatPart[]` + diff --git a/docs/vue-i18n.datetime_1.md b/docs/vue-i18n.datetime_1.md new file mode 100644 index 000000000..3ae2f337d --- /dev/null +++ b/docs/vue-i18n.datetime_1.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [datetime](./vue-i18n.datetime_1.md) + +## datetime() function + +Signature: + +```typescript +export declare function datetime(context: RuntimeDateTimeContext, value: number | Date, key: string): string | number | Intl.DateTimeFormatPart[]; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeDateTimeContext<DateTimeFormats, Message> | | +| value | number | Date | | +| key | string | | + +Returns: + +`string | number | Intl.DateTimeFormatPart[]` + diff --git a/docs/vue-i18n.datetime_2.md b/docs/vue-i18n.datetime_2.md new file mode 100644 index 000000000..1d6559d82 --- /dev/null +++ b/docs/vue-i18n.datetime_2.md @@ -0,0 +1,25 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [datetime](./vue-i18n.datetime_2.md) + +## datetime() function + +Signature: + +```typescript +export declare function datetime(context: RuntimeDateTimeContext, value: number | Date, key: string, locale: Locale): string | number | Intl.DateTimeFormatPart[]; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeDateTimeContext<DateTimeFormats, Message> | | +| value | number | Date | | +| key | string | | +| locale | Locale | | + +Returns: + +`string | number | Intl.DateTimeFormatPart[]` + diff --git a/docs/vue-i18n.datetime_3.md b/docs/vue-i18n.datetime_3.md new file mode 100644 index 000000000..29e5fb742 --- /dev/null +++ b/docs/vue-i18n.datetime_3.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [datetime](./vue-i18n.datetime_3.md) + +## datetime() function + +Signature: + +```typescript +export declare function datetime(context: RuntimeDateTimeContext, value: number | Date, options: DateTimeOptions): string | number | Intl.DateTimeFormatPart[]; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeDateTimeContext<DateTimeFormats, Message> | | +| value | number | Date | | +| options | DateTimeOptions | | + +Returns: + +`string | number | Intl.DateTimeFormatPart[]` + diff --git a/docs/vue-i18n.datetime_4.md b/docs/vue-i18n.datetime_4.md new file mode 100644 index 000000000..0f7917fab --- /dev/null +++ b/docs/vue-i18n.datetime_4.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [datetime](./vue-i18n.datetime_4.md) + +## datetime() function + +Signature: + +```typescript +export declare function datetime(context: RuntimeDateTimeContext, ...args: unknown[]): string | number | Intl.DateTimeFormatPart[]; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeDateTimeContext<DateTimeFormats, Message> | | +| args | unknown[] | | + +Returns: + +`string | number | Intl.DateTimeFormatPart[]` + diff --git a/docs/vue-i18n.datetimedigital.md b/docs/vue-i18n.datetimedigital.md deleted file mode 100644 index 2249e1587..000000000 --- a/docs/vue-i18n.datetimedigital.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [DateTimeDigital](./vue-i18n.datetimedigital.md) - -## DateTimeDigital type - -Signature: - -```typescript -export declare type DateTimeDigital = 'numeric' | '2-digit'; -``` diff --git a/docs/vue-i18n.datetimeformat.md b/docs/vue-i18n.datetimeformat.md index 575de4518..21b6a94d5 100644 --- a/docs/vue-i18n.datetimeformat.md +++ b/docs/vue-i18n.datetimeformat.md @@ -1,13 +1,81 @@ -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [DateTimeFormat](./vue-i18n.datetimeformat.md) +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [DatetimeFormat](./vue-i18n.datetimeformat.md) -## DateTimeFormat type +## DatetimeFormat variable Signature: ```typescript -export declare type DateTimeFormat = { - [key: string]: DateTimeFormatOptions; -}; +DatetimeFormat: (new () => import("vue").ComponentPublicInstance<{ + value: number | Date; + scope: "parent" | "global"; +} & { + format?: Intl.DateTimeFormatOptions | undefined; + tag?: string | undefined; + locale?: string | undefined; +}, import("vue").RenderFunction, {}, {}, {}, Record any) | null>, import("vue").VNodeProps & { + value: number | Date; +} & { + format?: Intl.DateTimeFormatOptions | undefined; + tag?: string | undefined; + locale?: string | undefined; + scope?: "parent" | "global" | undefined; +}, import("vue").ComponentOptionsBase<{ + value: number | Date; + scope: "parent" | "global"; +} & { + format?: Intl.DateTimeFormatOptions | undefined; + tag?: string | undefined; + locale?: string | undefined; +}, import("vue").RenderFunction, unknown, {}, {}, import("vue").ComponentOptionsBase, import("vue").ComponentOptionsBase, Record any) | null>, string>>) & import("vue").ComponentOptionsBase, import("vue").RenderFunction, unknown, {}, {}, import("vue").ComponentOptionsBase, import("vue").ComponentOptionsBase, Record any) | null>, string> & { + props: { + value: { + type: PropType; + required: true; + }; + format: { + type: PropType; + }; + tag: { + type: StringConstructor; + }; + locale: { + type: StringConstructor; + }; + scope: { + type: PropType<"parent" | "global">; + validator: (val: "parent" | "global") => boolean; + default: "parent" | "global"; + }; + }; +} & ThisType, import("vue").RenderFunction, {}, {}, {}, Record any) | null>, Readonly<{ + value: number | Date; + scope: "parent" | "global"; +} & { + format?: Intl.DateTimeFormatOptions | undefined; + tag?: string | undefined; + locale?: string | undefined; +}>, import("vue").ComponentOptionsBase, import("vue").RenderFunction, unknown, {}, {}, import("vue").ComponentOptionsBase, import("vue").ComponentOptionsBase, Record any) | null>, string>>> ``` diff --git a/docs/vue-i18n.datetimeformatoptions.md b/docs/vue-i18n.datetimeformatoptions.md deleted file mode 100644 index 8abed432d..000000000 --- a/docs/vue-i18n.datetimeformatoptions.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [DateTimeFormatOptions](./vue-i18n.datetimeformatoptions.md) - -## DateTimeFormatOptions type - -Signature: - -```typescript -export declare type DateTimeFormatOptions = Intl.DateTimeFormatOptions | SpecificDateTimeFormatOptions; -``` diff --git a/docs/vue-i18n.datetimeformatprops.md b/docs/vue-i18n.datetimeformatprops.md new file mode 100644 index 000000000..97eb528b9 --- /dev/null +++ b/docs/vue-i18n.datetimeformatprops.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [DatetimeFormatProps](./vue-i18n.datetimeformatprops.md) + +## DatetimeFormatProps type + +Signature: + +```typescript +export declare type DatetimeFormatProps = FormattableProps; +``` diff --git a/docs/vue-i18n.datetimehumanreadable.md b/docs/vue-i18n.datetimehumanreadable.md deleted file mode 100644 index 9d8658ccd..000000000 --- a/docs/vue-i18n.datetimehumanreadable.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [DateTimeHumanReadable](./vue-i18n.datetimehumanreadable.md) - -## DateTimeHumanReadable type - -Signature: - -```typescript -export declare type DateTimeHumanReadable = 'long' | 'short' | 'narrow'; -``` diff --git a/docs/vue-i18n.datetimeoptions.md b/docs/vue-i18n.datetimeoptions.md new file mode 100644 index 000000000..6dd8e2dd9 --- /dev/null +++ b/docs/vue-i18n.datetimeoptions.md @@ -0,0 +1,37 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [DateTimeOptions](./vue-i18n.datetimeoptions.md) + +## DateTimeOptions type + +\# datetime + +\#\# usages: // for example `context.datetimeFormats` below 'en-US': { short: { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' } }, 'ja-JP': { ... } + +// datetimeable value only datetime(context, value) + +// key argument datetime(context, value, 'short') + +// key & locale argument datetime(context, value, 'short', 'ja-JP') + +// object sytle argument datetime(context, value, { key: 'short', locale: 'ja-JP' }) + +// suppress localize miss warning option, override context.missingWarn datetime(context, value, { key: 'short', locale: 'ja-JP', missingWarn: false }) + +// suppress localize fallback warning option, override context.fallbackWarn datetime(context, value, { key: 'short', locale: 'ja-JP', fallbackWarn: false }) + +// if you specify `part` options, you can get an array of objects containing the formatted datetime in parts datetime(context, value, { key: 'short', part: true }) + +// orverride context.datetimeFormats\[locale\] options with functino options datetime(cnotext, value, 'short', { currency: 'EUR' }) datetime(cnotext, value, 'short', 'ja-JP', { currency: 'EUR' }) datetime(context, value, { key: 'short', part: true }, { currency: 'EUR'}) + +Signature: + +```typescript +export declare type DateTimeOptions = { + key?: string; + locale?: Locale; + missingWarn?: boolean; + fallbackWarn?: boolean; + part?: boolean; +}; +``` diff --git a/docs/vue-i18n.formattableprops.format.md b/docs/vue-i18n.formattableprops.format.md new file mode 100644 index 000000000..50e226497 --- /dev/null +++ b/docs/vue-i18n.formattableprops.format.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [FormattableProps](./vue-i18n.formattableprops.md) > [format](./vue-i18n.formattableprops.format.md) + +## FormattableProps.format property + +Signature: + +```typescript +format?: string | Format; +``` diff --git a/docs/vue-i18n.formattableprops.md b/docs/vue-i18n.formattableprops.md new file mode 100644 index 000000000..0b4152d2e --- /dev/null +++ b/docs/vue-i18n.formattableprops.md @@ -0,0 +1,19 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [FormattableProps](./vue-i18n.formattableprops.md) + +## FormattableProps interface + +Signature: + +```typescript +export interface FormattableProps extends BaseFormatProps +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [format](./vue-i18n.formattableprops.format.md) | string | Format | | +| [value](./vue-i18n.formattableprops.value.md) | Value | | + diff --git a/docs/vue-i18n.formattableprops.value.md b/docs/vue-i18n.formattableprops.value.md new file mode 100644 index 000000000..1ea41611b --- /dev/null +++ b/docs/vue-i18n.formattableprops.value.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [FormattableProps](./vue-i18n.formattableprops.md) > [value](./vue-i18n.formattableprops.value.md) + +## FormattableProps.value property + +Signature: + +```typescript +value: Value; +``` diff --git a/docs/vue-i18n.formattednumberpart.md b/docs/vue-i18n.formattednumberpart.md deleted file mode 100644 index 86220a7ec..000000000 --- a/docs/vue-i18n.formattednumberpart.md +++ /dev/null @@ -1,14 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [FormattedNumberPart](./vue-i18n.formattednumberpart.md) - -## FormattedNumberPart type - -Signature: - -```typescript -export declare type FormattedNumberPart = { - type: FormattedNumberPartType; - value: string; -}; -``` diff --git a/docs/vue-i18n.formattednumberparttype.md b/docs/vue-i18n.formattednumberparttype.md deleted file mode 100644 index 7319564b0..000000000 --- a/docs/vue-i18n.formattednumberparttype.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [FormattedNumberPartType](./vue-i18n.formattednumberparttype.md) - -## FormattedNumberPartType type - -Signature: - -```typescript -export declare type FormattedNumberPartType = 'currency' | 'decimal' | 'fraction' | 'group' | 'infinity' | 'integer' | 'literal' | 'minusSign' | 'nan' | 'plusSign' | 'percentSign'; -``` diff --git a/docs/vue-i18n.getlocalechain.md b/docs/vue-i18n.getlocalechain.md new file mode 100644 index 000000000..9e91ec2b1 --- /dev/null +++ b/docs/vue-i18n.getlocalechain.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [getLocaleChain](./vue-i18n.getlocalechain.md) + +## getLocaleChain() function + +Signature: + +```typescript +export declare function getLocaleChain(ctx: RuntimeCommonContext, fallback: FallbackLocale, start?: Locale): Locale[]; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| ctx | RuntimeCommonContext<Message> | | +| fallback | FallbackLocale | | +| start | Locale | | + +Returns: + +`Locale[]` + diff --git a/docs/vue-i18n.handlemissing.md b/docs/vue-i18n.handlemissing.md new file mode 100644 index 000000000..429b75432 --- /dev/null +++ b/docs/vue-i18n.handlemissing.md @@ -0,0 +1,26 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [handleMissing](./vue-i18n.handlemissing.md) + +## handleMissing() function + +Signature: + +```typescript +export declare function handleMissing(context: RuntimeCommonContext, key: Path, locale: Locale, missingWarn: boolean | RegExp, type: RuntimeMissingType): unknown; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeCommonContext<Message> | | +| key | Path | | +| locale | Locale | | +| missingWarn | boolean | RegExp | | +| type | RuntimeMissingType | | + +Returns: + +`unknown` + diff --git a/docs/vue-i18n.i18n.global.md b/docs/vue-i18n.i18n.global.md index ecaac4e3c..62528c3e0 100644 --- a/docs/vue-i18n.i18n.global.md +++ b/docs/vue-i18n.i18n.global.md @@ -9,5 +9,5 @@ Global composer Signature: ```typescript -readonly global: Composer; +readonly global: Composer; ``` diff --git a/docs/vue-i18n.i18n.md b/docs/vue-i18n.i18n.md index bb3100d16..e3832680d 100644 --- a/docs/vue-i18n.i18n.md +++ b/docs/vue-i18n.i18n.md @@ -9,13 +9,13 @@ I18n interface Signature: ```typescript -export interface I18n +export interface I18n ``` ## Properties | Property | Type | Description | | --- | --- | --- | -| [global](./vue-i18n.i18n.global.md) | Composer | Global composer | +| [global](./vue-i18n.i18n.global.md) | Composer<Messages, DateTimeFormats, NumberFormats> | Global composer | | [mode](./vue-i18n.i18n.mode.md) | I18nMode | I18n API mode | diff --git a/docs/vue-i18n.i18n.mode.md b/docs/vue-i18n.i18n.mode.md index 83e9edf04..ceaf79025 100644 --- a/docs/vue-i18n.i18n.mode.md +++ b/docs/vue-i18n.i18n.mode.md @@ -16,3 +16,5 @@ readonly mode: I18nMode; if you specified `legacy: true` option in `createI18n`, return `legacy`, else `composable` + composable + diff --git a/docs/vue-i18n.i18nadditionaloptions.legacy.md b/docs/vue-i18n.i18nadditionaloptions.legacy.md index e59e2ad1e..b724d02c2 100644 --- a/docs/vue-i18n.i18nadditionaloptions.legacy.md +++ b/docs/vue-i18n.i18nadditionaloptions.legacy.md @@ -6,6 +6,8 @@ Whether vue-i18n legacy API use on your Vue App. + false + Signature: ```typescript diff --git a/docs/vue-i18n.i18nadditionaloptions.md b/docs/vue-i18n.i18nadditionaloptions.md index b36cfbc20..ca56feb01 100644 --- a/docs/vue-i18n.i18nadditionaloptions.md +++ b/docs/vue-i18n.i18nadditionaloptions.md @@ -16,5 +16,5 @@ export interface I18nAdditionalOptions | Property | Type | Description | | --- | --- | --- | -| [legacy](./vue-i18n.i18nadditionaloptions.legacy.md) | boolean | Whether vue-i18n legacy API use on your Vue App. | +| [legacy](./vue-i18n.i18nadditionaloptions.legacy.md) | boolean | Whether vue-i18n legacy API use on your Vue App. false | diff --git a/docs/vue-i18n.i18npluginoptions._i18n-t_.md b/docs/vue-i18n.i18npluginoptions._i18n-t_.md deleted file mode 100644 index 75d7e7c6a..000000000 --- a/docs/vue-i18n.i18npluginoptions._i18n-t_.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [I18nPluginOptions](./vue-i18n.i18npluginoptions.md) > ["i18n-t"](./vue-i18n.i18npluginoptions._i18n-t_.md) - -## I18nPluginOptions."i18n-t" property - -Signature: - -```typescript -'i18n-t'?: string; -``` diff --git a/docs/vue-i18n.i18npluginoptions.globalinstall.md b/docs/vue-i18n.i18npluginoptions.globalinstall.md new file mode 100644 index 000000000..69ad63c53 --- /dev/null +++ b/docs/vue-i18n.i18npluginoptions.globalinstall.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [I18nPluginOptions](./vue-i18n.i18npluginoptions.md) > [globalInstall](./vue-i18n.i18npluginoptions.globalinstall.md) + +## I18nPluginOptions.globalInstall property + +Signature: + +```typescript +globalInstall?: boolean; +``` diff --git a/docs/vue-i18n.i18npluginoptions.md b/docs/vue-i18n.i18npluginoptions.md index 4783f28e7..8d0ae2abb 100644 --- a/docs/vue-i18n.i18npluginoptions.md +++ b/docs/vue-i18n.i18npluginoptions.md @@ -20,5 +20,6 @@ An options specified when installing vue-i18n as Vue plugin with using `app.use` | Property | Type | Description | | --- | --- | --- | -| ["i18n-t"](./vue-i18n.i18npluginoptions._i18n-t_.md) | string | | +| [globalInstall](./vue-i18n.i18npluginoptions.globalinstall.md) | boolean | | +| [useI18nComponentName](./vue-i18n.i18npluginoptions.usei18ncomponentname.md) | boolean | | diff --git a/docs/vue-i18n.i18npluginoptions.usei18ncomponentname.md b/docs/vue-i18n.i18npluginoptions.usei18ncomponentname.md new file mode 100644 index 000000000..b6f8884c1 --- /dev/null +++ b/docs/vue-i18n.i18npluginoptions.usei18ncomponentname.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [I18nPluginOptions](./vue-i18n.i18npluginoptions.md) > [useI18nComponentName](./vue-i18n.i18npluginoptions.usei18ncomponentname.md) + +## I18nPluginOptions.useI18nComponentName property + +Signature: + +```typescript +useI18nComponentName?: boolean; +``` diff --git a/docs/vue-i18n.intlavailability.md b/docs/vue-i18n.intlavailability.md deleted file mode 100644 index 864a463bd..000000000 --- a/docs/vue-i18n.intlavailability.md +++ /dev/null @@ -1,16 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [IntlAvailability](./vue-i18n.intlavailability.md) - -## IntlAvailability type - -datetime - -Signature: - -```typescript -export declare type IntlAvailability = { - dateTimeFormat: boolean; - numberFormat: boolean; -}; -``` diff --git a/docs/vue-i18n.istranslatemissingwarn.md b/docs/vue-i18n.istranslatemissingwarn.md new file mode 100644 index 000000000..eecb2906b --- /dev/null +++ b/docs/vue-i18n.istranslatemissingwarn.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [isTranslateMissingWarn](./vue-i18n.istranslatemissingwarn.md) + +## isTranslateMissingWarn() function + +Signature: + +```typescript +export declare function isTranslateMissingWarn(missing: boolean | RegExp, key: Path): boolean; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| missing | boolean | RegExp | | +| key | Path | | + +Returns: + +`boolean` + diff --git a/docs/vue-i18n.istrarnslatefallbackwarn.md b/docs/vue-i18n.istrarnslatefallbackwarn.md new file mode 100644 index 000000000..9d28d8409 --- /dev/null +++ b/docs/vue-i18n.istrarnslatefallbackwarn.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [isTrarnslateFallbackWarn](./vue-i18n.istrarnslatefallbackwarn.md) + +## isTrarnslateFallbackWarn() function + +Signature: + +```typescript +export declare function isTrarnslateFallbackWarn(fallback: boolean | RegExp, key: Path): boolean; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| fallback | boolean | RegExp | | +| key | Path | | + +Returns: + +`boolean` + diff --git a/docs/vue-i18n.linkedmodifiers.md b/docs/vue-i18n.linkedmodifiers.md index ea5ea7e5c..622cf84b7 100644 --- a/docs/vue-i18n.linkedmodifiers.md +++ b/docs/vue-i18n.linkedmodifiers.md @@ -7,7 +7,7 @@ Signature: ```typescript -export declare type LinkedModifiers = { - [key: string]: LinkedModify; +export declare type LinkedModifiers = { + [key: string]: LinkedModify; }; ``` diff --git a/docs/vue-i18n.localemessage.md b/docs/vue-i18n.localemessage.md deleted file mode 100644 index 49c113752..000000000 --- a/docs/vue-i18n.localemessage.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [LocaleMessage](./vue-i18n.localemessage.md) - -## LocaleMessage type - -Signature: - -```typescript -export declare type LocaleMessage = string | MessageFunction | LocaleMessageDictionary | LocaleMessage[]; -``` diff --git a/docs/vue-i18n.localemessagearray.md b/docs/vue-i18n.localemessagearray.md new file mode 100644 index 000000000..721c8893e --- /dev/null +++ b/docs/vue-i18n.localemessagearray.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [LocaleMessageArray](./vue-i18n.localemessagearray.md) + +## LocaleMessageArray interface + +Signature: + +```typescript +export interface LocaleMessageArray extends Array> +``` diff --git a/docs/vue-i18n.localemessagedictionary.md b/docs/vue-i18n.localemessagedictionary.md index 9396273c1..c43ae613a 100644 --- a/docs/vue-i18n.localemessagedictionary.md +++ b/docs/vue-i18n.localemessagedictionary.md @@ -7,7 +7,7 @@ Signature: ```typescript -export declare type LocaleMessageDictionary = { - [property: string]: LocaleMessage; +export declare type LocaleMessageDictionary = { + [property: string]: LocaleMessageValue; }; ``` diff --git a/docs/vue-i18n.localemessageobject.md b/docs/vue-i18n.localemessageobject.md index 97f08fd55..2ff6cab41 100644 --- a/docs/vue-i18n.localemessageobject.md +++ b/docs/vue-i18n.localemessageobject.md @@ -7,5 +7,5 @@ Signature: ```typescript -export declare type LocaleMessageObject = LocaleMessageDictionary; +export declare type LocaleMessageObject = LocaleMessageDictionary; ``` diff --git a/docs/vue-i18n.localemessages.md b/docs/vue-i18n.localemessages.md index 8080bcffc..6596f8139 100644 --- a/docs/vue-i18n.localemessages.md +++ b/docs/vue-i18n.localemessages.md @@ -7,5 +7,5 @@ Signature: ```typescript -export declare type LocaleMessages = Record; +export declare type LocaleMessages = Record>; ``` diff --git a/docs/vue-i18n.localemessagevalue.md b/docs/vue-i18n.localemessagevalue.md new file mode 100644 index 000000000..fd7985da3 --- /dev/null +++ b/docs/vue-i18n.localemessagevalue.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [LocaleMessageValue](./vue-i18n.localemessagevalue.md) + +## LocaleMessageValue type + +Signature: + +```typescript +export declare type LocaleMessageValue = string | MessageFunction | LocaleMessageDictionary | LocaleMessageArray; +``` diff --git a/docs/vue-i18n.md b/docs/vue-i18n.md index cf2c1f57b..f7f220287 100644 --- a/docs/vue-i18n.md +++ b/docs/vue-i18n.md @@ -15,26 +15,72 @@ | Function | Description | | --- | --- | | [baseCompile(source, options)](./vue-i18n.basecompile.md) | | +| [clearCompileCache()](./vue-i18n.clearcompilecache.md) | | +| [clearDateTimeFormat(ctx, locale, format)](./vue-i18n.cleardatetimeformat.md) | | +| [clearNumberFormat(ctx, locale, format)](./vue-i18n.clearnumberformat.md) | | | [compile(source, options)](./vue-i18n.compile.md) | | | [createI18n(options)](./vue-i18n.createi18n.md) | I18n factory function | | [createParser(options)](./vue-i18n.createparser.md) | | +| [createRuntimeContext(options)](./vue-i18n.createruntimecontext.md) | | +| [datetime(context, value)](./vue-i18n.datetime.md) | | +| [datetime(context, value, key)](./vue-i18n.datetime_1.md) | | +| [datetime(context, value, key, locale)](./vue-i18n.datetime_2.md) | | +| [datetime(context, value, options)](./vue-i18n.datetime_3.md) | | +| [datetime(context, args)](./vue-i18n.datetime_4.md) | | +| [getLocaleChain(ctx, fallback, start)](./vue-i18n.getlocalechain.md) | | +| [handleMissing(context, key, locale, missingWarn, type)](./vue-i18n.handlemissing.md) | | +| [isTranslateMissingWarn(missing, key)](./vue-i18n.istranslatemissingwarn.md) | | +| [isTrarnslateFallbackWarn(fallback, key)](./vue-i18n.istrarnslatefallbackwarn.md) | | +| [number(context, value)](./vue-i18n.number.md) | | +| [number(context, value, key)](./vue-i18n.number_1.md) | | +| [number(context, value, key, locale)](./vue-i18n.number_2.md) | | +| [number(context, value, options)](./vue-i18n.number_3.md) | | +| [number(context, args)](./vue-i18n.number_4.md) | | +| [parseDateTimeArgs(args)](./vue-i18n.parsedatetimeargs.md) | | +| [parseNumberArgs(args)](./vue-i18n.parsenumberargs.md) | | +| [parseTranslateArgs(args)](./vue-i18n.parsetranslateargs.md) | | +| [translate(context, key)](./vue-i18n.translate.md) | | +| [translate(context, key, named)](./vue-i18n.translate_9.md) | | +| [translate(context, key, named, plural)](./vue-i18n.translate_10.md) | | +| [translate(context, key, named, defaultMsg)](./vue-i18n.translate_11.md) | | +| [translate(context, key, named, options)](./vue-i18n.translate_12.md) | | +| [translate(context, args)](./vue-i18n.translate_13.md) | | +| [translate(context, key, plural)](./vue-i18n.translate_1.md) | | +| [translate(context, key, plural, options)](./vue-i18n.translate_2.md) | | +| [translate(context, key, defaultMsg)](./vue-i18n.translate_3.md) | | +| [translate(context, key, defaultMsg, options)](./vue-i18n.translate_4.md) | | +| [translate(context, key, list)](./vue-i18n.translate_5.md) | | +| [translate(context, key, list, plural)](./vue-i18n.translate_6.md) | | +| [translate(context, key, list, defaultMsg)](./vue-i18n.translate_7.md) | | +| [translate(context, key, list, options)](./vue-i18n.translate_8.md) | | +| [updateFallbackLocale(ctx, locale, fallback)](./vue-i18n.updatefallbacklocale.md) | | | [useI18n(options)](./vue-i18n.usei18n.md) | Use Composable API starting function | ## Interfaces | Interface | Description | | --- | --- | +| [BaseFormatProps](./vue-i18n.baseformatprops.md) | | | [CompileError](./vue-i18n.compileerror.md) | | | [Composer](./vue-i18n.composer.md) | Composer Interfaces | | [ComposerAdditionalOptions](./vue-i18n.composeradditionaloptions.md) | Composer additional options for useI18n | | [ComposerOptions](./vue-i18n.composeroptions.md) | Composer Options | -| [CurrencyNumberFormatOptions](./vue-i18n.currencynumberformatoptions.md) | | +| [FormattableProps](./vue-i18n.formattableprops.md) | | | [Formatter](./vue-i18n.formatter.md) | | | [I18n](./vue-i18n.i18n.md) | I18n interface | | [I18nAdditionalOptions](./vue-i18n.i18nadditionaloptions.md) | I18n Additional Options for createI18n | | [I18nPluginOptions](./vue-i18n.i18npluginoptions.md) | I18n plugin options | -| [SpecificDateTimeFormatOptions](./vue-i18n.specificdatetimeformatoptions.md) | | -| [SpecificNumberFormatOptions](./vue-i18n.specificnumberformatoptions.md) | | +| [LocaleMessageArray](./vue-i18n.localemessagearray.md) | | +| [Parser](./vue-i18n.parser.md) | | +| [RuntimeCommonContext](./vue-i18n.runtimecommoncontext.md) | | +| [RuntimeContext](./vue-i18n.runtimecontext.md) | | +| [RuntimeDateTimeContext](./vue-i18n.runtimedatetimecontext.md) | | +| [RuntimeInternalContext](./vue-i18n.runtimeinternalcontext.md) | | +| [RuntimeInternalOptions](./vue-i18n.runtimeinternaloptions.md) | | +| [RuntimeNumberContext](./vue-i18n.runtimenumbercontext.md) | | +| [RuntimeOptions](./vue-i18n.runtimeoptions.md) | | +| [RuntimeTranslationContext](./vue-i18n.runtimetranslationcontext.md) | | +| [TranslationProps](./vue-i18n.translationprops.md) | | | [VueI18n](./vue-i18n.vuei18n.md) | VueI18n Interfaces | | [VueI18nOptions](./vue-i18n.vuei18noptions.md) | VueI18n Options | @@ -42,9 +88,13 @@ | Variable | Description | | --- | --- | -| [Availabilities](./vue-i18n.availabilities.md) | | +| [DatetimeFormat](./vue-i18n.datetimeformat.md) | | | [friendlyJSONstringify](./vue-i18n.friendlyjsonstringify.md) | | | [generateFormatCacheKey](./vue-i18n.generateformatcachekey.md) | | +| [MISSING\_RESOLVE\_VALUE](./vue-i18n.missing_resolve_value.md) | | +| [NOT\_REOSLVED](./vue-i18n.not_reoslved.md) | | +| [NumberFormat](./vue-i18n.numberformat.md) | | +| [Translation](./vue-i18n.translation.md) | | | [VERSION](./vue-i18n.version.md) | vue-i18n version | ## Type Aliases @@ -55,40 +105,38 @@ | [CompileDomain](./vue-i18n.compiledomain.md) | | | [CompileErrorHandler](./vue-i18n.compileerrorhandler.md) | | | [CompileOptions](./vue-i18n.compileoptions.md) | | -| [CurrencyDisplay](./vue-i18n.currencydisplay.md) | number | -| [DateTimeDigital](./vue-i18n.datetimedigital.md) | | -| [DateTimeFormat](./vue-i18n.datetimeformat.md) | | -| [DateTimeFormatOptions](./vue-i18n.datetimeformatoptions.md) | | +| [ComponetI18nScope](./vue-i18n.componeti18nscope.md) | | +| [CustomBlocks](./vue-i18n.customblocks.md) | | +| [DatetimeFormatProps](./vue-i18n.datetimeformatprops.md) | | | [DateTimeFormatResult](./vue-i18n.datetimeformatresult.md) | | | [DateTimeFormats](./vue-i18n.datetimeformats.md) | | -| [DateTimeHumanReadable](./vue-i18n.datetimehumanreadable.md) | | +| [DateTimeOptions](./vue-i18n.datetimeoptions.md) | \# datetime\#\# usages: // for example context.datetimeFormats below 'en-US': { short: { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' } }, 'ja-JP': { ... }// datetimeable value only datetime(context, value)// key argument datetime(context, value, 'short')// key & locale argument datetime(context, value, 'short', 'ja-JP')// object sytle argument datetime(context, value, { key: 'short', locale: 'ja-JP' })// suppress localize miss warning option, override context.missingWarn datetime(context, value, { key: 'short', locale: 'ja-JP', missingWarn: false })// suppress localize fallback warning option, override context.fallbackWarn datetime(context, value, { key: 'short', locale: 'ja-JP', fallbackWarn: false })// if you specify part options, you can get an array of objects containing the formatted datetime in parts datetime(context, value, { key: 'short', part: true })// orverride context.datetimeFormats\[locale\] options with functino options datetime(cnotext, value, 'short', { currency: 'EUR' }) datetime(cnotext, value, 'short', 'ja-JP', { currency: 'EUR' }) datetime(context, value, { key: 'short', part: true }, { currency: 'EUR'}) | | [FallbackLocale](./vue-i18n.fallbacklocale.md) | | -| [FormattedNumberPart](./vue-i18n.formattednumberpart.md) | | -| [FormattedNumberPartType](./vue-i18n.formattednumberparttype.md) | | | [I18nMode](./vue-i18n.i18nmode.md) | I18n API mode | | [I18nOptions](./vue-i18n.i18noptions.md) | I18n Options for createI18n | | [I18nScope](./vue-i18n.i18nscope.md) | I18n Scope | -| [IntlAvailability](./vue-i18n.intlavailability.md) | datetime | | [LinkedModifiers](./vue-i18n.linkedmodifiers.md) | | | [Locale](./vue-i18n.locale.md) | | -| [LocaleMessage](./vue-i18n.localemessage.md) | | | [LocaleMessageDictionary](./vue-i18n.localemessagedictionary.md) | | | [LocaleMessageObject](./vue-i18n.localemessageobject.md) | | | [LocaleMessages](./vue-i18n.localemessages.md) | | +| [LocaleMessageValue](./vue-i18n.localemessagevalue.md) | | +| [MessageCompiler](./vue-i18n.messagecompiler.md) | | | [MessageFunction](./vue-i18n.messagefunction.md) | | | [MessageFunctions](./vue-i18n.messagefunctions.md) | | | [MissingHandler](./vue-i18n.missinghandler.md) | | -| [NumberFormat](./vue-i18n.numberformat.md) | | -| [NumberFormatOptions](./vue-i18n.numberformatoptions.md) | | +| [NumberFormatProps](./vue-i18n.numberformatprops.md) | | | [NumberFormatResult](./vue-i18n.numberformatresult.md) | | | [NumberFormats](./vue-i18n.numberformats.md) | | -| [NumberFormatToPartsResult](./vue-i18n.numberformattopartsresult.md) | | -| [Parser](./vue-i18n.parser.md) | | +| [NumberOptions](./vue-i18n.numberoptions.md) | \# number\#\# usages // for example context.numberFormats below 'en-US': { 'currency': { style: 'currency', currency: 'USD', currencyDisplay: 'symbol' } }, 'ja-JP: { ... }// value only number(context, value)// key argument number(context, value, 'currency')// key & locale argument number(context, value, 'currency', 'ja-JP')// object sytle argument number(context, value, { key: 'currency', locale: 'ja-JP' })// suppress localize miss warning option, override context.missingWarn number(context, value, { key: 'currency', locale: 'ja-JP', missingWarn: false })// suppress localize fallback warning option, override context.fallbackWarn number(context, value, { key: 'currency', locale: 'ja-JP', fallbackWarn: false })// if you specify part options, you can get an array of objects containing the formatted number in parts number(context, value, { key: 'currenty', part: true })// orverride context.numberFormats\[locale\] options with functino options number(cnotext, value, 'currency', { year: '2-digit' }) number(cnotext, value, 'currency', 'ja-JP', { year: '2-digit' }) number(context, value, { key: 'currenty', part: true }, { year: '2-digit'}) | | [Path](./vue-i18n.path.md) | | | [PathValue](./vue-i18n.pathvalue.md) | | | [PluralizationRule](./vue-i18n.pluralizationrule.md) | | | [PluralizationRulesMap](./vue-i18n.pluralizationrulesmap.md) | | | [PostTranslationHandler](./vue-i18n.posttranslationhandler.md) | | +| [RuntimeMissingHandler](./vue-i18n.runtimemissinghandler.md) | | +| [RuntimeMissingType](./vue-i18n.runtimemissingtype.md) | | +| [TranslateOptions](./vue-i18n.translateoptions.md) | \# translate\#\# usages: // for example, locale messages key { 'foo.bar': 'hi {0} !' or 'hi {name} !' }// no argument, context & path only translate(context, 'foo.bar')// list argument translate(context, 'foo.bar', \['kazupon'\])// named argument translate(context, 'foo.bar', { name: 'kazupon' })// plural choice number translate(context, 'foo.bar', 2)// plural choice number with name argument translate(context, 'foo.bar', { name: 'kazupon' }, 2)// default message argument translate(context, 'foo.bar', 'this is default message')// default message with named argument translate(context, 'foo.bar', { name: 'kazupon' }, 'Hello {name} !')// use key as default message translate(context, 'hi {0} !', \['kazupon'\], { default: true })// locale option, override context.locale translate(context, 'foo.bar', { name: 'kazupon' }, { locale: 'ja' })// suppress localize miss warning option, override context.missingWarn translate(context, 'foo.bar', { name: 'kazupon' }, { missingWarn: false })// suppress localize fallback warning option, override context.fallbackWarn translate(context, 'foo.bar', { name: 'kazupon' }, { fallbackWarn: false }) | | [TranslateResult](./vue-i18n.translateresult.md) | | | [UseI18nOptions](./vue-i18n.usei18noptions.md) | I18n Options for useI18n | | [WarnHtmlInMessageLevel](./vue-i18n.warnhtmlinmessagelevel.md) | | diff --git a/docs/vue-i18n.messagecompiler.md b/docs/vue-i18n.messagecompiler.md new file mode 100644 index 000000000..2006a0848 --- /dev/null +++ b/docs/vue-i18n.messagecompiler.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [MessageCompiler](./vue-i18n.messagecompiler.md) + +## MessageCompiler type + +Signature: + +```typescript +export declare type MessageCompiler = (source: string, options?: CompileOptions) => MessageFunction; +``` diff --git a/docs/vue-i18n.messagefunction.md b/docs/vue-i18n.messagefunction.md index ec76ffc98..8c42fdd1f 100644 --- a/docs/vue-i18n.messagefunction.md +++ b/docs/vue-i18n.messagefunction.md @@ -7,10 +7,5 @@ Signature: ```typescript -export declare type MessageFunction = { - (ctx: MessageContext): unknown; - key?: string; - locale?: string; - source?: string; -}; +export declare type MessageFunction = MessageFunctionCallable | MessageFunctionInternal; ``` diff --git a/docs/vue-i18n.messagefunctions.md b/docs/vue-i18n.messagefunctions.md index e977b120f..fa3e6453e 100644 --- a/docs/vue-i18n.messagefunctions.md +++ b/docs/vue-i18n.messagefunctions.md @@ -7,5 +7,5 @@ Signature: ```typescript -export declare type MessageFunctions = Record; +export declare type MessageFunctions = Record>; ``` diff --git a/docs/vue-i18n.missing_resolve_value.md b/docs/vue-i18n.missing_resolve_value.md new file mode 100644 index 000000000..37404b527 --- /dev/null +++ b/docs/vue-i18n.missing_resolve_value.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [MISSING\_RESOLVE\_VALUE](./vue-i18n.missing_resolve_value.md) + +## MISSING\_RESOLVE\_VALUE variable + +Signature: + +```typescript +MISSING_RESOLVE_VALUE = "" +``` diff --git a/docs/vue-i18n.not_reoslved.md b/docs/vue-i18n.not_reoslved.md new file mode 100644 index 000000000..6d6a8b982 --- /dev/null +++ b/docs/vue-i18n.not_reoslved.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [NOT\_REOSLVED](./vue-i18n.not_reoslved.md) + +## NOT\_REOSLVED variable + +Signature: + +```typescript +NOT_REOSLVED = -1 +``` diff --git a/docs/vue-i18n.number.md b/docs/vue-i18n.number.md new file mode 100644 index 000000000..19622e120 --- /dev/null +++ b/docs/vue-i18n.number.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [number](./vue-i18n.number.md) + +## number() function + +Signature: + +```typescript +export declare function number(context: RuntimeNumberContext, value: number): string | number | Intl.NumberFormatPart[]; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeNumberContext<NumberFormats, Message> | | +| value | number | | + +Returns: + +`string | number | Intl.NumberFormatPart[]` + diff --git a/docs/vue-i18n.number_1.md b/docs/vue-i18n.number_1.md new file mode 100644 index 000000000..587644869 --- /dev/null +++ b/docs/vue-i18n.number_1.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [number](./vue-i18n.number_1.md) + +## number() function + +Signature: + +```typescript +export declare function number(context: RuntimeNumberContext, value: number, key: string): string | number | Intl.NumberFormatPart[]; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeNumberContext<NumberFormats, Message> | | +| value | number | | +| key | string | | + +Returns: + +`string | number | Intl.NumberFormatPart[]` + diff --git a/docs/vue-i18n.number_2.md b/docs/vue-i18n.number_2.md new file mode 100644 index 000000000..a9432df8a --- /dev/null +++ b/docs/vue-i18n.number_2.md @@ -0,0 +1,25 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [number](./vue-i18n.number_2.md) + +## number() function + +Signature: + +```typescript +export declare function number(context: RuntimeNumberContext, value: number, key: string, locale: Locale): string | number | Intl.NumberFormatPart[]; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeNumberContext<NumberFormats, Message> | | +| value | number | | +| key | string | | +| locale | Locale | | + +Returns: + +`string | number | Intl.NumberFormatPart[]` + diff --git a/docs/vue-i18n.number_3.md b/docs/vue-i18n.number_3.md new file mode 100644 index 000000000..80926fce3 --- /dev/null +++ b/docs/vue-i18n.number_3.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [number](./vue-i18n.number_3.md) + +## number() function + +Signature: + +```typescript +export declare function number(context: RuntimeNumberContext, value: number, options: NumberOptions): string | number | Intl.NumberFormatPart[]; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeNumberContext<NumberFormats, Message> | | +| value | number | | +| options | NumberOptions | | + +Returns: + +`string | number | Intl.NumberFormatPart[]` + diff --git a/docs/vue-i18n.number_4.md b/docs/vue-i18n.number_4.md new file mode 100644 index 000000000..50fd2a6b8 --- /dev/null +++ b/docs/vue-i18n.number_4.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [number](./vue-i18n.number_4.md) + +## number() function + +Signature: + +```typescript +export declare function number(context: RuntimeNumberContext, ...args: unknown[]): string | number | Intl.NumberFormatPart[]; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeNumberContext<NumberFormats, Message> | | +| args | unknown[] | | + +Returns: + +`string | number | Intl.NumberFormatPart[]` + diff --git a/docs/vue-i18n.numberformat.md b/docs/vue-i18n.numberformat.md index 99fd8f0c7..835de92fd 100644 --- a/docs/vue-i18n.numberformat.md +++ b/docs/vue-i18n.numberformat.md @@ -2,12 +2,80 @@ [Home](./index.md) > [vue-i18n](./vue-i18n.md) > [NumberFormat](./vue-i18n.numberformat.md) -## NumberFormat type +## NumberFormat variable Signature: ```typescript -export declare type NumberFormat = { - [key: string]: NumberFormatOptions; -}; +NumberFormat: (new () => import("vue").ComponentPublicInstance<{ + value: number; + scope: "parent" | "global"; +} & { + format?: Intl.NumberFormatOptions | undefined; + tag?: string | undefined; + locale?: string | undefined; +}, import("vue").RenderFunction, {}, {}, {}, Record any) | null>, import("vue").VNodeProps & { + value: number; +} & { + format?: Intl.NumberFormatOptions | undefined; + tag?: string | undefined; + locale?: string | undefined; + scope?: "parent" | "global" | undefined; +}, import("vue").ComponentOptionsBase<{ + value: number; + scope: "parent" | "global"; +} & { + format?: Intl.NumberFormatOptions | undefined; + tag?: string | undefined; + locale?: string | undefined; +}, import("vue").RenderFunction, unknown, {}, {}, import("vue").ComponentOptionsBase, import("vue").ComponentOptionsBase, Record any) | null>, string>>) & import("vue").ComponentOptionsBase, import("vue").RenderFunction, unknown, {}, {}, import("vue").ComponentOptionsBase, import("vue").ComponentOptionsBase, Record any) | null>, string> & { + props: { + value: { + type: NumberConstructor; + required: true; + }; + format: { + type: PropType; + }; + tag: { + type: StringConstructor; + }; + locale: { + type: StringConstructor; + }; + scope: { + type: PropType<"parent" | "global">; + validator: (val: "parent" | "global") => boolean; + default: "parent" | "global"; + }; + }; +} & ThisType, import("vue").RenderFunction, {}, {}, {}, Record any) | null>, Readonly<{ + value: number; + scope: "parent" | "global"; +} & { + format?: Intl.NumberFormatOptions | undefined; + tag?: string | undefined; + locale?: string | undefined; +}>, import("vue").ComponentOptionsBase, import("vue").RenderFunction, unknown, {}, {}, import("vue").ComponentOptionsBase, import("vue").ComponentOptionsBase, Record any) | null>, string>>> ``` diff --git a/docs/vue-i18n.numberformatoptions.md b/docs/vue-i18n.numberformatoptions.md deleted file mode 100644 index 6e4c917bb..000000000 --- a/docs/vue-i18n.numberformatoptions.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [NumberFormatOptions](./vue-i18n.numberformatoptions.md) - -## NumberFormatOptions type - -Signature: - -```typescript -export declare type NumberFormatOptions = Intl.NumberFormatOptions | SpecificNumberFormatOptions | CurrencyNumberFormatOptions; -``` diff --git a/docs/vue-i18n.numberformatprops.md b/docs/vue-i18n.numberformatprops.md new file mode 100644 index 000000000..f80cdf01e --- /dev/null +++ b/docs/vue-i18n.numberformatprops.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [NumberFormatProps](./vue-i18n.numberformatprops.md) + +## NumberFormatProps type + +Signature: + +```typescript +export declare type NumberFormatProps = FormattableProps; +``` diff --git a/docs/vue-i18n.numberformattopartsresult.md b/docs/vue-i18n.numberformattopartsresult.md deleted file mode 100644 index 3c0cbf3c4..000000000 --- a/docs/vue-i18n.numberformattopartsresult.md +++ /dev/null @@ -1,13 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [NumberFormatToPartsResult](./vue-i18n.numberformattopartsresult.md) - -## NumberFormatToPartsResult type - -Signature: - -```typescript -export declare type NumberFormatToPartsResult = { - [index: number]: FormattedNumberPart; -}; -``` diff --git a/docs/vue-i18n.numberoptions.md b/docs/vue-i18n.numberoptions.md new file mode 100644 index 000000000..7edce53ee --- /dev/null +++ b/docs/vue-i18n.numberoptions.md @@ -0,0 +1,37 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [NumberOptions](./vue-i18n.numberoptions.md) + +## NumberOptions type + +\# number + +\#\# usages // for example `context.numberFormats` below 'en-US': { 'currency': { style: 'currency', currency: 'USD', currencyDisplay: 'symbol' } }, 'ja-JP: { ... } + +// value only number(context, value) + +// key argument number(context, value, 'currency') + +// key & locale argument number(context, value, 'currency', 'ja-JP') + +// object sytle argument number(context, value, { key: 'currency', locale: 'ja-JP' }) + +// suppress localize miss warning option, override context.missingWarn number(context, value, { key: 'currency', locale: 'ja-JP', missingWarn: false }) + +// suppress localize fallback warning option, override context.fallbackWarn number(context, value, { key: 'currency', locale: 'ja-JP', fallbackWarn: false }) + +// if you specify `part` options, you can get an array of objects containing the formatted number in parts number(context, value, { key: 'currenty', part: true }) + +// orverride context.numberFormats\[locale\] options with functino options number(cnotext, value, 'currency', { year: '2-digit' }) number(cnotext, value, 'currency', 'ja-JP', { year: '2-digit' }) number(context, value, { key: 'currenty', part: true }, { year: '2-digit'}) + +Signature: + +```typescript +export declare type NumberOptions = { + key?: string; + locale?: Locale; + missingWarn?: boolean; + fallbackWarn?: boolean; + part?: boolean; +}; +``` diff --git a/docs/vue-i18n.parsedatetimeargs.md b/docs/vue-i18n.parsedatetimeargs.md new file mode 100644 index 000000000..ecf5e43fe --- /dev/null +++ b/docs/vue-i18n.parsedatetimeargs.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [parseDateTimeArgs](./vue-i18n.parsedatetimeargs.md) + +## parseDateTimeArgs() function + +Signature: + +```typescript +export declare function parseDateTimeArgs(...args: unknown[]): [string, number | Date, DateTimeOptions, Intl.DateTimeFormatOptions]; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| args | unknown[] | | + +Returns: + +`[string, number | Date, DateTimeOptions, Intl.DateTimeFormatOptions]` + diff --git a/docs/vue-i18n.parsenumberargs.md b/docs/vue-i18n.parsenumberargs.md new file mode 100644 index 000000000..bb7c10a8e --- /dev/null +++ b/docs/vue-i18n.parsenumberargs.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [parseNumberArgs](./vue-i18n.parsenumberargs.md) + +## parseNumberArgs() function + +Signature: + +```typescript +export declare function parseNumberArgs(...args: unknown[]): [string, number, NumberOptions, Intl.NumberFormatOptions]; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| args | unknown[] | | + +Returns: + +`[string, number, NumberOptions, Intl.NumberFormatOptions]` + diff --git a/docs/vue-i18n.parser.md b/docs/vue-i18n.parser.md index c74392b73..cea5aeaab 100644 --- a/docs/vue-i18n.parser.md +++ b/docs/vue-i18n.parser.md @@ -2,12 +2,17 @@ [Home](./index.md) > [vue-i18n](./vue-i18n.md) > [Parser](./vue-i18n.parser.md) -## Parser type +## Parser interface Signature: ```typescript -export declare type Parser = Readonly<{ - parse: (source: string) => ResourceNode; -}>; +export interface Parser ``` + +## Methods + +| Method | Description | +| --- | --- | +| [parse(source)](./vue-i18n.parser.parse.md) | | + diff --git a/docs/vue-i18n.parser.parse.md b/docs/vue-i18n.parser.parse.md new file mode 100644 index 000000000..fcaf4aa90 --- /dev/null +++ b/docs/vue-i18n.parser.parse.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [Parser](./vue-i18n.parser.md) > [parse](./vue-i18n.parser.parse.md) + +## Parser.parse() method + +Signature: + +```typescript +parse(source: string): ResourceNode; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| source | string | | + +Returns: + +`ResourceNode` + diff --git a/docs/vue-i18n.parsetranslateargs.md b/docs/vue-i18n.parsetranslateargs.md new file mode 100644 index 000000000..aaf37b036 --- /dev/null +++ b/docs/vue-i18n.parsetranslateargs.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [parseTranslateArgs](./vue-i18n.parsetranslateargs.md) + +## parseTranslateArgs() function + +Signature: + +```typescript +export declare function parseTranslateArgs(...args: unknown[]): [Path, TranslateOptions]; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| args | unknown[] | | + +Returns: + +`[Path, TranslateOptions]` + diff --git a/docs/vue-i18n.posttranslationhandler.md b/docs/vue-i18n.posttranslationhandler.md index 1e0e017a7..e98e5e381 100644 --- a/docs/vue-i18n.posttranslationhandler.md +++ b/docs/vue-i18n.posttranslationhandler.md @@ -7,5 +7,5 @@ Signature: ```typescript -export declare type PostTranslationHandler = (translated: unknown) => unknown; +export declare type PostTranslationHandler = (translated: MessageType) => MessageType; ``` diff --git a/docs/vue-i18n.runtimecommoncontext.fallbackformat.md b/docs/vue-i18n.runtimecommoncontext.fallbackformat.md new file mode 100644 index 000000000..3a0b62954 --- /dev/null +++ b/docs/vue-i18n.runtimecommoncontext.fallbackformat.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeCommonContext](./vue-i18n.runtimecommoncontext.md) > [fallbackFormat](./vue-i18n.runtimecommoncontext.fallbackformat.md) + +## RuntimeCommonContext.fallbackFormat property + +Signature: + +```typescript +fallbackFormat: boolean; +``` diff --git a/docs/vue-i18n.runtimecommoncontext.fallbacklocale.md b/docs/vue-i18n.runtimecommoncontext.fallbacklocale.md new file mode 100644 index 000000000..6315ddf3b --- /dev/null +++ b/docs/vue-i18n.runtimecommoncontext.fallbacklocale.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeCommonContext](./vue-i18n.runtimecommoncontext.md) > [fallbackLocale](./vue-i18n.runtimecommoncontext.fallbacklocale.md) + +## RuntimeCommonContext.fallbackLocale property + +Signature: + +```typescript +fallbackLocale: FallbackLocale; +``` diff --git a/docs/vue-i18n.runtimecommoncontext.fallbackwarn.md b/docs/vue-i18n.runtimecommoncontext.fallbackwarn.md new file mode 100644 index 000000000..923d1ee6c --- /dev/null +++ b/docs/vue-i18n.runtimecommoncontext.fallbackwarn.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeCommonContext](./vue-i18n.runtimecommoncontext.md) > [fallbackWarn](./vue-i18n.runtimecommoncontext.fallbackwarn.md) + +## RuntimeCommonContext.fallbackWarn property + +Signature: + +```typescript +fallbackWarn: boolean | RegExp; +``` diff --git a/docs/vue-i18n.runtimecommoncontext.locale.md b/docs/vue-i18n.runtimecommoncontext.locale.md new file mode 100644 index 000000000..351cc9efe --- /dev/null +++ b/docs/vue-i18n.runtimecommoncontext.locale.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeCommonContext](./vue-i18n.runtimecommoncontext.md) > [locale](./vue-i18n.runtimecommoncontext.locale.md) + +## RuntimeCommonContext.locale property + +Signature: + +```typescript +locale: Locale; +``` diff --git a/docs/vue-i18n.runtimecommoncontext.md b/docs/vue-i18n.runtimecommoncontext.md new file mode 100644 index 000000000..cf20f8fa4 --- /dev/null +++ b/docs/vue-i18n.runtimecommoncontext.md @@ -0,0 +1,30 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeCommonContext](./vue-i18n.runtimecommoncontext.md) + +## RuntimeCommonContext interface + +Signature: + +```typescript +export interface RuntimeCommonContext +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [fallbackFormat](./vue-i18n.runtimecommoncontext.fallbackformat.md) | boolean | | +| [fallbackLocale](./vue-i18n.runtimecommoncontext.fallbacklocale.md) | FallbackLocale | | +| [fallbackWarn](./vue-i18n.runtimecommoncontext.fallbackwarn.md) | boolean | RegExp | | +| [locale](./vue-i18n.runtimecommoncontext.locale.md) | Locale | | +| [missing](./vue-i18n.runtimecommoncontext.missing.md) | RuntimeMissingHandler<Message> | null | | +| [missingWarn](./vue-i18n.runtimecommoncontext.missingwarn.md) | boolean | RegExp | | +| [unresolving](./vue-i18n.runtimecommoncontext.unresolving.md) | boolean | | + +## Methods + +| Method | Description | +| --- | --- | +| [onWarn(msg, err)](./vue-i18n.runtimecommoncontext.onwarn.md) | | + diff --git a/docs/vue-i18n.runtimecommoncontext.missing.md b/docs/vue-i18n.runtimecommoncontext.missing.md new file mode 100644 index 000000000..48f9d105c --- /dev/null +++ b/docs/vue-i18n.runtimecommoncontext.missing.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeCommonContext](./vue-i18n.runtimecommoncontext.md) > [missing](./vue-i18n.runtimecommoncontext.missing.md) + +## RuntimeCommonContext.missing property + +Signature: + +```typescript +missing: RuntimeMissingHandler | null; +``` diff --git a/docs/vue-i18n.runtimecommoncontext.missingwarn.md b/docs/vue-i18n.runtimecommoncontext.missingwarn.md new file mode 100644 index 000000000..cf33abc67 --- /dev/null +++ b/docs/vue-i18n.runtimecommoncontext.missingwarn.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeCommonContext](./vue-i18n.runtimecommoncontext.md) > [missingWarn](./vue-i18n.runtimecommoncontext.missingwarn.md) + +## RuntimeCommonContext.missingWarn property + +Signature: + +```typescript +missingWarn: boolean | RegExp; +``` diff --git a/docs/vue-i18n.runtimecommoncontext.onwarn.md b/docs/vue-i18n.runtimecommoncontext.onwarn.md new file mode 100644 index 000000000..d114ed05a --- /dev/null +++ b/docs/vue-i18n.runtimecommoncontext.onwarn.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeCommonContext](./vue-i18n.runtimecommoncontext.md) > [onWarn](./vue-i18n.runtimecommoncontext.onwarn.md) + +## RuntimeCommonContext.onWarn() method + +Signature: + +```typescript +onWarn(msg: string, err?: Error): void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| msg | string | | +| err | Error | | + +Returns: + +`void` + diff --git a/docs/vue-i18n.runtimecommoncontext.unresolving.md b/docs/vue-i18n.runtimecommoncontext.unresolving.md new file mode 100644 index 000000000..ef24a3bdb --- /dev/null +++ b/docs/vue-i18n.runtimecommoncontext.unresolving.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeCommonContext](./vue-i18n.runtimecommoncontext.md) > [unresolving](./vue-i18n.runtimecommoncontext.unresolving.md) + +## RuntimeCommonContext.unresolving property + +Signature: + +```typescript +unresolving: boolean; +``` diff --git a/docs/vue-i18n.runtimecontext.md b/docs/vue-i18n.runtimecontext.md new file mode 100644 index 000000000..4634613bc --- /dev/null +++ b/docs/vue-i18n.runtimecontext.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeContext](./vue-i18n.runtimecontext.md) + +## RuntimeContext interface + +Signature: + +```typescript +export interface RuntimeContext extends RuntimeTranslationContext, RuntimeDateTimeContext, RuntimeNumberContext +``` diff --git a/docs/vue-i18n.runtimedatetimecontext.datetimeformats.md b/docs/vue-i18n.runtimedatetimecontext.datetimeformats.md new file mode 100644 index 000000000..5e5ced1d7 --- /dev/null +++ b/docs/vue-i18n.runtimedatetimecontext.datetimeformats.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeDateTimeContext](./vue-i18n.runtimedatetimecontext.md) > [datetimeFormats](./vue-i18n.runtimedatetimecontext.datetimeformats.md) + +## RuntimeDateTimeContext.datetimeFormats property + +Signature: + +```typescript +datetimeFormats: DateTimeFormats; +``` diff --git a/docs/vue-i18n.runtimedatetimecontext.md b/docs/vue-i18n.runtimedatetimecontext.md new file mode 100644 index 000000000..498c06559 --- /dev/null +++ b/docs/vue-i18n.runtimedatetimecontext.md @@ -0,0 +1,18 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeDateTimeContext](./vue-i18n.runtimedatetimecontext.md) + +## RuntimeDateTimeContext interface + +Signature: + +```typescript +export interface RuntimeDateTimeContext extends RuntimeCommonContext +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [datetimeFormats](./vue-i18n.runtimedatetimecontext.datetimeformats.md) | DateTimeFormats | | + diff --git a/docs/vue-i18n.runtimeinternalcontext.__datetimeformatters.md b/docs/vue-i18n.runtimeinternalcontext.__datetimeformatters.md new file mode 100644 index 000000000..186f215a6 --- /dev/null +++ b/docs/vue-i18n.runtimeinternalcontext.__datetimeformatters.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeInternalContext](./vue-i18n.runtimeinternalcontext.md) > [\_\_datetimeFormatters](./vue-i18n.runtimeinternalcontext.__datetimeformatters.md) + +## RuntimeInternalContext.\_\_datetimeFormatters property + +Signature: + +```typescript +__datetimeFormatters: Map; +``` diff --git a/docs/vue-i18n.runtimeinternalcontext.__localechaincache.md b/docs/vue-i18n.runtimeinternalcontext.__localechaincache.md new file mode 100644 index 000000000..f233925a3 --- /dev/null +++ b/docs/vue-i18n.runtimeinternalcontext.__localechaincache.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeInternalContext](./vue-i18n.runtimeinternalcontext.md) > [\_\_localeChainCache](./vue-i18n.runtimeinternalcontext.__localechaincache.md) + +## RuntimeInternalContext.\_\_localeChainCache property + +Signature: + +```typescript +__localeChainCache?: Map; +``` diff --git a/docs/vue-i18n.runtimeinternalcontext.__numberformatters.md b/docs/vue-i18n.runtimeinternalcontext.__numberformatters.md new file mode 100644 index 000000000..6784edddd --- /dev/null +++ b/docs/vue-i18n.runtimeinternalcontext.__numberformatters.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeInternalContext](./vue-i18n.runtimeinternalcontext.md) > [\_\_numberFormatters](./vue-i18n.runtimeinternalcontext.__numberformatters.md) + +## RuntimeInternalContext.\_\_numberFormatters property + +Signature: + +```typescript +__numberFormatters: Map; +``` diff --git a/docs/vue-i18n.runtimeinternalcontext.md b/docs/vue-i18n.runtimeinternalcontext.md new file mode 100644 index 000000000..f63cdabd7 --- /dev/null +++ b/docs/vue-i18n.runtimeinternalcontext.md @@ -0,0 +1,20 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeInternalContext](./vue-i18n.runtimeinternalcontext.md) + +## RuntimeInternalContext interface + +Signature: + +```typescript +export interface RuntimeInternalContext +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [\_\_datetimeFormatters](./vue-i18n.runtimeinternalcontext.__datetimeformatters.md) | Map<string, Intl.DateTimeFormat> | | +| [\_\_localeChainCache](./vue-i18n.runtimeinternalcontext.__localechaincache.md) | Map<Locale, Locale[]> | | +| [\_\_numberFormatters](./vue-i18n.runtimeinternalcontext.__numberformatters.md) | Map<string, Intl.NumberFormat> | | + diff --git a/docs/vue-i18n.runtimeinternaloptions.__datetimeformatters.md b/docs/vue-i18n.runtimeinternaloptions.__datetimeformatters.md new file mode 100644 index 000000000..02c6805a4 --- /dev/null +++ b/docs/vue-i18n.runtimeinternaloptions.__datetimeformatters.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeInternalOptions](./vue-i18n.runtimeinternaloptions.md) > [\_\_datetimeFormatters](./vue-i18n.runtimeinternaloptions.__datetimeformatters.md) + +## RuntimeInternalOptions.\_\_datetimeFormatters property + +Signature: + +```typescript +__datetimeFormatters?: Map; +``` diff --git a/docs/vue-i18n.runtimeinternaloptions.__numberformatters.md b/docs/vue-i18n.runtimeinternaloptions.__numberformatters.md new file mode 100644 index 000000000..beda3432c --- /dev/null +++ b/docs/vue-i18n.runtimeinternaloptions.__numberformatters.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeInternalOptions](./vue-i18n.runtimeinternaloptions.md) > [\_\_numberFormatters](./vue-i18n.runtimeinternaloptions.__numberformatters.md) + +## RuntimeInternalOptions.\_\_numberFormatters property + +Signature: + +```typescript +__numberFormatters?: Map; +``` diff --git a/docs/vue-i18n.runtimeinternaloptions.md b/docs/vue-i18n.runtimeinternaloptions.md new file mode 100644 index 000000000..5689bf85a --- /dev/null +++ b/docs/vue-i18n.runtimeinternaloptions.md @@ -0,0 +1,19 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeInternalOptions](./vue-i18n.runtimeinternaloptions.md) + +## RuntimeInternalOptions interface + +Signature: + +```typescript +export interface RuntimeInternalOptions +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [\_\_datetimeFormatters](./vue-i18n.runtimeinternaloptions.__datetimeformatters.md) | Map<string, Intl.DateTimeFormat> | | +| [\_\_numberFormatters](./vue-i18n.runtimeinternaloptions.__numberformatters.md) | Map<string, Intl.NumberFormat> | | + diff --git a/docs/vue-i18n.runtimemissinghandler.md b/docs/vue-i18n.runtimemissinghandler.md new file mode 100644 index 000000000..db0bc8f37 --- /dev/null +++ b/docs/vue-i18n.runtimemissinghandler.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeMissingHandler](./vue-i18n.runtimemissinghandler.md) + +## RuntimeMissingHandler type + +Signature: + +```typescript +export declare type RuntimeMissingHandler = (context: RuntimeCommonContext, locale: Locale, key: Path, type: RuntimeMissingType, ...values: unknown[]) => string | void; +``` diff --git a/docs/vue-i18n.runtimemissingtype.md b/docs/vue-i18n.runtimemissingtype.md new file mode 100644 index 000000000..b75019f44 --- /dev/null +++ b/docs/vue-i18n.runtimemissingtype.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeMissingType](./vue-i18n.runtimemissingtype.md) + +## RuntimeMissingType type + +Signature: + +```typescript +export declare type RuntimeMissingType = 'translate' | 'datetime' | 'number'; +``` diff --git a/docs/vue-i18n.runtimenumbercontext.md b/docs/vue-i18n.runtimenumbercontext.md new file mode 100644 index 000000000..e899f35ec --- /dev/null +++ b/docs/vue-i18n.runtimenumbercontext.md @@ -0,0 +1,18 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeNumberContext](./vue-i18n.runtimenumbercontext.md) + +## RuntimeNumberContext interface + +Signature: + +```typescript +export interface RuntimeNumberContext extends RuntimeCommonContext +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [numberFormats](./vue-i18n.runtimenumbercontext.numberformats.md) | NumberFormats | | + diff --git a/docs/vue-i18n.runtimenumbercontext.numberformats.md b/docs/vue-i18n.runtimenumbercontext.numberformats.md new file mode 100644 index 000000000..580cb4646 --- /dev/null +++ b/docs/vue-i18n.runtimenumbercontext.numberformats.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeNumberContext](./vue-i18n.runtimenumbercontext.md) > [numberFormats](./vue-i18n.runtimenumbercontext.numberformats.md) + +## RuntimeNumberContext.numberFormats property + +Signature: + +```typescript +numberFormats: NumberFormats; +``` diff --git a/docs/vue-i18n.runtimeoptions.datetimeformats.md b/docs/vue-i18n.runtimeoptions.datetimeformats.md new file mode 100644 index 000000000..8cb7ae752 --- /dev/null +++ b/docs/vue-i18n.runtimeoptions.datetimeformats.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeOptions](./vue-i18n.runtimeoptions.md) > [datetimeFormats](./vue-i18n.runtimeoptions.datetimeformats.md) + +## RuntimeOptions.datetimeFormats property + +Signature: + +```typescript +datetimeFormats?: DateTimeFormatsType; +``` diff --git a/docs/vue-i18n.runtimeoptions.fallbackformat.md b/docs/vue-i18n.runtimeoptions.fallbackformat.md new file mode 100644 index 000000000..d050fc2a6 --- /dev/null +++ b/docs/vue-i18n.runtimeoptions.fallbackformat.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeOptions](./vue-i18n.runtimeoptions.md) > [fallbackFormat](./vue-i18n.runtimeoptions.fallbackformat.md) + +## RuntimeOptions.fallbackFormat property + +Signature: + +```typescript +fallbackFormat?: boolean; +``` diff --git a/docs/vue-i18n.runtimeoptions.fallbacklocale.md b/docs/vue-i18n.runtimeoptions.fallbacklocale.md new file mode 100644 index 000000000..45525f068 --- /dev/null +++ b/docs/vue-i18n.runtimeoptions.fallbacklocale.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeOptions](./vue-i18n.runtimeoptions.md) > [fallbackLocale](./vue-i18n.runtimeoptions.fallbacklocale.md) + +## RuntimeOptions.fallbackLocale property + +Signature: + +```typescript +fallbackLocale?: FallbackLocale; +``` diff --git a/docs/vue-i18n.runtimeoptions.fallbackwarn.md b/docs/vue-i18n.runtimeoptions.fallbackwarn.md new file mode 100644 index 000000000..eaa1e335a --- /dev/null +++ b/docs/vue-i18n.runtimeoptions.fallbackwarn.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeOptions](./vue-i18n.runtimeoptions.md) > [fallbackWarn](./vue-i18n.runtimeoptions.fallbackwarn.md) + +## RuntimeOptions.fallbackWarn property + +Signature: + +```typescript +fallbackWarn?: boolean | RegExp; +``` diff --git a/docs/vue-i18n.runtimeoptions.locale.md b/docs/vue-i18n.runtimeoptions.locale.md new file mode 100644 index 000000000..a154e56e4 --- /dev/null +++ b/docs/vue-i18n.runtimeoptions.locale.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeOptions](./vue-i18n.runtimeoptions.md) > [locale](./vue-i18n.runtimeoptions.locale.md) + +## RuntimeOptions.locale property + +Signature: + +```typescript +locale?: Locale; +``` diff --git a/docs/vue-i18n.runtimeoptions.md b/docs/vue-i18n.runtimeoptions.md new file mode 100644 index 000000000..338f4a088 --- /dev/null +++ b/docs/vue-i18n.runtimeoptions.md @@ -0,0 +1,34 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeOptions](./vue-i18n.runtimeoptions.md) + +## RuntimeOptions interface + +Signature: + +```typescript +export interface RuntimeOptions +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [datetimeFormats](./vue-i18n.runtimeoptions.datetimeformats.md) | DateTimeFormatsType | | +| [fallbackFormat](./vue-i18n.runtimeoptions.fallbackformat.md) | boolean | | +| [fallbackLocale](./vue-i18n.runtimeoptions.fallbacklocale.md) | FallbackLocale | | +| [fallbackWarn](./vue-i18n.runtimeoptions.fallbackwarn.md) | boolean | RegExp | | +| [locale](./vue-i18n.runtimeoptions.locale.md) | Locale | | +| [messageCompiler](./vue-i18n.runtimeoptions.messagecompiler.md) | MessageCompiler<Message> | | +| [messages](./vue-i18n.runtimeoptions.messages.md) | LocaleMessages<Message> | | +| [missing](./vue-i18n.runtimeoptions.missing.md) | RuntimeMissingHandler<Message> | | +| [missingWarn](./vue-i18n.runtimeoptions.missingwarn.md) | boolean | RegExp | | +| [modifiers](./vue-i18n.runtimeoptions.modifiers.md) | LinkedModifiers<Message> | | +| [numberFormats](./vue-i18n.runtimeoptions.numberformats.md) | NumberFormatsType | | +| [onWarn](./vue-i18n.runtimeoptions.onwarn.md) | (msg: string, err?: Error) => void | | +| [pluralRules](./vue-i18n.runtimeoptions.pluralrules.md) | PluralizationRules | | +| [postTranslation](./vue-i18n.runtimeoptions.posttranslation.md) | PostTranslationHandler<Message> | | +| [processor](./vue-i18n.runtimeoptions.processor.md) | MessageProcessor<Message> | | +| [unresolving](./vue-i18n.runtimeoptions.unresolving.md) | boolean | | +| [warnHtmlMessage](./vue-i18n.runtimeoptions.warnhtmlmessage.md) | boolean | | + diff --git a/docs/vue-i18n.runtimeoptions.messagecompiler.md b/docs/vue-i18n.runtimeoptions.messagecompiler.md new file mode 100644 index 000000000..6271d4cfa --- /dev/null +++ b/docs/vue-i18n.runtimeoptions.messagecompiler.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeOptions](./vue-i18n.runtimeoptions.md) > [messageCompiler](./vue-i18n.runtimeoptions.messagecompiler.md) + +## RuntimeOptions.messageCompiler property + +Signature: + +```typescript +messageCompiler?: MessageCompiler; +``` diff --git a/docs/vue-i18n.runtimeoptions.messages.md b/docs/vue-i18n.runtimeoptions.messages.md new file mode 100644 index 000000000..f3f3ebffb --- /dev/null +++ b/docs/vue-i18n.runtimeoptions.messages.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeOptions](./vue-i18n.runtimeoptions.md) > [messages](./vue-i18n.runtimeoptions.messages.md) + +## RuntimeOptions.messages property + +Signature: + +```typescript +messages?: LocaleMessages; +``` diff --git a/docs/vue-i18n.runtimeoptions.missing.md b/docs/vue-i18n.runtimeoptions.missing.md new file mode 100644 index 000000000..dd781ea1e --- /dev/null +++ b/docs/vue-i18n.runtimeoptions.missing.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeOptions](./vue-i18n.runtimeoptions.md) > [missing](./vue-i18n.runtimeoptions.missing.md) + +## RuntimeOptions.missing property + +Signature: + +```typescript +missing?: RuntimeMissingHandler; +``` diff --git a/docs/vue-i18n.runtimeoptions.missingwarn.md b/docs/vue-i18n.runtimeoptions.missingwarn.md new file mode 100644 index 000000000..207c7ebeb --- /dev/null +++ b/docs/vue-i18n.runtimeoptions.missingwarn.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeOptions](./vue-i18n.runtimeoptions.md) > [missingWarn](./vue-i18n.runtimeoptions.missingwarn.md) + +## RuntimeOptions.missingWarn property + +Signature: + +```typescript +missingWarn?: boolean | RegExp; +``` diff --git a/docs/vue-i18n.runtimeoptions.modifiers.md b/docs/vue-i18n.runtimeoptions.modifiers.md new file mode 100644 index 000000000..f871f76ca --- /dev/null +++ b/docs/vue-i18n.runtimeoptions.modifiers.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeOptions](./vue-i18n.runtimeoptions.md) > [modifiers](./vue-i18n.runtimeoptions.modifiers.md) + +## RuntimeOptions.modifiers property + +Signature: + +```typescript +modifiers?: LinkedModifiers; +``` diff --git a/docs/vue-i18n.runtimeoptions.numberformats.md b/docs/vue-i18n.runtimeoptions.numberformats.md new file mode 100644 index 000000000..44cbaa16b --- /dev/null +++ b/docs/vue-i18n.runtimeoptions.numberformats.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeOptions](./vue-i18n.runtimeoptions.md) > [numberFormats](./vue-i18n.runtimeoptions.numberformats.md) + +## RuntimeOptions.numberFormats property + +Signature: + +```typescript +numberFormats?: NumberFormatsType; +``` diff --git a/docs/vue-i18n.runtimeoptions.onwarn.md b/docs/vue-i18n.runtimeoptions.onwarn.md new file mode 100644 index 000000000..00080de37 --- /dev/null +++ b/docs/vue-i18n.runtimeoptions.onwarn.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeOptions](./vue-i18n.runtimeoptions.md) > [onWarn](./vue-i18n.runtimeoptions.onwarn.md) + +## RuntimeOptions.onWarn property + +Signature: + +```typescript +onWarn?: (msg: string, err?: Error) => void; +``` diff --git a/docs/vue-i18n.runtimeoptions.pluralrules.md b/docs/vue-i18n.runtimeoptions.pluralrules.md new file mode 100644 index 000000000..2293679e2 --- /dev/null +++ b/docs/vue-i18n.runtimeoptions.pluralrules.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeOptions](./vue-i18n.runtimeoptions.md) > [pluralRules](./vue-i18n.runtimeoptions.pluralrules.md) + +## RuntimeOptions.pluralRules property + +Signature: + +```typescript +pluralRules?: PluralizationRules; +``` diff --git a/docs/vue-i18n.runtimeoptions.posttranslation.md b/docs/vue-i18n.runtimeoptions.posttranslation.md new file mode 100644 index 000000000..03207fba2 --- /dev/null +++ b/docs/vue-i18n.runtimeoptions.posttranslation.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeOptions](./vue-i18n.runtimeoptions.md) > [postTranslation](./vue-i18n.runtimeoptions.posttranslation.md) + +## RuntimeOptions.postTranslation property + +Signature: + +```typescript +postTranslation?: PostTranslationHandler; +``` diff --git a/docs/vue-i18n.runtimeoptions.processor.md b/docs/vue-i18n.runtimeoptions.processor.md new file mode 100644 index 000000000..306586807 --- /dev/null +++ b/docs/vue-i18n.runtimeoptions.processor.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeOptions](./vue-i18n.runtimeoptions.md) > [processor](./vue-i18n.runtimeoptions.processor.md) + +## RuntimeOptions.processor property + +Signature: + +```typescript +processor?: MessageProcessor; +``` diff --git a/docs/vue-i18n.runtimeoptions.unresolving.md b/docs/vue-i18n.runtimeoptions.unresolving.md new file mode 100644 index 000000000..854ca06cb --- /dev/null +++ b/docs/vue-i18n.runtimeoptions.unresolving.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeOptions](./vue-i18n.runtimeoptions.md) > [unresolving](./vue-i18n.runtimeoptions.unresolving.md) + +## RuntimeOptions.unresolving property + +Signature: + +```typescript +unresolving?: boolean; +``` diff --git a/docs/vue-i18n.runtimeoptions.warnhtmlmessage.md b/docs/vue-i18n.runtimeoptions.warnhtmlmessage.md new file mode 100644 index 000000000..1daa889f0 --- /dev/null +++ b/docs/vue-i18n.runtimeoptions.warnhtmlmessage.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeOptions](./vue-i18n.runtimeoptions.md) > [warnHtmlMessage](./vue-i18n.runtimeoptions.warnhtmlmessage.md) + +## RuntimeOptions.warnHtmlMessage property + +Signature: + +```typescript +warnHtmlMessage?: boolean; +``` diff --git a/docs/vue-i18n.runtimetranslationcontext.md b/docs/vue-i18n.runtimetranslationcontext.md new file mode 100644 index 000000000..edb9fba1e --- /dev/null +++ b/docs/vue-i18n.runtimetranslationcontext.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeTranslationContext](./vue-i18n.runtimetranslationcontext.md) + +## RuntimeTranslationContext interface + +Signature: + +```typescript +export interface RuntimeTranslationContext extends RuntimeCommonContext +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [messageCompiler](./vue-i18n.runtimetranslationcontext.messagecompiler.md) | MessageCompiler<Message> | | +| [messages](./vue-i18n.runtimetranslationcontext.messages.md) | Messages | | +| [modifiers](./vue-i18n.runtimetranslationcontext.modifiers.md) | LinkedModifiers<Message> | | +| [pluralRules](./vue-i18n.runtimetranslationcontext.pluralrules.md) | PluralizationRules | | +| [postTranslation](./vue-i18n.runtimetranslationcontext.posttranslation.md) | PostTranslationHandler<Message> | null | | +| [processor](./vue-i18n.runtimetranslationcontext.processor.md) | MessageProcessor<Message> | null | | +| [warnHtmlMessage](./vue-i18n.runtimetranslationcontext.warnhtmlmessage.md) | boolean | | + diff --git a/docs/vue-i18n.runtimetranslationcontext.messagecompiler.md b/docs/vue-i18n.runtimetranslationcontext.messagecompiler.md new file mode 100644 index 000000000..db597f768 --- /dev/null +++ b/docs/vue-i18n.runtimetranslationcontext.messagecompiler.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeTranslationContext](./vue-i18n.runtimetranslationcontext.md) > [messageCompiler](./vue-i18n.runtimetranslationcontext.messagecompiler.md) + +## RuntimeTranslationContext.messageCompiler property + +Signature: + +```typescript +messageCompiler: MessageCompiler; +``` diff --git a/docs/vue-i18n.runtimetranslationcontext.messages.md b/docs/vue-i18n.runtimetranslationcontext.messages.md new file mode 100644 index 000000000..45bc1d02e --- /dev/null +++ b/docs/vue-i18n.runtimetranslationcontext.messages.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeTranslationContext](./vue-i18n.runtimetranslationcontext.md) > [messages](./vue-i18n.runtimetranslationcontext.messages.md) + +## RuntimeTranslationContext.messages property + +Signature: + +```typescript +messages: Messages; +``` diff --git a/docs/vue-i18n.runtimetranslationcontext.modifiers.md b/docs/vue-i18n.runtimetranslationcontext.modifiers.md new file mode 100644 index 000000000..2c89e5d84 --- /dev/null +++ b/docs/vue-i18n.runtimetranslationcontext.modifiers.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeTranslationContext](./vue-i18n.runtimetranslationcontext.md) > [modifiers](./vue-i18n.runtimetranslationcontext.modifiers.md) + +## RuntimeTranslationContext.modifiers property + +Signature: + +```typescript +modifiers: LinkedModifiers; +``` diff --git a/docs/vue-i18n.runtimetranslationcontext.pluralrules.md b/docs/vue-i18n.runtimetranslationcontext.pluralrules.md new file mode 100644 index 000000000..2f18064f9 --- /dev/null +++ b/docs/vue-i18n.runtimetranslationcontext.pluralrules.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeTranslationContext](./vue-i18n.runtimetranslationcontext.md) > [pluralRules](./vue-i18n.runtimetranslationcontext.pluralrules.md) + +## RuntimeTranslationContext.pluralRules property + +Signature: + +```typescript +pluralRules?: PluralizationRules; +``` diff --git a/docs/vue-i18n.runtimetranslationcontext.posttranslation.md b/docs/vue-i18n.runtimetranslationcontext.posttranslation.md new file mode 100644 index 000000000..30c8757b2 --- /dev/null +++ b/docs/vue-i18n.runtimetranslationcontext.posttranslation.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeTranslationContext](./vue-i18n.runtimetranslationcontext.md) > [postTranslation](./vue-i18n.runtimetranslationcontext.posttranslation.md) + +## RuntimeTranslationContext.postTranslation property + +Signature: + +```typescript +postTranslation: PostTranslationHandler | null; +``` diff --git a/docs/vue-i18n.runtimetranslationcontext.processor.md b/docs/vue-i18n.runtimetranslationcontext.processor.md new file mode 100644 index 000000000..969418fcc --- /dev/null +++ b/docs/vue-i18n.runtimetranslationcontext.processor.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeTranslationContext](./vue-i18n.runtimetranslationcontext.md) > [processor](./vue-i18n.runtimetranslationcontext.processor.md) + +## RuntimeTranslationContext.processor property + +Signature: + +```typescript +processor: MessageProcessor | null; +``` diff --git a/docs/vue-i18n.runtimetranslationcontext.warnhtmlmessage.md b/docs/vue-i18n.runtimetranslationcontext.warnhtmlmessage.md new file mode 100644 index 000000000..afa16c73d --- /dev/null +++ b/docs/vue-i18n.runtimetranslationcontext.warnhtmlmessage.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [RuntimeTranslationContext](./vue-i18n.runtimetranslationcontext.md) > [warnHtmlMessage](./vue-i18n.runtimetranslationcontext.warnhtmlmessage.md) + +## RuntimeTranslationContext.warnHtmlMessage property + +Signature: + +```typescript +warnHtmlMessage: boolean; +``` diff --git a/docs/vue-i18n.specificdatetimeformatoptions.day.md b/docs/vue-i18n.specificdatetimeformatoptions.day.md deleted file mode 100644 index eece6267c..000000000 --- a/docs/vue-i18n.specificdatetimeformatoptions.day.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [SpecificDateTimeFormatOptions](./vue-i18n.specificdatetimeformatoptions.md) > [day](./vue-i18n.specificdatetimeformatoptions.day.md) - -## SpecificDateTimeFormatOptions.day property - -Signature: - -```typescript -day?: DateTimeDigital; -``` diff --git a/docs/vue-i18n.specificdatetimeformatoptions.era.md b/docs/vue-i18n.specificdatetimeformatoptions.era.md deleted file mode 100644 index a2fe33538..000000000 --- a/docs/vue-i18n.specificdatetimeformatoptions.era.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [SpecificDateTimeFormatOptions](./vue-i18n.specificdatetimeformatoptions.md) > [era](./vue-i18n.specificdatetimeformatoptions.era.md) - -## SpecificDateTimeFormatOptions.era property - -Signature: - -```typescript -era?: DateTimeHumanReadable; -``` diff --git a/docs/vue-i18n.specificdatetimeformatoptions.formatmatcher.md b/docs/vue-i18n.specificdatetimeformatoptions.formatmatcher.md deleted file mode 100644 index 742352dd4..000000000 --- a/docs/vue-i18n.specificdatetimeformatoptions.formatmatcher.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [SpecificDateTimeFormatOptions](./vue-i18n.specificdatetimeformatoptions.md) > [formatMatcher](./vue-i18n.specificdatetimeformatoptions.formatmatcher.md) - -## SpecificDateTimeFormatOptions.formatMatcher property - -Signature: - -```typescript -formatMatcher?: 'basic' | 'best-fit'; -``` diff --git a/docs/vue-i18n.specificdatetimeformatoptions.hour.md b/docs/vue-i18n.specificdatetimeformatoptions.hour.md deleted file mode 100644 index 98802d2d6..000000000 --- a/docs/vue-i18n.specificdatetimeformatoptions.hour.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [SpecificDateTimeFormatOptions](./vue-i18n.specificdatetimeformatoptions.md) > [hour](./vue-i18n.specificdatetimeformatoptions.hour.md) - -## SpecificDateTimeFormatOptions.hour property - -Signature: - -```typescript -hour?: DateTimeDigital; -``` diff --git a/docs/vue-i18n.specificdatetimeformatoptions.localematcher.md b/docs/vue-i18n.specificdatetimeformatoptions.localematcher.md deleted file mode 100644 index 152d5af3a..000000000 --- a/docs/vue-i18n.specificdatetimeformatoptions.localematcher.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [SpecificDateTimeFormatOptions](./vue-i18n.specificdatetimeformatoptions.md) > [localeMatcher](./vue-i18n.specificdatetimeformatoptions.localematcher.md) - -## SpecificDateTimeFormatOptions.localeMatcher property - -Signature: - -```typescript -localeMatcher?: 'lookup' | 'best-fit'; -``` diff --git a/docs/vue-i18n.specificdatetimeformatoptions.md b/docs/vue-i18n.specificdatetimeformatoptions.md deleted file mode 100644 index 564b0c908..000000000 --- a/docs/vue-i18n.specificdatetimeformatoptions.md +++ /dev/null @@ -1,28 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [SpecificDateTimeFormatOptions](./vue-i18n.specificdatetimeformatoptions.md) - -## SpecificDateTimeFormatOptions interface - -Signature: - -```typescript -export interface SpecificDateTimeFormatOptions extends Intl.DateTimeFormatOptions -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [day](./vue-i18n.specificdatetimeformatoptions.day.md) | DateTimeDigital | | -| [era](./vue-i18n.specificdatetimeformatoptions.era.md) | DateTimeHumanReadable | | -| [formatMatcher](./vue-i18n.specificdatetimeformatoptions.formatmatcher.md) | 'basic' | 'best-fit' | | -| [hour](./vue-i18n.specificdatetimeformatoptions.hour.md) | DateTimeDigital | | -| [localeMatcher](./vue-i18n.specificdatetimeformatoptions.localematcher.md) | 'lookup' | 'best-fit' | | -| [minute](./vue-i18n.specificdatetimeformatoptions.minute.md) | DateTimeDigital | | -| [month](./vue-i18n.specificdatetimeformatoptions.month.md) | DateTimeDigital | DateTimeHumanReadable | | -| [second](./vue-i18n.specificdatetimeformatoptions.second.md) | DateTimeDigital | | -| [timeZoneName](./vue-i18n.specificdatetimeformatoptions.timezonename.md) | 'long' | 'short' | | -| [weekday](./vue-i18n.specificdatetimeformatoptions.weekday.md) | DateTimeHumanReadable | | -| [year](./vue-i18n.specificdatetimeformatoptions.year.md) | DateTimeDigital | | - diff --git a/docs/vue-i18n.specificdatetimeformatoptions.minute.md b/docs/vue-i18n.specificdatetimeformatoptions.minute.md deleted file mode 100644 index fd2852de8..000000000 --- a/docs/vue-i18n.specificdatetimeformatoptions.minute.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [SpecificDateTimeFormatOptions](./vue-i18n.specificdatetimeformatoptions.md) > [minute](./vue-i18n.specificdatetimeformatoptions.minute.md) - -## SpecificDateTimeFormatOptions.minute property - -Signature: - -```typescript -minute?: DateTimeDigital; -``` diff --git a/docs/vue-i18n.specificdatetimeformatoptions.month.md b/docs/vue-i18n.specificdatetimeformatoptions.month.md deleted file mode 100644 index 6a3026b5b..000000000 --- a/docs/vue-i18n.specificdatetimeformatoptions.month.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [SpecificDateTimeFormatOptions](./vue-i18n.specificdatetimeformatoptions.md) > [month](./vue-i18n.specificdatetimeformatoptions.month.md) - -## SpecificDateTimeFormatOptions.month property - -Signature: - -```typescript -month?: DateTimeDigital | DateTimeHumanReadable; -``` diff --git a/docs/vue-i18n.specificdatetimeformatoptions.second.md b/docs/vue-i18n.specificdatetimeformatoptions.second.md deleted file mode 100644 index 20e83d03d..000000000 --- a/docs/vue-i18n.specificdatetimeformatoptions.second.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [SpecificDateTimeFormatOptions](./vue-i18n.specificdatetimeformatoptions.md) > [second](./vue-i18n.specificdatetimeformatoptions.second.md) - -## SpecificDateTimeFormatOptions.second property - -Signature: - -```typescript -second?: DateTimeDigital; -``` diff --git a/docs/vue-i18n.specificdatetimeformatoptions.timezonename.md b/docs/vue-i18n.specificdatetimeformatoptions.timezonename.md deleted file mode 100644 index c8d5ce913..000000000 --- a/docs/vue-i18n.specificdatetimeformatoptions.timezonename.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [SpecificDateTimeFormatOptions](./vue-i18n.specificdatetimeformatoptions.md) > [timeZoneName](./vue-i18n.specificdatetimeformatoptions.timezonename.md) - -## SpecificDateTimeFormatOptions.timeZoneName property - -Signature: - -```typescript -timeZoneName?: 'long' | 'short'; -``` diff --git a/docs/vue-i18n.specificdatetimeformatoptions.weekday.md b/docs/vue-i18n.specificdatetimeformatoptions.weekday.md deleted file mode 100644 index 34bf09cec..000000000 --- a/docs/vue-i18n.specificdatetimeformatoptions.weekday.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [SpecificDateTimeFormatOptions](./vue-i18n.specificdatetimeformatoptions.md) > [weekday](./vue-i18n.specificdatetimeformatoptions.weekday.md) - -## SpecificDateTimeFormatOptions.weekday property - -Signature: - -```typescript -weekday?: DateTimeHumanReadable; -``` diff --git a/docs/vue-i18n.specificdatetimeformatoptions.year.md b/docs/vue-i18n.specificdatetimeformatoptions.year.md deleted file mode 100644 index c0efe1e30..000000000 --- a/docs/vue-i18n.specificdatetimeformatoptions.year.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [SpecificDateTimeFormatOptions](./vue-i18n.specificdatetimeformatoptions.md) > [year](./vue-i18n.specificdatetimeformatoptions.year.md) - -## SpecificDateTimeFormatOptions.year property - -Signature: - -```typescript -year?: DateTimeDigital; -``` diff --git a/docs/vue-i18n.specificnumberformatoptions.currency.md b/docs/vue-i18n.specificnumberformatoptions.currency.md deleted file mode 100644 index 21d174c97..000000000 --- a/docs/vue-i18n.specificnumberformatoptions.currency.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [SpecificNumberFormatOptions](./vue-i18n.specificnumberformatoptions.md) > [currency](./vue-i18n.specificnumberformatoptions.currency.md) - -## SpecificNumberFormatOptions.currency property - -Signature: - -```typescript -currency?: string; -``` diff --git a/docs/vue-i18n.specificnumberformatoptions.currencydisplay.md b/docs/vue-i18n.specificnumberformatoptions.currencydisplay.md deleted file mode 100644 index 66033b16a..000000000 --- a/docs/vue-i18n.specificnumberformatoptions.currencydisplay.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [SpecificNumberFormatOptions](./vue-i18n.specificnumberformatoptions.md) > [currencyDisplay](./vue-i18n.specificnumberformatoptions.currencydisplay.md) - -## SpecificNumberFormatOptions.currencyDisplay property - -Signature: - -```typescript -currencyDisplay?: CurrencyDisplay; -``` diff --git a/docs/vue-i18n.specificnumberformatoptions.formatmatcher.md b/docs/vue-i18n.specificnumberformatoptions.formatmatcher.md deleted file mode 100644 index 514becf23..000000000 --- a/docs/vue-i18n.specificnumberformatoptions.formatmatcher.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [SpecificNumberFormatOptions](./vue-i18n.specificnumberformatoptions.md) > [formatMatcher](./vue-i18n.specificnumberformatoptions.formatmatcher.md) - -## SpecificNumberFormatOptions.formatMatcher property - -Signature: - -```typescript -formatMatcher?: 'basic' | 'best-fit'; -``` diff --git a/docs/vue-i18n.specificnumberformatoptions.localematcher.md b/docs/vue-i18n.specificnumberformatoptions.localematcher.md deleted file mode 100644 index 409f2dca1..000000000 --- a/docs/vue-i18n.specificnumberformatoptions.localematcher.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [SpecificNumberFormatOptions](./vue-i18n.specificnumberformatoptions.md) > [localeMatcher](./vue-i18n.specificnumberformatoptions.localematcher.md) - -## SpecificNumberFormatOptions.localeMatcher property - -Signature: - -```typescript -localeMatcher?: 'lookup' | 'best-fit'; -``` diff --git a/docs/vue-i18n.specificnumberformatoptions.md b/docs/vue-i18n.specificnumberformatoptions.md deleted file mode 100644 index ed637b44e..000000000 --- a/docs/vue-i18n.specificnumberformatoptions.md +++ /dev/null @@ -1,22 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [SpecificNumberFormatOptions](./vue-i18n.specificnumberformatoptions.md) - -## SpecificNumberFormatOptions interface - -Signature: - -```typescript -export interface SpecificNumberFormatOptions extends Intl.NumberFormatOptions -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [currency](./vue-i18n.specificnumberformatoptions.currency.md) | string | | -| [currencyDisplay](./vue-i18n.specificnumberformatoptions.currencydisplay.md) | CurrencyDisplay | | -| [formatMatcher](./vue-i18n.specificnumberformatoptions.formatmatcher.md) | 'basic' | 'best-fit' | | -| [localeMatcher](./vue-i18n.specificnumberformatoptions.localematcher.md) | 'lookup' | 'best-fit' | | -| [style](./vue-i18n.specificnumberformatoptions.style.md) | 'decimal' | 'percent' | | - diff --git a/docs/vue-i18n.specificnumberformatoptions.style.md b/docs/vue-i18n.specificnumberformatoptions.style.md deleted file mode 100644 index f1e46754e..000000000 --- a/docs/vue-i18n.specificnumberformatoptions.style.md +++ /dev/null @@ -1,11 +0,0 @@ - - -[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [SpecificNumberFormatOptions](./vue-i18n.specificnumberformatoptions.md) > [style](./vue-i18n.specificnumberformatoptions.style.md) - -## SpecificNumberFormatOptions.style property - -Signature: - -```typescript -style?: 'decimal' | 'percent'; -``` diff --git a/docs/vue-i18n.translate.md b/docs/vue-i18n.translate.md new file mode 100644 index 000000000..3e6ee3554 --- /dev/null +++ b/docs/vue-i18n.translate.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [translate](./vue-i18n.translate.md) + +## translate() function + +Signature: + +```typescript +export declare function translate(context: RuntimeTranslationContext, key: Path): MessageType | number; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeTranslationContext<Messages, Message> | | +| key | Path | | + +Returns: + +`MessageType | number` + diff --git a/docs/vue-i18n.translate_1.md b/docs/vue-i18n.translate_1.md new file mode 100644 index 000000000..90eda96f5 --- /dev/null +++ b/docs/vue-i18n.translate_1.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [translate](./vue-i18n.translate_1.md) + +## translate() function + +Signature: + +```typescript +export declare function translate(context: RuntimeTranslationContext, key: Path, plural: number): MessageType | number; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeTranslationContext<Messages, Message> | | +| key | Path | | +| plural | number | | + +Returns: + +`MessageType | number` + diff --git a/docs/vue-i18n.translate_10.md b/docs/vue-i18n.translate_10.md new file mode 100644 index 000000000..ba4043a7d --- /dev/null +++ b/docs/vue-i18n.translate_10.md @@ -0,0 +1,25 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [translate](./vue-i18n.translate_10.md) + +## translate() function + +Signature: + +```typescript +export declare function translate(context: RuntimeTranslationContext, key: Path, named: NamedValue, plural: number): MessageType | number; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeTranslationContext<Messages, Message> | | +| key | Path | | +| named | NamedValue | | +| plural | number | | + +Returns: + +`MessageType | number` + diff --git a/docs/vue-i18n.translate_11.md b/docs/vue-i18n.translate_11.md new file mode 100644 index 000000000..a6f628ca7 --- /dev/null +++ b/docs/vue-i18n.translate_11.md @@ -0,0 +1,25 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [translate](./vue-i18n.translate_11.md) + +## translate() function + +Signature: + +```typescript +export declare function translate(context: RuntimeTranslationContext, key: Path, named: NamedValue, defaultMsg: string): MessageType | number; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeTranslationContext<Messages, Message> | | +| key | Path | | +| named | NamedValue | | +| defaultMsg | string | | + +Returns: + +`MessageType | number` + diff --git a/docs/vue-i18n.translate_12.md b/docs/vue-i18n.translate_12.md new file mode 100644 index 000000000..cdc17f11e --- /dev/null +++ b/docs/vue-i18n.translate_12.md @@ -0,0 +1,25 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [translate](./vue-i18n.translate_12.md) + +## translate() function + +Signature: + +```typescript +export declare function translate(context: RuntimeTranslationContext, key: Path, named: NamedValue, options: TranslateOptions): MessageType | number; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeTranslationContext<Messages, Message> | | +| key | Path | | +| named | NamedValue | | +| options | TranslateOptions | | + +Returns: + +`MessageType | number` + diff --git a/docs/vue-i18n.translate_13.md b/docs/vue-i18n.translate_13.md new file mode 100644 index 000000000..b4bb2a177 --- /dev/null +++ b/docs/vue-i18n.translate_13.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [translate](./vue-i18n.translate_13.md) + +## translate() function + +Signature: + +```typescript +export declare function translate(context: RuntimeTranslationContext, ...args: unknown[]): MessageType | number; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeTranslationContext<Messages, Message> | | +| args | unknown[] | | + +Returns: + +`MessageType | number` + diff --git a/docs/vue-i18n.translate_2.md b/docs/vue-i18n.translate_2.md new file mode 100644 index 000000000..4a128762e --- /dev/null +++ b/docs/vue-i18n.translate_2.md @@ -0,0 +1,25 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [translate](./vue-i18n.translate_2.md) + +## translate() function + +Signature: + +```typescript +export declare function translate(context: RuntimeTranslationContext, key: Path, plural: number, options: TranslateOptions): MessageType | number; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeTranslationContext<Messages, Message> | | +| key | Path | | +| plural | number | | +| options | TranslateOptions | | + +Returns: + +`MessageType | number` + diff --git a/docs/vue-i18n.translate_3.md b/docs/vue-i18n.translate_3.md new file mode 100644 index 000000000..a1e55f136 --- /dev/null +++ b/docs/vue-i18n.translate_3.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [translate](./vue-i18n.translate_3.md) + +## translate() function + +Signature: + +```typescript +export declare function translate(context: RuntimeTranslationContext, key: Path, defaultMsg: string): MessageType | number; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeTranslationContext<Messages, Message> | | +| key | Path | | +| defaultMsg | string | | + +Returns: + +`MessageType | number` + diff --git a/docs/vue-i18n.translate_4.md b/docs/vue-i18n.translate_4.md new file mode 100644 index 000000000..b0e8fbd6f --- /dev/null +++ b/docs/vue-i18n.translate_4.md @@ -0,0 +1,25 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [translate](./vue-i18n.translate_4.md) + +## translate() function + +Signature: + +```typescript +export declare function translate(context: RuntimeTranslationContext, key: Path, defaultMsg: string, options: TranslateOptions): MessageType | number; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeTranslationContext<Messages, Message> | | +| key | Path | | +| defaultMsg | string | | +| options | TranslateOptions | | + +Returns: + +`MessageType | number` + diff --git a/docs/vue-i18n.translate_5.md b/docs/vue-i18n.translate_5.md new file mode 100644 index 000000000..2e5132b9d --- /dev/null +++ b/docs/vue-i18n.translate_5.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [translate](./vue-i18n.translate_5.md) + +## translate() function + +Signature: + +```typescript +export declare function translate(context: RuntimeTranslationContext, key: Path, list: unknown[]): MessageType | number; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeTranslationContext<Messages, Message> | | +| key | Path | | +| list | unknown[] | | + +Returns: + +`MessageType | number` + diff --git a/docs/vue-i18n.translate_6.md b/docs/vue-i18n.translate_6.md new file mode 100644 index 000000000..2b7ec40cf --- /dev/null +++ b/docs/vue-i18n.translate_6.md @@ -0,0 +1,25 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [translate](./vue-i18n.translate_6.md) + +## translate() function + +Signature: + +```typescript +export declare function translate(context: RuntimeTranslationContext, key: Path, list: unknown[], plural: number): MessageType | number; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeTranslationContext<Messages, Message> | | +| key | Path | | +| list | unknown[] | | +| plural | number | | + +Returns: + +`MessageType | number` + diff --git a/docs/vue-i18n.translate_7.md b/docs/vue-i18n.translate_7.md new file mode 100644 index 000000000..13a3f6e7e --- /dev/null +++ b/docs/vue-i18n.translate_7.md @@ -0,0 +1,25 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [translate](./vue-i18n.translate_7.md) + +## translate() function + +Signature: + +```typescript +export declare function translate(context: RuntimeTranslationContext, key: Path, list: unknown[], defaultMsg: string): MessageType | number; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeTranslationContext<Messages, Message> | | +| key | Path | | +| list | unknown[] | | +| defaultMsg | string | | + +Returns: + +`MessageType | number` + diff --git a/docs/vue-i18n.translate_8.md b/docs/vue-i18n.translate_8.md new file mode 100644 index 000000000..435589ee4 --- /dev/null +++ b/docs/vue-i18n.translate_8.md @@ -0,0 +1,25 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [translate](./vue-i18n.translate_8.md) + +## translate() function + +Signature: + +```typescript +export declare function translate(context: RuntimeTranslationContext, key: Path, list: unknown[], options: TranslateOptions): MessageType | number; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeTranslationContext<Messages, Message> | | +| key | Path | | +| list | unknown[] | | +| options | TranslateOptions | | + +Returns: + +`MessageType | number` + diff --git a/docs/vue-i18n.translate_9.md b/docs/vue-i18n.translate_9.md new file mode 100644 index 000000000..2aadc7518 --- /dev/null +++ b/docs/vue-i18n.translate_9.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [translate](./vue-i18n.translate_9.md) + +## translate() function + +Signature: + +```typescript +export declare function translate(context: RuntimeTranslationContext, key: Path, named: NamedValue): MessageType | number; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| context | RuntimeTranslationContext<Messages, Message> | | +| key | Path | | +| named | NamedValue | | + +Returns: + +`MessageType | number` + diff --git a/docs/vue-i18n.translateoptions.md b/docs/vue-i18n.translateoptions.md new file mode 100644 index 000000000..63bf6399b --- /dev/null +++ b/docs/vue-i18n.translateoptions.md @@ -0,0 +1,45 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [TranslateOptions](./vue-i18n.translateoptions.md) + +## TranslateOptions type + +\# translate + +\#\# usages: // for example, locale messages key { 'foo.bar': 'hi {0} !' or 'hi {name} !' } + +// no argument, context & path only translate(context, 'foo.bar') + +// list argument translate(context, 'foo.bar', \['kazupon'\]) + +// named argument translate(context, 'foo.bar', { name: 'kazupon' }) + +// plural choice number translate(context, 'foo.bar', 2) + +// plural choice number with name argument translate(context, 'foo.bar', { name: 'kazupon' }, 2) + +// default message argument translate(context, 'foo.bar', 'this is default message') + +// default message with named argument translate(context, 'foo.bar', { name: 'kazupon' }, 'Hello {name} !') + +// use key as default message translate(context, 'hi {0} !', \['kazupon'\], { default: true }) + +// locale option, override context.locale translate(context, 'foo.bar', { name: 'kazupon' }, { locale: 'ja' }) + +// suppress localize miss warning option, override context.missingWarn translate(context, 'foo.bar', { name: 'kazupon' }, { missingWarn: false }) + +// suppress localize fallback warning option, override context.fallbackWarn translate(context, 'foo.bar', { name: 'kazupon' }, { fallbackWarn: false }) + +Signature: + +```typescript +export declare type TranslateOptions = { + list?: unknown[]; + named?: NamedValue; + plural?: number; + default?: string | boolean; + locale?: Locale; + missingWarn?: boolean; + fallbackWarn?: boolean; +}; +``` diff --git a/docs/vue-i18n.translation.md b/docs/vue-i18n.translation.md new file mode 100644 index 000000000..3dceee3a6 --- /dev/null +++ b/docs/vue-i18n.translation.md @@ -0,0 +1,82 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [Translation](./vue-i18n.translation.md) + +## Translation variable + +Signature: + +```typescript +Translation: (new () => import("vue").ComponentPublicInstance<{ + keypath: string; + scope: "parent" | "global"; +} & { + plural?: string | number | undefined; + tag?: string | undefined; + locale?: string | undefined; +}, () => VNodeChild, {}, {}, {}, Record any) | null>, import("vue").VNodeProps & { + keypath: string; +} & { + plural?: string | number | undefined; + tag?: string | undefined; + locale?: string | undefined; + scope?: "parent" | "global" | undefined; +}, import("vue").ComponentOptionsBase<{ + keypath: string; + scope: "parent" | "global"; +} & { + plural?: string | number | undefined; + tag?: string | undefined; + locale?: string | undefined; +}, () => VNodeChild, unknown, {}, {}, import("vue").ComponentOptionsBase, import("vue").ComponentOptionsBase, Record any) | null>, string>>) & import("vue").ComponentOptionsBase, () => VNodeChild, unknown, {}, {}, import("vue").ComponentOptionsBase, import("vue").ComponentOptionsBase, Record any) | null>, string> & { + props: { + keypath: { + type: StringConstructor; + required: true; + }; + plural: { + type: (StringConstructor | NumberConstructor)[]; + validator: (val: any) => boolean; + }; + tag: { + type: StringConstructor; + }; + locale: { + type: StringConstructor; + }; + scope: { + type: import("vue").PropType<"parent" | "global">; + validator: (val: "parent" | "global") => boolean; + default: "parent" | "global"; + }; + }; +} & ThisType, () => VNodeChild, {}, {}, {}, Record any) | null>, Readonly<{ + keypath: string; + scope: "parent" | "global"; +} & { + plural?: string | number | undefined; + tag?: string | undefined; + locale?: string | undefined; +}>, import("vue").ComponentOptionsBase, () => VNodeChild, unknown, {}, {}, import("vue").ComponentOptionsBase, import("vue").ComponentOptionsBase, Record any) | null>, string>>> +``` diff --git a/docs/vue-i18n.translationprops.keypath.md b/docs/vue-i18n.translationprops.keypath.md new file mode 100644 index 000000000..747ed0159 --- /dev/null +++ b/docs/vue-i18n.translationprops.keypath.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [TranslationProps](./vue-i18n.translationprops.md) > [keypath](./vue-i18n.translationprops.keypath.md) + +## TranslationProps.keypath property + +Signature: + +```typescript +keypath: string; +``` diff --git a/docs/vue-i18n.translationprops.md b/docs/vue-i18n.translationprops.md new file mode 100644 index 000000000..2c3cf921b --- /dev/null +++ b/docs/vue-i18n.translationprops.md @@ -0,0 +1,19 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [TranslationProps](./vue-i18n.translationprops.md) + +## TranslationProps interface + +Signature: + +```typescript +export interface TranslationProps extends BaseFormatProps +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [keypath](./vue-i18n.translationprops.keypath.md) | string | | +| [plural](./vue-i18n.translationprops.plural.md) | number | string | | + diff --git a/docs/vue-i18n.translationprops.plural.md b/docs/vue-i18n.translationprops.plural.md new file mode 100644 index 000000000..9f61a874d --- /dev/null +++ b/docs/vue-i18n.translationprops.plural.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [TranslationProps](./vue-i18n.translationprops.md) > [plural](./vue-i18n.translationprops.plural.md) + +## TranslationProps.plural property + +Signature: + +```typescript +plural?: number | string; +``` diff --git a/docs/vue-i18n.updatefallbacklocale.md b/docs/vue-i18n.updatefallbacklocale.md new file mode 100644 index 000000000..631368fe7 --- /dev/null +++ b/docs/vue-i18n.updatefallbacklocale.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [updateFallbackLocale](./vue-i18n.updatefallbacklocale.md) + +## updateFallbackLocale() function + +Signature: + +```typescript +export declare function updateFallbackLocale(ctx: RuntimeCommonContext, locale: Locale, fallback: FallbackLocale): void; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| ctx | RuntimeCommonContext<Message> | | +| locale | Locale | | +| fallback | FallbackLocale | | + +Returns: + +`void` + diff --git a/docs/vue-i18n.usei18n.md b/docs/vue-i18n.usei18n.md index 65f0e1ce6..d1a3f92e9 100644 --- a/docs/vue-i18n.usei18n.md +++ b/docs/vue-i18n.usei18n.md @@ -9,18 +9,18 @@ Use Composable API starting function Signature: ```typescript -export declare function useI18n(options?: UseI18nOptions): Composer; +export declare function useI18n> = Record>, DateTimeFormats extends Record = Record, NumberFormats extends Record = Record>(options?: Options): Composer; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | -| options | UseI18nOptions | See [UseI18nOptions](./vue-i18n.usei18noptions.md) | +| options | Options | See [UseI18nOptions](./vue-i18n.usei18noptions.md) | Returns: -`Composer` +`Composer` [Composer](./vue-i18n.composer.md) object diff --git a/docs/vue-i18n.vuei18n.getlocalemessage.md b/docs/vue-i18n.vuei18n.getlocalemessage.md index 62371c5c6..36362bac4 100644 --- a/docs/vue-i18n.vuei18n.getlocalemessage.md +++ b/docs/vue-i18n.vuei18n.getlocalemessage.md @@ -7,7 +7,7 @@ Signature: ```typescript -getLocaleMessage(locale: Locale): LocaleMessage; +getLocaleMessage(locale: Locale): LocaleMessageDictionary; ``` ## Parameters @@ -18,5 +18,5 @@ getLocaleMessage(locale: Locale): LocaleMessage; Returns: -`LocaleMessage` +`LocaleMessageDictionary` diff --git a/docs/vue-i18n.vuei18n.md b/docs/vue-i18n.vuei18n.md index eb3bf5aa4..8b57faaae 100644 --- a/docs/vue-i18n.vuei18n.md +++ b/docs/vue-i18n.vuei18n.md @@ -9,7 +9,7 @@ VueI18n Interfaces Signature: ```typescript -export interface VueI18n +export interface VueI18n ``` ## Remarks @@ -27,10 +27,10 @@ This interface is compatible with interface of `VueI18n` class (offered with vue | [formatter](./vue-i18n.vuei18n.formatter.md) | Formatter | | | [getChoiceIndex](./vue-i18n.vuei18n.getchoiceindex.md) | (choice: Choice, choicesLength: number) => number | | | [locale](./vue-i18n.vuei18n.locale.md) | Locale | | -| [messages](./vue-i18n.vuei18n.messages.md) | LocaleMessages | | +| [messages](./vue-i18n.vuei18n.messages.md) | Messages | | | [missing](./vue-i18n.vuei18n.missing.md) | MissingHandler | null | | | [numberFormats](./vue-i18n.vuei18n.numberformats.md) | NumberFormats | | -| [postTranslation](./vue-i18n.vuei18n.posttranslation.md) | PostTranslationHandler | null | | +| [postTranslation](./vue-i18n.vuei18n.posttranslation.md) | PostTranslationHandler<VueMessageType> | null | | | [preserveDirectiveContent](./vue-i18n.vuei18n.preservedirectivecontent.md) | boolean | | | [silentFallbackWarn](./vue-i18n.vuei18n.silentfallbackwarn.md) | boolean | RegExp | | | [silentTranslationWarn](./vue-i18n.vuei18n.silenttranslationwarn.md) | boolean | RegExp | | diff --git a/docs/vue-i18n.vuei18n.mergelocalemessage.md b/docs/vue-i18n.vuei18n.mergelocalemessage.md index 93b72de76..ea7b3f31d 100644 --- a/docs/vue-i18n.vuei18n.mergelocalemessage.md +++ b/docs/vue-i18n.vuei18n.mergelocalemessage.md @@ -7,7 +7,7 @@ Signature: ```typescript -mergeLocaleMessage(locale: Locale, message: LocaleMessage): void; +mergeLocaleMessage(locale: Locale, message: LocaleMessageDictionary): void; ``` ## Parameters @@ -15,7 +15,7 @@ mergeLocaleMessage(locale: Locale, message: LocaleMessage): void; | Parameter | Type | Description | | --- | --- | --- | | locale | Locale | | -| message | LocaleMessage | | +| message | LocaleMessageDictionary<VueMessageType> | | Returns: diff --git a/docs/vue-i18n.vuei18n.messages.md b/docs/vue-i18n.vuei18n.messages.md index ec2163bca..a93b1cf6f 100644 --- a/docs/vue-i18n.vuei18n.messages.md +++ b/docs/vue-i18n.vuei18n.messages.md @@ -7,5 +7,5 @@ Signature: ```typescript -readonly messages: LocaleMessages; +readonly messages: Messages; ``` diff --git a/docs/vue-i18n.vuei18n.posttranslation.md b/docs/vue-i18n.vuei18n.posttranslation.md index f1ec50d7e..505be7cfc 100644 --- a/docs/vue-i18n.vuei18n.posttranslation.md +++ b/docs/vue-i18n.vuei18n.posttranslation.md @@ -7,5 +7,5 @@ Signature: ```typescript -postTranslation: PostTranslationHandler | null; +postTranslation: PostTranslationHandler | null; ``` diff --git a/docs/vue-i18n.vuei18n.setlocalemessage.md b/docs/vue-i18n.vuei18n.setlocalemessage.md index 92722ffef..f5d02e50c 100644 --- a/docs/vue-i18n.vuei18n.setlocalemessage.md +++ b/docs/vue-i18n.vuei18n.setlocalemessage.md @@ -7,7 +7,7 @@ Signature: ```typescript -setLocaleMessage(locale: Locale, message: LocaleMessage): void; +setLocaleMessage(locale: Locale, message: LocaleMessageDictionary): void; ``` ## Parameters @@ -15,7 +15,7 @@ setLocaleMessage(locale: Locale, message: LocaleMessage): void; | Parameter | Type | Description | | --- | --- | --- | | locale | Locale | | -| message | LocaleMessage | | +| message | LocaleMessageDictionary<VueMessageType> | | Returns: diff --git a/docs/vue-i18n.vuei18n.t_5.md b/docs/vue-i18n.vuei18n.t_5.md index 67b39d839..3158ba30e 100644 --- a/docs/vue-i18n.vuei18n.t_5.md +++ b/docs/vue-i18n.vuei18n.t_5.md @@ -7,7 +7,7 @@ Signature: ```typescript -t(key: Path, named: object): TranslateResult; +t(key: Path, named: Record): TranslateResult; ``` ## Parameters @@ -15,7 +15,7 @@ t(key: Path, named: object): TranslateResult; | Parameter | Type | Description | | --- | --- | --- | | key | Path | | -| named | object | | +| named | Record<string, unknown> | | Returns: diff --git a/docs/vue-i18n.vuei18n.tc_3.md b/docs/vue-i18n.vuei18n.tc_3.md index 303d9ea59..674d4b042 100644 --- a/docs/vue-i18n.vuei18n.tc_3.md +++ b/docs/vue-i18n.vuei18n.tc_3.md @@ -7,7 +7,7 @@ Signature: ```typescript -tc(key: Path, named: object): TranslateResult; +tc(key: Path, named: Record): TranslateResult; ``` ## Parameters @@ -15,7 +15,7 @@ tc(key: Path, named: object): TranslateResult; | Parameter | Type | Description | | --- | --- | --- | | key | Path | | -| named | object | | +| named | Record<string, unknown> | | Returns: diff --git a/docs/vue-i18n.vuei18n.tc_7.md b/docs/vue-i18n.vuei18n.tc_7.md index 6cf4b3c1e..38e3e1393 100644 --- a/docs/vue-i18n.vuei18n.tc_7.md +++ b/docs/vue-i18n.vuei18n.tc_7.md @@ -7,7 +7,7 @@ Signature: ```typescript -tc(key: Path, choice: number, named: object): TranslateResult; +tc(key: Path, choice: number, named: Record): TranslateResult; ``` ## Parameters @@ -16,7 +16,7 @@ tc(key: Path, choice: number, named: object): TranslateResult; | --- | --- | --- | | key | Path | | | choice | number | | -| named | object | | +| named | Record<string, unknown> | | Returns: diff --git a/docs/vue-i18n.vuei18noptions.componentinstancecreatedlistener.md b/docs/vue-i18n.vuei18noptions.componentinstancecreatedlistener.md new file mode 100644 index 000000000..ee3e1aa60 --- /dev/null +++ b/docs/vue-i18n.vuei18noptions.componentinstancecreatedlistener.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [vue-i18n](./vue-i18n.md) > [VueI18nOptions](./vue-i18n.vuei18noptions.md) > [componentInstanceCreatedListener](./vue-i18n.vuei18noptions.componentinstancecreatedlistener.md) + +## VueI18nOptions.componentInstanceCreatedListener property + +Signature: + +```typescript +componentInstanceCreatedListener?: ComponentInstanceCreatedListener; +``` diff --git a/docs/vue-i18n.vuei18noptions.datetimeformats.md b/docs/vue-i18n.vuei18noptions.datetimeformats.md index db4589537..46b6f377f 100644 --- a/docs/vue-i18n.vuei18noptions.datetimeformats.md +++ b/docs/vue-i18n.vuei18noptions.datetimeformats.md @@ -7,5 +7,5 @@ Signature: ```typescript -datetimeFormats?: DateTimeFormats; +datetimeFormats?: DateTimeFormatsType; ``` diff --git a/docs/vue-i18n.vuei18noptions.md b/docs/vue-i18n.vuei18noptions.md index 55ea0b216..7a46d6d9b 100644 --- a/docs/vue-i18n.vuei18noptions.md +++ b/docs/vue-i18n.vuei18noptions.md @@ -21,20 +21,21 @@ This option is compatible with the constructor options of `VueI18n` class (offer | Property | Type | Description | | --- | --- | --- | | [availableLocales](./vue-i18n.vuei18noptions.availablelocales.md) | Locale[] | | -| [datetimeFormats](./vue-i18n.vuei18noptions.datetimeformats.md) | DateTimeFormats | | +| [componentInstanceCreatedListener](./vue-i18n.vuei18noptions.componentinstancecreatedlistener.md) | ComponentInstanceCreatedListener | | +| [datetimeFormats](./vue-i18n.vuei18noptions.datetimeformats.md) | DateTimeFormatsType | | | [fallbackLocale](./vue-i18n.vuei18noptions.fallbacklocale.md) | FallbackLocale | | | [fallbackRoot](./vue-i18n.vuei18noptions.fallbackroot.md) | boolean | | | [formatFallbackMessages](./vue-i18n.vuei18noptions.formatfallbackmessages.md) | boolean | | | [formatter](./vue-i18n.vuei18noptions.formatter.md) | Formatter | | | [locale](./vue-i18n.vuei18noptions.locale.md) | Locale | | -| [messages](./vue-i18n.vuei18noptions.messages.md) | LocaleMessages | | +| [messages](./vue-i18n.vuei18noptions.messages.md) | LocaleMessages<VueMessageType> | | | [missing](./vue-i18n.vuei18noptions.missing.md) | MissingHandler | | -| [modifiers](./vue-i18n.vuei18noptions.modifiers.md) | LinkedModifiers | | -| [numberFormats](./vue-i18n.vuei18noptions.numberformats.md) | NumberFormats | | +| [modifiers](./vue-i18n.vuei18noptions.modifiers.md) | LinkedModifiers<VueMessageType> | | +| [numberFormats](./vue-i18n.vuei18noptions.numberformats.md) | NumberFormatsType | | | [pluralizationRules](./vue-i18n.vuei18noptions.pluralizationrules.md) | PluralizationRules | | -| [postTranslation](./vue-i18n.vuei18noptions.posttranslation.md) | PostTranslationHandler | | +| [postTranslation](./vue-i18n.vuei18noptions.posttranslation.md) | PostTranslationHandler<VueMessageType> | | | [preserveDirectiveContent](./vue-i18n.vuei18noptions.preservedirectivecontent.md) | boolean | | -| [sharedMessages](./vue-i18n.vuei18noptions.sharedmessages.md) | LocaleMessages | | +| [sharedMessages](./vue-i18n.vuei18noptions.sharedmessages.md) | LocaleMessages<VueMessageType> | | | [silentFallbackWarn](./vue-i18n.vuei18noptions.silentfallbackwarn.md) | boolean | RegExp | | | [silentTranslationWarn](./vue-i18n.vuei18noptions.silenttranslationwarn.md) | boolean | RegExp | | | [sync](./vue-i18n.vuei18noptions.sync.md) | boolean | | diff --git a/docs/vue-i18n.vuei18noptions.messages.md b/docs/vue-i18n.vuei18noptions.messages.md index 36515de58..99b384766 100644 --- a/docs/vue-i18n.vuei18noptions.messages.md +++ b/docs/vue-i18n.vuei18noptions.messages.md @@ -7,5 +7,5 @@ Signature: ```typescript -messages?: LocaleMessages; +messages?: LocaleMessages; ``` diff --git a/docs/vue-i18n.vuei18noptions.modifiers.md b/docs/vue-i18n.vuei18noptions.modifiers.md index 9ca902838..8fddb0540 100644 --- a/docs/vue-i18n.vuei18noptions.modifiers.md +++ b/docs/vue-i18n.vuei18noptions.modifiers.md @@ -7,5 +7,5 @@ Signature: ```typescript -modifiers?: LinkedModifiers; +modifiers?: LinkedModifiers; ``` diff --git a/docs/vue-i18n.vuei18noptions.numberformats.md b/docs/vue-i18n.vuei18noptions.numberformats.md index f555549fd..6c00416be 100644 --- a/docs/vue-i18n.vuei18noptions.numberformats.md +++ b/docs/vue-i18n.vuei18noptions.numberformats.md @@ -7,5 +7,5 @@ Signature: ```typescript -numberFormats?: NumberFormats; +numberFormats?: NumberFormatsType; ``` diff --git a/docs/vue-i18n.vuei18noptions.posttranslation.md b/docs/vue-i18n.vuei18noptions.posttranslation.md index 2ed91e6c6..aeac8cfb7 100644 --- a/docs/vue-i18n.vuei18noptions.posttranslation.md +++ b/docs/vue-i18n.vuei18noptions.posttranslation.md @@ -7,5 +7,5 @@ Signature: ```typescript -postTranslation?: PostTranslationHandler; +postTranslation?: PostTranslationHandler; ``` diff --git a/docs/vue-i18n.vuei18noptions.sharedmessages.md b/docs/vue-i18n.vuei18noptions.sharedmessages.md index d520015f8..9f2a20f9d 100644 --- a/docs/vue-i18n.vuei18noptions.sharedmessages.md +++ b/docs/vue-i18n.vuei18noptions.sharedmessages.md @@ -7,5 +7,5 @@ Signature: ```typescript -sharedMessages?: LocaleMessages; +sharedMessages?: LocaleMessages; ```