Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
chore: improve language preloading
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKohler committed May 19, 2020
1 parent 473060a commit e16ffce
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions server/lib/languages.js
Expand Up @@ -168,21 +168,23 @@ const LANGUAGES_TO_REMOVE = [
'nn' // coverted by nn-NO
];

const isoLanguages = ISO6391.getLanguages(ISO6391.getAllCodes());
const languagesWithoutRemoved = removeLanguages(isoLanguages);
const codeIdReplaced = languagesWithoutRemoved.map((lang) => ({
id: lang.code,
name: lang.name,
nativeName: lang.nativeName,
}));
const allLanguages = addAdditionalLanguages(codeIdReplaced);
const allLanguagesSorted = allLanguages.sort((a, b) => {
if (a.name < b.name) return -1;
if (a.name > b.name) return 1;
return 0;
});
const loadedLanguages = allLanguagesSorted;

function getAllLanguages() {
const isoLanguages = ISO6391.getLanguages(ISO6391.getAllCodes());
const languagesWithoutRemoved = removeLanguages(isoLanguages);
const codeIdReplaced = languagesWithoutRemoved.map((lang) => ({
id: lang.code,
name: lang.name,
nativeName: lang.nativeName,
}));
const allLanguages = addAdditionalLanguages(codeIdReplaced);
const allLanguagesSorted = allLanguages.sort((a, b) => {
if (a.name < b.name) return -1;
if (a.name > b.name) return 1;
return 0;
});
return allLanguagesSorted;
return loadedLanguages;
}

function removeLanguages(languages) {
Expand Down

0 comments on commit e16ffce

Please sign in to comment.