core&ui: add language filter (#346)

This commit is contained in:
panda authored and GitHub committed 2022-04-25 22:26:08 +08:00
1 parent 59f1b4e429
commit 84d69bc348
7 files changed
+57 -34

No files matched your search

@@ -0,0 +1,12 @@
const prefixes = new Set(Object.keys(LANGS).filter((i) => i.includes('.')).map((i) => i.split('.')[0]));
export default function getAvaliableLangs(langsList?: string[]) {
const Langs = {};
for (const key in LANGS) {
if (prefixes.has(key)) continue;
if (langsList && !langsList.includes(key)) continue;
if (LANGS[key].hidden && !langsList?.includes(key)) continue;
Langs[key] = LANGS[key];
}
return Langs;
}