Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Commit

Permalink
feat: allow osx locale/code and android code when searching for a lan…
Browse files Browse the repository at this point in the history
…guage
  • Loading branch information
Bas950 committed Aug 21, 2022
1 parent 62d745d commit cc3904d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/functions/findLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export default function findLanguage(lang: string) {
languages.find(l => l.ids.ISO_639_1 === lang.toLowerCase()) ??
languages.find(l => l.ids.ISO_639_2 === lang.toLowerCase()) ??
languages.find(l => l.ids.ISO_639_3 === lang.toLowerCase()) ??
languages.find(l => l.ids.osxLocale.toLowerCase() === lang.toLowerCase()) ??
languages.find(l => l.ids.osxCode.toLowerCase() === lang.toLowerCase()) ??
languages.find(l => l.ids.androidCode.toLowerCase() === lang.toLowerCase()) ??
languages.find(l => l.ids.locale.toLowerCase().includes(lang.toLowerCase())) ??
languages.find(l => l.name.toLowerCase() === lang.toLowerCase()) ??
languages.find(l => l.name.toLowerCase().includes(lang.toLowerCase()))
Expand Down
12 changes: 12 additions & 0 deletions src/tests/findLanguage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,16 @@ describe("findLanguage()", () => {
test("Finding the language of a language given its name", () => {
expect(findLanguage("english")).toStrictEqual(EN);
});

test("Finding the language of a language given its osxCode", () => {
expect(findLanguage("en.lproj")).toStrictEqual(EN);
});

test("Finding the language of a language given its osxLocale", () => {
expect(findLanguage("ar_BH")).toStrictEqual(BH);
});

test("Finding the language of a language given its android code", () => {
expect(findLanguage("ar-rBH")).toStrictEqual(BH);
});
});

0 comments on commit cc3904d

Please sign in to comment.