File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -100,4 +100,19 @@ describe("i18n", () => {
100
100
expect ( ( x . i18n . value as any ) . hello ) . toBeUndefined ( ) ;
101
101
} ) ;
102
102
} ) ;
103
+
104
+ it ( "should fallback if the locale is different than fallback locale" , async ( ) => {
105
+ const x = buildI18n ( {
106
+ locale : "jp" ,
107
+ fallback : "en" ,
108
+ messages : {
109
+ en : { hello : "Hello" } ,
110
+ jp : { }
111
+ }
112
+ } ) ;
113
+
114
+ await nextTick ( ) ;
115
+
116
+ expect ( ( x . i18n . value as any ) . hello ) . toBe ( "Hello" ) ;
117
+ } ) ;
103
118
} ) ;
Original file line number Diff line number Diff line change @@ -134,7 +134,10 @@ export function buildI18n<
134
134
135
135
let fallbackIsPromise = false ;
136
136
if ( shouldFallback ) {
137
- const fallbackI18n = loadLocale ( locale . value as string , localeMessages ) ;
137
+ const fallbackI18n = loadLocale (
138
+ definition . fallback ! as string ,
139
+ localeMessages
140
+ ) ;
138
141
if ( isPromise ( fallbackI18n ) ) {
139
142
fallbackI18n . then ( x => {
140
143
fallback = x ;
@@ -147,7 +150,7 @@ export function buildI18n<
147
150
fallback . value = { } ;
148
151
}
149
152
150
- watch (
153
+ watch (
151
154
[ locale , fallback ] ,
152
155
async ( [ l , fb ] : [ keyof TMessage , i18n | undefined ] ) => {
153
156
if ( l === definition . fallback && shouldFallback ) {
You can’t perform that action at this time.
0 commit comments