fix sonar findings and translation structure
This commit is contained in:
Vendored
+11
-19
@@ -3,15 +3,7 @@
|
||||
|
||||
const versions = Object.freeze({ app: '0.12.14', jquery: '4.0.0', jqueryUi: '1.14.2' });
|
||||
const steps = ['storage', 'jquery', 'jquery-ui', 'modules', 'server', 'routes', 'location'];
|
||||
const stepLabels = Object.freeze({
|
||||
get storage() { return globalThis.Wegwichtel.I18n.t("bootstrap-loader.gespeicherte.inhalte.prufen"); },
|
||||
get jquery() { return globalThis.Wegwichtel.I18n.t("bootstrap-loader.wegwichtel.vorbereiten"); },
|
||||
get 'jquery-ui'() { return globalThis.Wegwichtel.I18n.t("bootstrap-loader.die.bedienung.vorbereiten"); },
|
||||
get modules() { return globalThis.Wegwichtel.I18n.t("bootstrap-loader.die.app.vorbereiten"); },
|
||||
get server() { return globalThis.Wegwichtel.I18n.t("bootstrap-loader.verbindung.prufen"); },
|
||||
get routes() { return globalThis.Wegwichtel.I18n.t("bootstrap-loader.strecken.laden"); },
|
||||
get location() { return globalThis.Wegwichtel.I18n.t("bootstrap.location"); }
|
||||
});
|
||||
const stepLabel = step => globalThis.Wegwichtel.I18n.t(`bootstrap-loader.steps.${step}`);
|
||||
const screen = document.getElementById('bootstrap-screen');
|
||||
const progress = document.getElementById('bootstrap-progress');
|
||||
const errorBox = document.getElementById('bootstrap-error');
|
||||
@@ -43,8 +35,8 @@
|
||||
androidBrowserHint.hidden = false;
|
||||
androidBrowserHint.dataset.browser = isChrome ? 'chrome' : 'other';
|
||||
androidBrowserHint.textContent = isChrome
|
||||
? globalThis.Wegwichtel.I18n.t("bootstrap-loader.auf.diesem.gerat.kannst.du.bilder.und")
|
||||
: globalThis.Wegwichtel.I18n.t("bootstrap-loader.tipp.fur.android.mit.chrome.lassen.sich");
|
||||
? globalThis.Wegwichtel.I18n.t("bootstrap-loader.hints.chrome")
|
||||
: globalThis.Wegwichtel.I18n.t("bootstrap-loader.hints.android");
|
||||
}
|
||||
|
||||
function schedule(callback, delay = 0) {
|
||||
@@ -77,7 +69,7 @@
|
||||
}
|
||||
|
||||
function announceStep(step) {
|
||||
if (stepLabels[step]) setStatusText(stepLabels[step]);
|
||||
if (steps.includes(step)) setStatusText(stepLabel(step));
|
||||
}
|
||||
|
||||
function mark(step, state) {
|
||||
@@ -93,7 +85,7 @@
|
||||
if (progress) progress.value = completedSteps.size;
|
||||
|
||||
if (state === 'failed') {
|
||||
setStatusText(globalThis.Wegwichtel.I18n.t("bootstrap.step.failed", { value1: stepLabels[step] || step }));
|
||||
setStatusText(globalThis.Wegwichtel.I18n.t("bootstrap-loader.error.step-error", { value1: stepLabel(step) }));
|
||||
return;
|
||||
}
|
||||
if (state === 'done') {
|
||||
@@ -108,10 +100,10 @@
|
||||
script.src = versioned(src);
|
||||
script.async = false;
|
||||
script.onload = () => {
|
||||
if (test && !test()) reject(new Error(globalThis.Wegwichtel.I18n.t("bootstrap-loader.ein.teil.der.app.konnte.nicht.starten")));
|
||||
if (test && !test()) reject(new Error(globalThis.Wegwichtel.I18n.t("bootstrap-loader.error.start-error")));
|
||||
else resolve();
|
||||
};
|
||||
script.onerror = () => reject(new Error(globalThis.Wegwichtel.I18n.t("bootstrap-loader.ein.teil.der.app.konnte.nicht.geladen")));
|
||||
script.onerror = () => reject(new Error(globalThis.Wegwichtel.I18n.t("bootstrap-loader.error.load-error")));
|
||||
document.head.appendChild(script);
|
||||
});
|
||||
}
|
||||
@@ -127,7 +119,7 @@
|
||||
}
|
||||
|
||||
function updateCleanupProgress(removed, total) {
|
||||
cleanupStatus.textContent = globalThis.Wegwichtel.I18n.t("bootstrap-loader.alten.fortschritt.loschen", { value1: removed, value2: total });
|
||||
cleanupStatus.textContent = globalThis.Wegwichtel.I18n.t("bootstrap-loader.cleanup-progress", { value1: removed, value2: total });
|
||||
cleanupStatus.hidden = false;
|
||||
}
|
||||
|
||||
@@ -161,7 +153,7 @@
|
||||
screen.classList.add('ready');
|
||||
readyText.hidden = false;
|
||||
|
||||
setStatusText(globalThis.Wegwichtel.I18n.t("bootstrap.ready"));
|
||||
setStatusText(globalThis.Wegwichtel.I18n.t("bootstrap-loader.ready"));
|
||||
actionStatus?.classList.add('is-leaving');
|
||||
enter.hidden = false;
|
||||
const showEnter = () => enter.classList.add('is-visible');
|
||||
@@ -194,7 +186,7 @@
|
||||
|
||||
try {
|
||||
await globalThis.Wegwichtel.OfflineCache?.initialize();
|
||||
setStatusText(stepLabels.storage, true);
|
||||
setStatusText(stepLabel('storage'), true);
|
||||
await cleanupOldProgress();
|
||||
mark('storage', 'done');
|
||||
|
||||
@@ -222,7 +214,7 @@
|
||||
console.error(error);
|
||||
const current = nextPendingStep();
|
||||
if (current) mark(current, 'failed');
|
||||
errorBox.textContent = globalThis.Wegwichtel.UserMessages?.error(error, globalThis.Wegwichtel.I18n.t("bootstrap-loader.wegwichtel.konnte.nicht.starten.prufe.deine.verbindung")) || globalThis.Wegwichtel.I18n.t("bootstrap-loader.wegwichtel.konnte.nicht.starten.bitte.versuche.es");
|
||||
errorBox.textContent = globalThis.Wegwichtel.UserMessages?.error(error, globalThis.Wegwichtel.I18n.t("bootstrap-loader.error.connection-error")) || globalThis.Wegwichtel.I18n.t("bootstrap-loader.error.init-error");
|
||||
errorBox.hidden = false;
|
||||
retry.hidden = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user