Some fixes in the rewrite of the maprendering

This commit is contained in:
Pieter Vander Vennet 2022-03-08 01:05:54 +01:00
parent 9f3a23843c
commit 67c8d08f3e
9 changed files with 117 additions and 19 deletions

View file

@ -11,6 +11,7 @@ export class Translation extends BaseUIElement {
constructor(translations: object, context?: string) {
super()
if (translations === undefined) {
console.error("Translation without content at "+context)
throw `Translation without content (${context})`
}
if (typeof translations === "string") {
@ -29,7 +30,8 @@ export class Translation extends BaseUIElement {
}
this.translations = translations;
if (count === 0) {
throw `No translations given in the object (${context})`
console.error("Constructing a translation, but the object containing translations is empty "+context)
throw `Constructing a translation, but the object containing translations is empty (${context})`
}
}

View file

@ -94,7 +94,15 @@ export default class Translations {
if(typeof transl !== "object"){
return false;
}
if(Object.keys(transl).length == 0){
// No translations found; not a translation
return false
}
// is a weird key found?
return !Object.keys(transl).some(key => !this.knownLanguages.has(key))
if(Object.keys(transl).some(key => !this.knownLanguages.has(key))){
return false
}
return true;
}
}