From 519363151e9b7730ba1e531c7c322ca4689ca023 Mon Sep 17 00:00:00 2001 From: Seanghay Yath Date: Wed, 12 Oct 2022 13:59:56 +0700 Subject: [PATCH 1/2] Support Khmer language (Cambodia) --- src/language.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/language.ts b/src/language.ts index c1080430..37abc65c 100644 --- a/src/language.ts +++ b/src/language.ts @@ -21,6 +21,7 @@ const code = { ja: /\p{scx=Hira}|\p{scx=Kana}|[,;:]/u, ko: /\p{scx=Hangul}/u, zh: /\p{scx=Han}/u, + km: /\p{scx=Khmer}/u, th: /\p{scx=Thai}/u, bn: /\p{scx=Bengali}/u, ar: /\p{scx=Arabic}/u, From c05890d316a9b3b98c56a2cd3b93a97ba24142d0 Mon Sep 17 00:00:00 2001 From: Seanghay Yath Date: Wed, 12 Oct 2022 23:54:19 +0700 Subject: [PATCH 2/2] add test for Khmer language --- test/language.test.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/language.test.tsx b/test/language.test.tsx index d450b666..8e2417c0 100644 --- a/test/language.test.tsx +++ b/test/language.test.tsx @@ -28,7 +28,11 @@ describe('detectLanguageCode', () => { it('should detect traditional chinese', async () => { expect(detectLanguageCode('我知道怎麼說中文')).toBe('zh') }) - + + it('should detect khmer', async () => { + expect(detectLanguageCode('សួស្តី')).toBe('km') + }) + it('should detect thai', async () => { expect(detectLanguageCode('สวัสดี')).toBe('th') })