update langmap to sort out issues regarding Chinese locales
This commit is contained in:
parent
610722e258
commit
e5163ecb82
2 changed files with 15 additions and 16 deletions
|
@ -714,17 +714,22 @@ const language = ref<string>(
|
|||
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() {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue