summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndré Colomb <src@andre.colomb.de>2022-09-16 22:52:33 +0200
committerGitHub <noreply@github.com>2022-09-16 22:52:33 +0200
commit698346edc342c214d844a874c83a8fd6c9c6e18b (patch)
tree3439732cc4e2a5a4147254c6b72a23608848e06f
parent39d3424e34ae9c4636c4da53a075f744c6776567 (diff)
script: Support single quotes in $translate.instant() parsing (#8542)
Duplicate the regular expression for single and double quotes. Support additional arguments (string substitution) in both variants. Simplify the translation string group matching by using a lazy quantifier instead of excluding the quote itself.
-rw-r--r--gui/default/assets/lang/lang-en.json10
-rw-r--r--script/translate.go14
2 files changed, 21 insertions, 3 deletions
diff --git a/gui/default/assets/lang/lang-en.json b/gui/default/assets/lang/lang-en.json
index 2f2dfcb9dc..576d6ac1f9 100644
--- a/gui/default/assets/lang/lang-en.json
+++ b/gui/default/assets/lang/lang-en.json
@@ -124,12 +124,17 @@
"Enable NAT traversal": "Enable NAT traversal",
"Enable Relaying": "Enable Relaying",
"Enabled": "Enabled",
+ "Enables sending extended attributes to other devices, and applying incoming extended attributes. May require running with elevated privileges.": "Enables sending extended attributes to other devices, and applying incoming extended attributes. May require running with elevated privileges.",
+ "Enables sending extended attributes to other devices, but not applying incoming extended attributes. This can have a significant performance impact. Always enabled when \"Sync Extended Attributes\" is enabled.": "Enables sending extended attributes to other devices, but not applying incoming extended attributes. This can have a significant performance impact. Always enabled when \"Sync Extended Attributes\" is enabled.",
+ "Enables sending ownership information to other devices, and applying incoming ownership information. Typically requires running with elevated privileges.": "Enables sending ownership information to other devices, and applying incoming ownership information. Typically requires running with elevated privileges.",
+ "Enables sending ownership to other devices, but not applying incoming ownership information. This can have a significant performance impact. Always enabled when \"Sync Ownership\" is enabled.": "Enables sending ownership to other devices, but not applying incoming ownership information. This can have a significant performance impact. Always enabled when \"Sync Ownership\" is enabled.",
"Enter a non-negative number (e.g., \"2.35\") and select a unit. Percentages are as part of the total disk size.": "Enter a non-negative number (e.g., \"2.35\") and select a unit. Percentages are as part of the total disk size.",
"Enter a non-privileged port number (1024 - 65535).": "Enter a non-privileged port number (1024 - 65535).",
"Enter comma separated (\"tcp://ip:port\", \"tcp://host:port\") addresses or \"dynamic\" to perform automatic discovery of the address.": "Enter comma separated (\"tcp://ip:port\", \"tcp://host:port\") addresses or \"dynamic\" to perform automatic discovery of the address.",
"Enter ignore patterns, one per line.": "Enter ignore patterns, one per line.",
"Enter up to three octal digits.": "Enter up to three octal digits.",
"Error": "Error",
+ "Extended Attributes": "Extended Attributes",
"External": "External",
"External File Versioning": "External File Versioning",
"Failed Items": "Failed Items",
@@ -244,6 +249,7 @@
"Outgoing Rate Limit (KiB/s)": "Outgoing Rate Limit (KiB/s)",
"Override": "Override",
"Override Changes": "Override Changes",
+ "Ownership": "Ownership",
"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",
"Path where versions should be stored (leave empty for the default .stversions directory in the shared folder).": "Path where versions should be stored (leave empty for the default .stversions directory in the shared folder).",
@@ -304,7 +310,9 @@
"Select latest version": "Select latest version",
"Select oldest version": "Select oldest version",
"Send \u0026 Receive": "Send \u0026 Receive",
+ "Send Extended Attributes": "Send Extended Attributes",
"Send Only": "Send Only",
+ "Send Ownership": "Send Ownership",
"Set Ignores on Added Folder": "Set Ignores on Added Folder",
"Settings": "Settings",
"Share": "Share",
@@ -342,6 +350,8 @@
"Stores and syncs only encrypted data. Folders on all connected devices need to be set up with the same password or be of type \"{%receiveEncrypted%}\" too.": "Stores and syncs only encrypted data. Folders on all connected devices need to be set up with the same password or be of type \"{{receiveEncrypted}}\" too.",
"Support": "Support",
"Support Bundle": "Support Bundle",
+ "Sync Extended Attributes": "Sync Extended Attributes",
+ "Sync Ownership": "Sync Ownership",
"Sync Protocol Listen Addresses": "Sync Protocol Listen Addresses",
"Sync Status": "Sync Status",
"Syncing": "Syncing",
diff --git a/script/translate.go b/script/translate.go
index 5f9f0ada38..15a82b5246 100644
--- a/script/translate.go
+++ b/script/translate.go
@@ -24,7 +24,13 @@ 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\("([^"]+)"\)`)
+
+// Find both $translate.instant("…") and $translate.instant("…",…) in JS.
+// Consider single quote variants too.
+var jsRe = []*regexp.Regexp{
+ regexp.MustCompile(`\$translate\.instant\(\s*"(.+?)"(,.*|\s*)\)`),
+ regexp.MustCompile(`\$translate\.instant\(\s*'(.+?)'(,.*|\s*)\)`),
+}
// exceptions to the untranslated text warning
var noStringRe = regexp.MustCompile(
@@ -128,8 +134,10 @@ func walkerFor(basePath string) filepath.WalkFunc {
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])
+ for _, re := range jsRe {
+ for _, matches := range re.FindAllStringSubmatch(s.Text(), -1) {
+ translation(matches[1])
+ }
}
}
}