@@ -259,28 +259,28 @@ export abstract class Loader extends Disposable {
259
259
return new LocaleNode ( { keypath : key , shadow : true } )
260
260
}
261
261
262
- getNodeByKey ( key : string , shadow = false ) : LocaleNode | undefined {
262
+ getNodeByKey ( key : string , shadow = false , locale ?: string ) : LocaleNode | undefined {
263
263
const node = resolveFlattenRoot ( this . getTreeNodeByKey ( key ) )
264
264
if ( ! node && shadow )
265
265
return this . getShadowNodeByKey ( key )
266
266
if ( node && node . type !== 'tree' )
267
267
return node
268
268
269
- // TODO: maybe use something other than Config.displayLanguage?
269
+ const language = locale || Config . sourceLanguage
270
270
if (
271
271
node
272
272
&& node . type === 'tree'
273
273
&& Config . _keyStyle !== 'flat'
274
- && this . treeNodeValueHasPluralizationKeys ( node . values [ Config . displayLanguage ] )
274
+ && this . treeNodeValueHasPluralizationKeys ( node . values [ language ] )
275
275
) {
276
- const subkey = this . firstPluralizationKey ( node . values [ Config . displayLanguage ] )
276
+ const subkey = this . firstPluralizationKey ( node . values [ language ] )
277
277
if ( subkey && node . children [ subkey ] && node . children [ subkey ] . type === 'node' )
278
- return node . children [ subkey ]
278
+ return node . children [ subkey ] as LocaleNode
279
279
}
280
280
}
281
281
282
- getTranslationsByKey ( key : string , shadow = true ) {
283
- const node = this . getNodeByKey ( key , shadow )
282
+ getTranslationsByKey ( key : string , shadow = true , locale ?: string ) {
283
+ const node = this . getNodeByKey ( key , shadow , locale )
284
284
if ( ! node )
285
285
return { }
286
286
if ( shadow )
@@ -290,7 +290,7 @@ export abstract class Loader extends Disposable {
290
290
}
291
291
292
292
getRecordByKey ( key : string , locale : string , shadow = false ) : LocaleRecord | undefined {
293
- const trans = this . getTranslationsByKey ( key , shadow )
293
+ const trans = this . getTranslationsByKey ( key , shadow , locale )
294
294
return trans [ locale ]
295
295
}
296
296
0 commit comments