remove callback hell

This commit is contained in:
Felix Wiedenbach
2021-01-29 22:34:12 +01:00
parent db24f20289
commit 308774c2a6
2 changed files with 26 additions and 34 deletions

View File

@@ -318,24 +318,24 @@ var Module = Class.extend({
const languages = Object.keys(translations);
const fallbackLanguage = languages[0];
if (languages.length > 0) {
const translationFile = translations[language];
const translationsFallbackFile = translations[fallbackLanguage];
if (translationFile) {
Translator.load(this, translationFile, false, () => {
if (translationFile !== translationsFallbackFile) {
Translator.load(this, translationsFallbackFile, true, callback);
} else {
callback();
}
});
} else {
Translator.load(this, translationsFallbackFile, true, callback);
}
} else {
callback();
if (languages.length === 0) {
return callback();
}
const translationFile = translations[language];
const translationsFallbackFile = translations[fallbackLanguage];
if (!translationFile) {
return Translator.load(this, translationsFallbackFile, true, callback);
}
Translator.load(this, translationFile, false, () => {
if (translationFile !== translationsFallbackFile) {
Translator.load(this, translationsFallbackFile, true, callback);
} else {
callback();
}
});
},
/**