Use browser locales API to generate language labels

This commit is contained in:
Johannes Zellner
2025-10-20 09:04:29 +02:00
parent a415b70adf
commit f5c81f5882
2 changed files with 12 additions and 2 deletions
+6 -1
View File
@@ -58,9 +58,14 @@ onMounted(async () => {
if (error) return console.error(error);
allLanguages.value = result.map(l => {
const displayNames = new Intl.DisplayNames(['en'], { type: 'language' });
// hack for chinese simplified
l = l === 'zh_Hans' ? 'zh' : l;
return {
id: l,
display: t(`lang.${l}`, l /* default fallback */, { locale: 'en' })
display: displayNames.of(l) || l,
};
}).sort((a, b) => {
return a.display.localeCompare(b.display);