@@ -61,17 +61,14 @@ export type LocaleMessages<Message = string> = Record<
61
61
>
62
62
63
63
/** @internal */
64
- export type RuntimeMissingType =
65
- | 'translate'
66
- | 'datetime format'
67
- | 'number format'
64
+ export type CoreMissingType = 'translate' | 'datetime format' | 'number format'
68
65
69
66
/** @internal */
70
- export type RuntimeMissingHandler < Message = string > = (
71
- context : RuntimeCommonContext < Message > ,
67
+ export type CoreMissingHandler < Message = string > = (
68
+ context : CoreCommonContext < Message > ,
72
69
locale : Locale ,
73
70
key : Path ,
74
- type : RuntimeMissingType ,
71
+ type : CoreMissingType ,
75
72
...values : unknown [ ]
76
73
) => string | void
77
74
/** @VueI 18nGeneral */
@@ -86,15 +83,15 @@ export type MessageCompiler<Message = string> = (
86
83
) => MessageFunction < Message >
87
84
88
85
/** @internal */
89
- export interface RuntimeOptions < Message = string > {
86
+ export interface CoreOptions < Message = string > {
90
87
locale ?: Locale
91
88
fallbackLocale ?: FallbackLocale
92
89
messages ?: LocaleMessages < Message >
93
90
datetimeFormats ?: DateTimeFormatsType
94
91
numberFormats ?: NumberFormatsType
95
92
modifiers ?: LinkedModifiers < Message >
96
93
pluralRules ?: PluralizationRules
97
- missing ?: RuntimeMissingHandler < Message >
94
+ missing ?: CoreMissingHandler < Message >
98
95
missingWarn ?: boolean | RegExp
99
96
fallbackWarn ?: boolean | RegExp
100
97
fallbackFormat ?: boolean
@@ -108,17 +105,17 @@ export interface RuntimeOptions<Message = string> {
108
105
}
109
106
110
107
/** @internal */
111
- export interface RuntimeInternalOptions {
108
+ export interface CoreInternalOptions {
112
109
__datetimeFormatters ?: Map < string , Intl . DateTimeFormat >
113
110
__numberFormatters ?: Map < string , Intl . NumberFormat >
114
111
__emitter ?: DevToolsEmitter // for vue-devtools timeline event
115
112
}
116
113
117
114
/** @internal */
118
- export interface RuntimeCommonContext < Message = string > {
115
+ export interface CoreCommonContext < Message = string > {
119
116
locale : Locale
120
117
fallbackLocale : FallbackLocale
121
- missing : RuntimeMissingHandler < Message > | null
118
+ missing : CoreMissingHandler < Message > | null
122
119
missingWarn : boolean | RegExp
123
120
fallbackWarn : boolean | RegExp
124
121
fallbackFormat : boolean
@@ -127,8 +124,8 @@ export interface RuntimeCommonContext<Message = string> {
127
124
}
128
125
129
126
/** @internal */
130
- export interface RuntimeTranslationContext < Messages = { } , Message = string >
131
- extends RuntimeCommonContext < Message > {
127
+ export interface CoreTranslationContext < Messages = { } , Message = string >
128
+ extends CoreCommonContext < Message > {
132
129
messages : Messages
133
130
modifiers : LinkedModifiers < Message >
134
131
pluralRules ?: PluralizationRules
@@ -140,29 +137,29 @@ export interface RuntimeTranslationContext<Messages = {}, Message = string>
140
137
}
141
138
142
139
/** @internal */
143
- export interface RuntimeDateTimeContext < DateTimeFormats = { } , Message = string >
144
- extends RuntimeCommonContext < Message > {
140
+ export interface CoreDateTimeContext < DateTimeFormats = { } , Message = string >
141
+ extends CoreCommonContext < Message > {
145
142
datetimeFormats : DateTimeFormats
146
143
}
147
144
148
145
/** @internal */
149
- export interface RuntimeNumberContext < NumberFormats = { } , Message = string >
150
- extends RuntimeCommonContext < Message > {
146
+ export interface CoreNumberContext < NumberFormats = { } , Message = string >
147
+ extends CoreCommonContext < Message > {
151
148
numberFormats : NumberFormats
152
149
}
153
150
154
151
/** @internal */
155
- export interface RuntimeContext <
152
+ export interface CoreContext <
156
153
Messages = { } ,
157
154
DateTimeFormats = { } ,
158
155
NumberFormats = { } ,
159
156
Message = string
160
- > extends RuntimeTranslationContext < Messages , Message > ,
161
- RuntimeDateTimeContext < DateTimeFormats , Message > ,
162
- RuntimeNumberContext < NumberFormats , Message > { }
157
+ > extends CoreTranslationContext < Messages , Message > ,
158
+ CoreDateTimeContext < DateTimeFormats , Message > ,
159
+ CoreNumberContext < NumberFormats , Message > { }
163
160
164
161
/** @internal */
165
- export interface RuntimeInternalContext {
162
+ export interface CoreInternalContext {
166
163
__datetimeFormatters : Map < string , Intl . DateTimeFormat >
167
164
__numberFormatters : Map < string , Intl . NumberFormat >
168
165
__localeChainCache ?: Map < Locale , Locale [ ] >
@@ -192,9 +189,9 @@ function getDefaultLinkedModifiers<
192
189
}
193
190
194
191
/** @internal */
195
- export function createRuntimeContext <
192
+ export function createCoreContext <
196
193
Message = string ,
197
- Options extends RuntimeOptions < Message > = object ,
194
+ Options extends CoreOptions < Message > = object ,
198
195
Messages extends Record <
199
196
keyof Options [ 'messages' ] ,
200
197
LocaleMessageDictionary < Message >
@@ -209,7 +206,7 @@ export function createRuntimeContext<
209
206
> = Record < keyof Options [ 'numberFormats' ] , NumberFormat >
210
207
> (
211
208
options : Options = { } as Options
212
- ) : RuntimeContext <
209
+ ) : CoreContext <
213
210
Options [ 'messages' ] ,
214
211
Options [ 'datetimeFormats' ] ,
215
212
Options [ 'numberFormats' ] ,
@@ -264,7 +261,7 @@ export function createRuntimeContext<
264
261
const onWarn = isFunction ( options . onWarn ) ? options . onWarn : warn
265
262
266
263
// setup internal options
267
- const internalOptions = options as RuntimeInternalOptions
264
+ const internalOptions = options as CoreInternalOptions
268
265
const __datetimeFormatters = isObject ( internalOptions . __datetimeFormatters )
269
266
? internalOptions . __datetimeFormatters
270
267
: new Map < string , Intl . DateTimeFormat > ( )
@@ -293,7 +290,7 @@ export function createRuntimeContext<
293
290
onWarn,
294
291
__datetimeFormatters,
295
292
__numberFormatters
296
- } as RuntimeContext <
293
+ } as CoreContext <
297
294
Options [ 'messages' ] ,
298
295
Options [ 'datetimeFormats' ] ,
299
296
Options [ 'numberFormats' ] ,
@@ -302,7 +299,7 @@ export function createRuntimeContext<
302
299
303
300
// for vue-devtools timeline event
304
301
if ( __DEV__ ) {
305
- ; ( ( context as unknown ) as RuntimeInternalContext ) . __emitter =
302
+ ; ( ( context as unknown ) as CoreInternalContext ) . __emitter =
306
303
internalOptions . __emitter != null ? internalOptions . __emitter : undefined
307
304
}
308
305
@@ -327,17 +324,17 @@ export function isTranslateMissingWarn(
327
324
328
325
/** @internal */
329
326
export function handleMissing < Message = string > (
330
- context : RuntimeCommonContext < Message > ,
327
+ context : CoreCommonContext < Message > ,
331
328
key : Path ,
332
329
locale : Locale ,
333
330
missingWarn : boolean | RegExp ,
334
- type : RuntimeMissingType
331
+ type : CoreMissingType
335
332
) : unknown {
336
333
const { missing, onWarn } = context
337
334
338
335
// for vue-devtools timeline event
339
336
if ( __DEV__ ) {
340
- const emitter = ( ( context as unknown ) as RuntimeInternalContext ) . __emitter
337
+ const emitter = ( ( context as unknown ) as CoreInternalContext ) . __emitter
341
338
if ( emitter ) {
342
339
emitter . emit ( DevToolsTimelineEvents . MISSING , {
343
340
locale,
@@ -360,11 +357,11 @@ export function handleMissing<Message = string>(
360
357
361
358
/** @internal */
362
359
export function getLocaleChain < Message = string > (
363
- ctx : RuntimeCommonContext < Message > ,
360
+ ctx : CoreCommonContext < Message > ,
364
361
fallback : FallbackLocale ,
365
362
start : Locale = ''
366
363
) : Locale [ ] {
367
- const context = ( ctx as unknown ) as RuntimeInternalContext
364
+ const context = ( ctx as unknown ) as CoreInternalContext
368
365
369
366
if ( start === '' ) {
370
367
return [ ]
@@ -463,11 +460,11 @@ function appendItemToChain(
463
460
464
461
/** @internal */
465
462
export function updateFallbackLocale < Message = string > (
466
- ctx : RuntimeCommonContext < Message > ,
463
+ ctx : CoreCommonContext < Message > ,
467
464
locale : Locale ,
468
465
fallback : FallbackLocale
469
466
) : void {
470
- const context = ( ctx as unknown ) as RuntimeInternalContext
467
+ const context = ( ctx as unknown ) as CoreInternalContext
471
468
context . __localeChainCache = new Map ( )
472
469
getLocaleChain ( ctx , fallback , locale )
473
470
}
0 commit comments