diff --git a/packages/lib/locale.test.ts b/packages/lib/locale.test.ts index 0627ef5ba5..641119f3e4 100644 --- a/packages/lib/locale.test.ts +++ b/packages/lib/locale.test.ts @@ -1,4 +1,4 @@ -import { closestSupportedLocale, parsePluralForm, setLocale, _n } from './locale'; +import { closestSupportedLocale, parsePluralForm, setLocale, _n, toIso639 } from './locale'; describe('locale', () => { @@ -91,4 +91,14 @@ describe('locale', () => { } }); + test.each([ + ['en_GB', 'eng'], + ['en', 'eng'], + ['de', 'deu'], + ['fr_FR', 'fra'], + ])('should convert to ISO-639', (input, expected) => { + const actual = toIso639(input); + expect(actual).toBe(expected); + }); + }); diff --git a/packages/lib/locale.ts b/packages/lib/locale.ts index 600a4fed3d..6bf10d6d97 100644 --- a/packages/lib/locale.ts +++ b/packages/lib/locale.ts @@ -213,6 +213,7 @@ const iso639Map_ = [ ['cos', 'co'], ['cre', 'cr'], ['dan', 'da'], + ['deu', 'de'], ['div', 'dv'], ['dzo', 'dz'], ['eng', 'en'],