Skip to content

Commit 80a3810

Browse files
authored
Merge pull request #1471 from i18next/fix-getBestMatchFromCodes
getBestMatchFromCodes: use fallbackLng if nothing found, fixes #1470
2 parents fdb526b + ba5c120 commit 80a3810

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/LanguageUtils.js

+3
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ class LanguageUtil {
111111
});
112112
}
113113

114+
// if nothing found, use fallbackLng
115+
if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
116+
114117
return found;
115118
}
116119

test/languageUtils.spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ describe('LanguageUtils', () => {
228228
{ args: [['en-GB']], expected: 'en' },
229229
{ args: [['ru', 'en-GB']], expected: 'en' },
230230
{ args: [['de-CH']], expected: 'de-DE' },
231+
{ args: [['ru']], expected: 'en' },
232+
{ args: [[]], expected: 'en' },
231233
];
232234

233235
tests.forEach(test => {

0 commit comments

Comments
 (0)