aboutsummaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorAndré Colomb <src@andre.colomb.de>2023-11-14 07:22:52 +0100
committerGitHub <noreply@github.com>2023-11-14 07:22:52 +0100
commit4f70f5c280c72929a3dd761ec8cb90ef0aa7e6f0 (patch)
tree30a3bebd2cf8fca573f7a1ab3af8fd289ad8c76b /script
parenta1ad020b6387f851764cb9a6e97253df85cce12c (diff)
downloadsyncthing-4f70f5c280c72929a3dd761ec8cb90ef0aa7e6f0.tar.gz
syncthing-4f70f5c280c72929a3dd761ec8cb90ef0aa7e6f0.zip
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.
Diffstat (limited to 'script')
-rw-r--r--script/translate.go21
1 files changed, 18 insertions, 3 deletions
diff --git a/script/translate.go b/script/translate.go
index 1d182ebe2..21b2a2803 100644
--- a/script/translate.go
+++ b/script/translate.go
@@ -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)
}
}
}