@@ -20,23 +20,28 @@ import { defineMixin } from './mixin'
20
20
import { isEmptyObject } from './utils'
21
21
22
22
/**
23
- * I18n Options
23
+ * I18n Options for `createI18n`
24
24
*
25
25
* @remarks
26
- * `I18nOptions` is inherited {@link ComposerOptions} and {@link VueI18nOptions}, so you can specify these options.
26
+ * `I18nOptions` is inherited {@link I18nAdditionalOptions}, {@link ComposerOptions} and {@link VueI18nOptions},
27
+ * so you can specify these options.
27
28
*
28
29
*/
30
+ export type I18nOptions = I18nAdditionalOptions &
31
+ ( ComposerOptions | VueI18nOptions )
32
+
33
+ /**
34
+ * I18n Additional Options for `createI18n`
35
+ */
29
36
export interface I18nAdditionalOptions {
30
37
/**
31
38
* Whether vue-i18n legacy API use on your Vue App.
39
+ *
32
40
* @defaultValue `false`
33
41
*/
34
42
legacy ?: boolean
35
43
}
36
44
37
- export type I18nOptions = I18nAdditionalOptions &
38
- ( ComposerOptions | VueI18nOptions )
39
-
40
45
/**
41
46
* I18n API mode
42
47
*/
@@ -46,16 +51,32 @@ export type I18nMode = 'legacy' | 'composable'
46
51
* I18n interface
47
52
*/
48
53
export interface I18n {
54
+ /**
55
+ * I18n API mode
56
+ *
57
+ * @remarks
58
+ * if you specified `legacy: true` option in `createI18n`, return `legacy`,
59
+ * else `composable`
60
+ *
61
+ * @defaultValue `composable`
62
+ */
49
63
readonly mode : I18nMode
64
+ /**
65
+ * Global composer
66
+ */
67
+ readonly global : Composer
68
+ /**
69
+ * @internal
70
+ */
50
71
install ( app : App , ...options : unknown [ ] ) : void
51
72
}
52
73
53
74
/**
54
75
* I18n interface for internal usage
76
+ *
55
77
* @internal
56
78
*/
57
79
export interface I18nInternal {
58
- readonly _global : Composer
59
80
_getComposer ( instance : ComponentInternalInstance ) : Composer | null
60
81
_setComposer ( instance : ComponentInternalInstance , composer : Composer ) : void
61
82
_deleteComposer ( instance : ComponentInternalInstance ) : void
@@ -70,17 +91,24 @@ export interface I18nInternal {
70
91
export type I18nScope = 'local' | 'parent' | 'global'
71
92
72
93
/**
73
- * Composer additional options
94
+ * I18n Options for `useI18n`
95
+ *
96
+ * @remarks
97
+ * `UseI18nOptions` is inherited {@link ComposerAdditionalOptions} and {@link ComposerOptions},
98
+ * so you can specify these options.
99
+ */
100
+ export type UseI18nOptions = ComposerAdditionalOptions & ComposerOptions
101
+
102
+ /**
103
+ * Composer additional options for `useI18n`
74
104
*
75
- * @remarks
105
+ * @remarks
76
106
* `ComposerAdditionalOptions` is extend for {@link ComposerOptions}, so you can specify these options.
77
107
*/
78
108
export interface ComposerAdditionalOptions {
79
- useScope ?: I18nScope // default 'global'
109
+ useScope ?: I18nScope
80
110
}
81
111
82
- export type UseI18nOptions = ComposerAdditionalOptions & ComposerOptions
83
-
84
112
/**
85
113
* I18n instance injectin key
86
114
* @internal
@@ -97,7 +125,7 @@ export const I18nSymbol: InjectionKey<I18n & I18nInternal> = Symbol.for(
97
125
*
98
126
* @remarks
99
127
* When you use Composable API, you need to specify options of {@link ComposerOptions}.
100
- * When you use Legacy API, you need toto specify options of {@link VueI18nOptions} and `legacy: true`.
128
+ * When you use Legacy API, you need toto specify options of {@link VueI18nOptions} and `legacy: true` option .
101
129
*
102
130
* @example
103
131
* case: for Composable API
@@ -181,7 +209,7 @@ export function createI18n(options: I18nOptions = {}): I18n {
181
209
)
182
210
}
183
211
} ,
184
- get _global ( ) : Composer {
212
+ get global ( ) : Composer {
185
213
return __legacyMode
186
214
? ( __global as VueI18n ) . __composer
187
215
: ( __global as Composer )
@@ -264,7 +292,7 @@ export function useI18n(options: UseI18nOptions = {}): Composer {
264
292
throw new Error ( 'TODO' )
265
293
}
266
294
267
- const global = i18n . _global
295
+ const global = i18n . global
268
296
269
297
let emptyOption = false
270
298
// prettier-ignore
0 commit comments