Use browser locales API to generate language labels
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user