From e5163ecb82187cf9c7aad7924e4c44deb46b8103 Mon Sep 17 00:00:00 2001 From: naskya Date: Thu, 23 Nov 2023 19:48:33 +0900 Subject: [PATCH] update langmap to sort out issues regarding Chinese locales --- packages/client/src/components/MkPostForm.vue | 13 +++++++++---- packages/client/src/scripts/langmap.ts | 18 ++++++------------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/packages/client/src/components/MkPostForm.vue b/packages/client/src/components/MkPostForm.vue index 14c7cd98b8..d881aa64a5 100644 --- a/packages/client/src/components/MkPostForm.vue +++ b/packages/client/src/components/MkPostForm.vue @@ -714,17 +714,22 @@ const language = ref( localStorage.getItem("lang")?.split("-")[0], ); -// example usage: -// filterLangmapByPrefix("zh") to take -// zh, zh-cn, zh-tw, zh-hk, etc. out of the langmap function filterLangmapByPrefix( prefix: string, ): { langCode: string; nativeName: string }[] { - return Object.entries(langmap) + const to_return = Object.entries(langmap) .filter(([langCode, _]) => langCode.startsWith(prefix)) .map(([langCode, v]) => { return { langCode, nativeName: v.nativeName }; }); + + if (prefix === "zh") + to_return = to_return.concat([ + { langCode: "yue", nativeName: langmap["yue"].nativeName }, + { langCode: "nan", nativeName: langmap["nan"].nativeName }, + ]); + + return to_return; } function setLanguage() { diff --git a/packages/client/src/scripts/langmap.ts b/packages/client/src/scripts/langmap.ts index ab7e2437c6..c0a2bb1669 100644 --- a/packages/client/src/scripts/langmap.ts +++ b/packages/client/src/scripts/langmap.ts @@ -354,6 +354,12 @@ export const iso639Langs3 = { tok: { nativeName: "Toki Pona", }, + yue: { + nativeName: "粵語", + }, + nan: { + nativeName: "閩南語", + }, }; export const langmapNoRegion = Object.assign({}, iso639Langs1, iso639Langs3); @@ -365,18 +371,6 @@ export const iso639Regional = { "zh-hant": { nativeName: "中文(繁體)", }, - "zh-cn": { - nativeName: "中文(中国大陆)", - }, - "zh-hk": { - nativeName: "中文(香港)", - }, - "zh-sg": { - nativeName: "中文(新加坡)", - }, - "zh-tw": { - nativeName: "中文(台灣)", - }, }; export const langmap = Object.assign({}, langmapNoRegion, iso639Regional);