Handle metadata in translations

This commit is contained in:
Pieter Vander Vennet 2022-10-29 03:02:42 +02:00
parent 30a835a232
commit efb54782ca
6 changed files with 47 additions and 24 deletions

View file

@ -42,6 +42,9 @@ export default class LanguagePicker extends Toggle {
return new Translation({ "*": nativeText })
}
for (const key in trans) {
if(key.startsWith("_")){
continue
}
const translationInKey = allTranslations[lang][key]
if (nativeText.toLowerCase() === translationInKey.toLowerCase()) {
translation[key] = nativeText

View file

@ -16,10 +16,6 @@ export class Translation extends BaseUIElement {
throw `Translation without content (${context})`
}
this.context = translations["_context"] ?? context
if (translations["_context"] !== undefined) {
translations = { ...translations }
delete translations["_context"]
}
if (typeof translations === "string") {
translations = { "*": translations }
}
@ -28,7 +24,7 @@ export class Translation extends BaseUIElement {
if (!translations.hasOwnProperty(translationsKey)) {
continue
}
if (translationsKey === "_context") {
if (translationsKey === "_context" || translationsKey === "_meta") {
continue
}
count++