Merge branch 'develop' into feature/add-error-to-callback

# Conflicts:
#	CHANGELOG.md
This commit is contained in:
Felix Wiedenbach
2021-02-06 11:29:17 +01:00
52 changed files with 1397 additions and 1340 deletions

View File

@@ -548,6 +548,11 @@ var MM = (function () {
return;
}
if (!module.data.position) {
Log.warn("module tries to update the DOM without being displayed.");
return;
}
// Further implementation is done in the private method.
updateDom(module, speed);
},

View File

@@ -311,33 +311,31 @@ var Module = Class.extend({
*
* @param {Function} callback Function called when done.
*/
loadTranslations: function (callback) {
var self = this;
var translations = this.getTranslations();
var lang = config.language.toLowerCase();
loadTranslations(callback) {
const translations = this.getTranslations() || {};
const language = config.language.toLowerCase();
// The variable `first` will contain the first
// defined translation after the following line.
for (var first in translations) {
break;
const languages = Object.keys(translations);
const fallbackLanguage = languages[0];
if (languages.length === 0) {
return callback();
}
if (translations) {
var translationFile = translations[lang] || undefined;
var translationsFallbackFile = translations[first];
const translationFile = translations[language];
const translationsFallbackFile = translations[fallbackLanguage];
// If a translation file is set, load it and then also load the fallback translation file.
// Otherwise only load the fallback translation file.
if (translationFile !== undefined && translationFile !== translationsFallbackFile) {
Translator.load(self, translationFile, false, function () {
Translator.load(self, translationsFallbackFile, true, callback);
});
if (!translationFile) {
return Translator.load(this, translationsFallbackFile, true, callback);
}
Translator.load(this, translationFile, false, () => {
if (translationFile !== translationsFallbackFile) {
Translator.load(this, translationsFallbackFile, true, callback);
} else {
Translator.load(self, translationsFallbackFile, true, callback);
callback();
}
} else {
callback();
}
});
},
/**

View File

@@ -103,26 +103,18 @@ var Translator = (function () {
* @param {boolean} isFallback Flag to indicate fallback translations.
* @param {Function} callback Function called when done.
*/
load: function (module, file, isFallback, callback) {
if (!isFallback) {
Log.log(module.name + " - Load translation: " + file);
} else {
Log.log(module.name + " - Load translation fallback: " + file);
load(module, file, isFallback, callback) {
Log.log(`${module.name} - Load translation${isFallback && " fallback"}: ${file}`);
if (this.translationsFallback[module.name]) {
return callback();
}
var self = this;
if (!this.translationsFallback[module.name]) {
loadJSON(module.file(file), function (json) {
if (!isFallback) {
self.translations[module.name] = json;
} else {
self.translationsFallback[module.name] = json;
}
callback();
});
} else {
loadJSON(module.file(file), (json) => {
const property = isFallback ? "translationsFallback" : "translations";
this[property][module.name] = json;
callback();
}
});
},
/**