Skip to content

Commit

Permalink
sort languages by language code
Browse files Browse the repository at this point in the history
  • Loading branch information
mayswind committed Mar 30, 2024
1 parent 185758b commit 46caf46
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/lib/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,6 @@ function getAllLanguageInfos() {
function getAllLanguageInfoArray(translateFn, includeSystemDefault) {
const ret = [];

if (includeSystemDefault) {
ret.push({
code: '',
displayName: translateFn('System Default')
});
}

for (const code in allLanguages) {
if (!Object.prototype.hasOwnProperty.call(allLanguages, code)) {
continue;
Expand All @@ -195,6 +188,17 @@ function getAllLanguageInfoArray(translateFn, includeSystemDefault) {
});
}

ret.sort(function (lang1, lang2) {
return lang1.code.localeCompare(lang2.code);
});

if (includeSystemDefault) {
ret.splice(0, 0, {
code: '',
displayName: translateFn('System Default')
});
}

return ret;
}

Expand Down

0 comments on commit 46caf46

Please sign in to comment.