summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Frei <freisim93@gmail.com>2021-07-23 14:24:08 +0200
committerGitHub <noreply@github.com>2021-07-23 14:24:08 +0200
commit7ec76095e6abd6c84b60c8cfe1f814188f1f9777 (patch)
treebea26982ea87a741a293c9c893dcd3ab0752b8e1
parentcb26552440ebf60c366d2f9299e7d46e4850ddac (diff)
gui, script: Parse JS files for translation values (fixes #7845) (#7846)
-rw-r--r--gui/default/assets/lang/lang-en.json6
-rw-r--r--script/translate.go24
2 files changed, 24 insertions, 6 deletions
diff --git a/gui/default/assets/lang/lang-en.json b/gui/default/assets/lang/lang-en.json
index d7c2585a07..314cf7939e 100644
--- a/gui/default/assets/lang/lang-en.json
+++ b/gui/default/assets/lang/lang-en.json
@@ -94,6 +94,7 @@
"Discovered": "Discovered",
"Discovery": "Discovery",
"Discovery Failures": "Discovery Failures",
+ "Discovery Status": "Discovery Status",
"Dismiss": "Dismiss",
"Do not add it to the ignore list, so this notification may recur.": "Do not add it to the ignore list, so this notification may recur.",
"Do not restore": "Do not restore",
@@ -121,6 +122,7 @@
"Error": "Error",
"External File Versioning": "External File Versioning",
"Failed Items": "Failed Items",
+ "Failed to load ignore patterns.": "Failed to load ignore patterns.",
"Failed to setup, retrying": "Failed to setup, retrying",
"Failure to connect to IPv6 servers is expected if there is no IPv6 connectivity.": "Failure to connect to IPv6 servers is expected if there is no IPv6 connectivity.",
"File Pull Order": "File Pull Order",
@@ -178,6 +180,8 @@
"Latest Change": "Latest Change",
"Learn more": "Learn more",
"Limit": "Limit",
+ "Listener Failures": "Listener Failures",
+ "Listener Status": "Listener Status",
"Listeners": "Listeners",
"Loading data...": "Loading data...",
"Loading...": "Loading...",
@@ -216,6 +220,7 @@
"Out of Sync": "Out of Sync",
"Out of Sync Items": "Out of Sync Items",
"Outgoing Rate Limit (KiB/s)": "Outgoing Rate Limit (KiB/s)",
+ "Override": "Override",
"Override Changes": "Override Changes",
"Path": "Path",
"Path to the folder on the local computer. Will be created if it does not exist. The tilde character (~) can be used as a shortcut for": "Path to the folder on the local computer. Will be created if it does not exist. The tilde character (~) can be used as a shortcut for",
@@ -265,6 +270,7 @@
"Resume": "Resume",
"Resume All": "Resume All",
"Reused": "Reused",
+ "Revert": "Revert",
"Revert Local Changes": "Revert Local Changes",
"Save": "Save",
"Scan Time Remaining": "Scan Time Remaining",
diff --git a/script/translate.go b/script/translate.go
index 928068b5dd..12a7def822 100644
--- a/script/translate.go
+++ b/script/translate.go
@@ -9,6 +9,7 @@
package main
import (
+ "bufio"
"encoding/json"
"log"
"os"
@@ -22,6 +23,7 @@ import (
var trans = make(map[string]string)
var attrRe = regexp.MustCompile(`\{\{\s*'([^']+)'\s+\|\s+translate\s*\}\}`)
var attrReCond = regexp.MustCompile(`\{\{.+\s+\?\s+'([^']+)'\s+:\s+'([^']+)'\s+\|\s+translate\s*\}\}`)
+var jsRe = regexp.MustCompile(`\$translate.instant\("([^"]+)"\)`)
// exceptions to the untranslated text warning
var noStringRe = regexp.MustCompile(
@@ -108,17 +110,27 @@ func walkerFor(basePath string) filepath.WalkFunc {
return err
}
- if filepath.Ext(name) == ".html" && info.Mode().IsRegular() {
- fd, err := os.Open(name)
- if err != nil {
- log.Fatal(err)
- }
+ if !info.Mode().IsRegular() {
+ return nil
+ }
+ fd, err := os.Open(name)
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer fd.Close()
+ switch filepath.Ext(name) {
+ case ".html":
doc, err := html.Parse(fd)
if err != nil {
log.Fatal(err)
}
- fd.Close()
generalNode(doc, filepath.Base(name))
+ case ".js":
+ for s := bufio.NewScanner(fd); s.Scan(); {
+ for _, matches := range jsRe.FindAllStringSubmatch(s.Text(), -1) {
+ translation(matches[1])
+ }
+ }
}
return nil