Move 'translators'-logic into UserSettings

This commit is contained in:
Pieter Vander Vennet 2023-02-09 02:45:19 +01:00
parent fad62a2877
commit 79a88401dc
22 changed files with 321 additions and 277 deletions

View file

@ -237,13 +237,11 @@ export default class LayoutConfig {
}
public missingTranslations(): {
completeness: Map<string, number>
untranslated: Map<string, string[]>
total: number
} {
const layout = this
let total = 0
const completeness = new Map<string, number>()
const untranslated = new Map<string, string[]>()
Utils.WalkObject(
@ -264,13 +262,21 @@ export default class LayoutConfig {
if (trans["*"] !== undefined) {
return
}
if (translation.context.indexOf(":") < 0) {
return
}
if (trans[ln] === undefined) {
if (!untranslated.has(ln)) {
untranslated.set(ln, [])
}
untranslated.get(ln).push(translation.context)
} else {
completeness.set(ln, 1 + (completeness.get(ln) ?? 0))
untranslated
.get(ln)
.push(
translation.context.replace(
/^note_import_[a-zA-Z0-9_]*/,
"note_import"
)
)
}
})
},
@ -282,7 +288,7 @@ export default class LayoutConfig {
}
)
return { completeness, untranslated, total }
return { untranslated, total }
}
public getMatchingLayer(tags: any): LayerConfig | undefined {
if (tags === undefined) {