Add binoculars theme, auto reformat everything

This commit is contained in:
Pieter Vander Vennet 2021-09-09 00:05:51 +02:00
parent 38dea806c5
commit 78d6482c88
586 changed files with 115573 additions and 111842 deletions

View file

@ -16,7 +16,7 @@ export default class Locale {
source.setData(language)
}
source.syncWith(
QueryParameters.GetQueryParameter("language", undefined,"The language to display mapcomplete in. Will be ignored in case a logged-in-user did set their language before. If the specified language does not exist, it will default to the first language in the theme."),
QueryParameters.GetQueryParameter("language", undefined, "The language to display mapcomplete in. Will be ignored in case a logged-in-user did set their language before. If the specified language does not exist, it will default to the first language in the theme."),
true
)
}

View file

@ -31,10 +31,10 @@ export class Translation extends BaseUIElement {
}
get txt(): string {
return this.textFor(Translation.forcedLanguage ?? Locale.language.data)
return this.textFor(Translation.forcedLanguage ?? Locale.language.data)
}
public textFor(language: string): string{
public textFor(language: string): string {
if (this.translations["*"]) {
return this.translations["*"];
}
@ -55,7 +55,7 @@ export class Translation extends BaseUIElement {
console.error("Missing language ", Locale.language.data, "for", this.translations)
return "";
}
InnerConstructElement(): HTMLElement {
const el = document.createElement("span")
Locale.language.addCallbackAndRun(_ => {
@ -73,7 +73,7 @@ export class Translation extends BaseUIElement {
if (translationsKey === "#") {
continue;
}
if(!this.translations.hasOwnProperty(translationsKey)){
if (!this.translations.hasOwnProperty(translationsKey)) {
continue
}
langs.push(translationsKey)
@ -112,7 +112,7 @@ export class Translation extends BaseUIElement {
} else if (el.ConstructElement === undefined) {
console.error("ConstructElement is not defined", el);
throw "ConstructElement is not defined, you are working with a " + (typeof el) + ":" + (el.constructor.name)
}else if(el["textFor"] !== undefined){
} else if (el["textFor"] !== undefined) {
// @ts-ignore
rtext = el.textFor(lang)
} else {
@ -195,5 +195,5 @@ export class Translation extends BaseUIElement {
}
return allIcons.filter(icon => icon != undefined)
}
}

View file

@ -5,57 +5,57 @@ 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"
}
static t = AllTranslationAssets.t;
public static W(s: string | BaseUIElement): BaseUIElement {
if (typeof (s) === "string") {
return new FixedUiElement(s);
}
if(typeof s === "number"){
return new FixedUiElement(""+s)
if (typeof s === "number") {
return new FixedUiElement("" + s)
}
return s;
}
static T(t: string | any, context = undefined): Translation {
if(t === undefined || t === null){
if (t === undefined || t === null) {
return undefined;
}
if(typeof t === "string"){
return new Translation({"*":t}, context);
if (typeof t === "string") {
return new Translation({"*": t}, context);
}
if(t.render !== undefined){
if (t.render !== undefined) {
const msg = "Creating a translation, but this object contains a 'render'-field. Use the translation directly"
console.error(msg, t);
throw msg
}
if(t instanceof Translation){
if (t instanceof Translation) {
return t;
}
return new Translation(t, context);
}
private static wtcache = {}
public static WT(s: string | Translation): Translation {
if(s === undefined || s === null){
if (s === undefined || s === null) {
return undefined;
}
if (typeof (s) === "string") {
if(Translations.wtcache[s]){
if (Translations.wtcache[s]) {
return Translations.wtcache[s];
}
const tr = new Translation({en: s});
Translations.wtcache[s]= tr;
Translations.wtcache[s] = tr;
return tr;
}
if (s instanceof Translation) {
return s;
}
console.error("Trying to Translation.WT, but got ",s)
console.error("Trying to Translation.WT, but got ", s)
throw "??? Not a valid translation"
}