Use some es6 notation

This commit is contained in:
rejas
2021-03-25 17:29:27 +01:00
parent a99de1ad13
commit 670a760404

View File

@@ -14,7 +14,7 @@ var Translator = (function () {
* @param {Function} callback Function called when done. * @param {Function} callback Function called when done.
*/ */
function loadJSON(file, callback) { function loadJSON(file, callback) {
var xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
xhr.overrideMimeType("application/json"); xhr.overrideMimeType("application/json");
xhr.open("GET", file, true); xhr.open("GET", file, true);
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
@@ -124,18 +124,16 @@ var Translator = (function () {
* @param {string} lang The language identifier of the core language. * @param {string} lang The language identifier of the core language.
*/ */
loadCoreTranslations: function (lang) { loadCoreTranslations: function (lang) {
var self = this;
if (lang in translations) { if (lang in translations) {
Log.log("Loading core translation file: " + translations[lang]); Log.log("Loading core translation file: " + translations[lang]);
loadJSON(translations[lang], function (translations) { loadJSON(translations[lang], (translations) => {
self.coreTranslations = translations; this.coreTranslations = translations;
}); });
} else { } else {
Log.log("Configured language not found in core translations."); Log.log("Configured language not found in core translations.");
} }
self.loadCoreTranslationsFallback(); this.loadCoreTranslationsFallback();
}, },
/** /**
@@ -143,8 +141,6 @@ var Translator = (function () {
* The first language defined in translations.js will be used. * The first language defined in translations.js will be used.
*/ */
loadCoreTranslationsFallback: function () { loadCoreTranslationsFallback: function () {
var self = this;
// The variable `first` will contain the first // The variable `first` will contain the first
// defined translation after the following line. // defined translation after the following line.
for (var first in translations) { for (var first in translations) {
@@ -153,8 +149,8 @@ var Translator = (function () {
if (first) { if (first) {
Log.log("Loading core translation fallback file: " + translations[first]); Log.log("Loading core translation fallback file: " + translations[first]);
loadJSON(translations[first], function (translations) { loadJSON(translations[first], (translations) => {
self.coreTranslationsFallback = translations; this.coreTranslationsFallback = translations;
}); });
} }
} }