gui: Use nested namespace for theme name translation keys (#9220)

Following up on #9192, this makes use of the new mechanism for the theme
names.

The dummy string added for testing is removed again here. All
translations are updated to the new nested syntax, except Chinese
(zh-HK) where the string weren't actually translated.
This commit is contained in:
André Colomb
2023-11-14 07:22:52 +01:00
committed by GitHub
parent a1ad020b63
commit 4f70f5c280
34 changed files with 258 additions and 134 deletions

View File

@@ -104,6 +104,21 @@ func inTranslate(n *html.Node, translationId string, filename string) {
}
}
func isTranslated(id string) bool {
namespace := trans
idParts := strings.Split(id, ".")
id = idParts[len(idParts)-1]
for _, subNamespace := range idParts[0 : len(idParts)-1] {
if _, ok := namespace[subNamespace]; !ok {
return false
}
namespace = namespace[subNamespace].(map[string]interface{})
}
_, ok := namespace[id]
return ok
}
func translation(id string, v string) {
namespace := trans
idParts := strings.Split(id, ".")
@@ -169,10 +184,10 @@ func collectThemes(basePath string) {
}
for _, f := range files {
if f.IsDir() {
key := "theme-name-" + f.Name()
if _, ok := trans[key]; !ok {
key := "theme.name." + f.Name()
if !isTranslated(key) {
name := strings.Title(f.Name())
trans[key] = name
translation(key, name)
}
}
}