No more need to add '.clone()' for compiled translations, removed a bunch of 'clones'

This commit is contained in:
Pieter Vander Vennet 2021-10-25 21:50:38 +02:00
parent feb684d9e5
commit 9dc8404c43
8 changed files with 56 additions and 61 deletions

View file

@ -6,7 +6,6 @@ import BaseUIElement from "../BaseUIElement";
export default class Translations {
static t = AllTranslationAssets.t;
private static wtcache = {}
constructor() {
throw "Translations is static. If you want to intitialize a new translation, use the singular form"
@ -45,15 +44,10 @@ export default class Translations {
return undefined;
}
if (typeof (s) === "string") {
if (Translations.wtcache[s]) {
return Translations.wtcache[s];
}
const tr = new Translation({en: s});
Translations.wtcache[s] = tr;
return tr;
return new Translation({en: s});
}
if (s instanceof Translation) {
return s;
return s.Clone() /* MUST CLONE HERE! */;
}
console.error("Trying to Translation.WT, but got ", s)
throw "??? Not a valid translation"