diff options
author | Simon Frei <freisim93@gmail.com> | 2020-08-30 08:01:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-30 08:01:46 +0200 |
commit | 44bf8cfd273e3667c5910f42690d19b9e031baa2 (patch) | |
tree | a8a20c0c971d9bea14357c2e3f815c7dd2453450 /script | |
parent | 563cea0dbe0f5e917301b5806d2f8cdb4c48e413 (diff) | |
download | syncthing-44bf8cfd273e3667c5910f42690d19b9e031baa2.tar.gz syncthing-44bf8cfd273e3667c5910f42690d19b9e031baa2.zip |
build: Improve translation script (fixes #6943) (#6944)
Diffstat (limited to 'script')
-rw-r--r-- | script/translate.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/script/translate.go b/script/translate.go index aee7c9eb3..7d237b1eb 100644 --- a/script/translate.go +++ b/script/translate.go @@ -21,13 +21,14 @@ import ( var trans = make(map[string]string) var attrRe = regexp.MustCompile(`\{\{'([^']+)'\s+\|\s+translate\}\}`) +var attrReCond = regexp.MustCompile(`\{\{.+\s+\?\s+'([^']+)'\s+:\s+'([^']+)'\s+\|\s+translate\}\}`) // exceptions to the untranslated text warning var noStringRe = regexp.MustCompile( `^((\W*\{\{.*?\}\} ?.?\/?.?(bps)?\W*)+(\.stignore)?|[^a-zA-Z]+.?[^a-zA-Z]*|[kMGT]?B|Twitter|JS\W?|DEV|https?://\S+)$`) // exceptions to the untranslated text warning specific to aboutModalView.html -var aboutRe = regexp.MustCompile(`^([^/]+/[^/]+|(The Go Pro|Font Awesome ).+)$`) +var aboutRe = regexp.MustCompile(`^([^/]+/[^/]+|(The Go Pro|Font Awesome ).+|Build \{\{.+\}\}|Copyright .+ the Syncthing Authors\.)$`) func generalNode(n *html.Node, filename string) { translate := false @@ -46,9 +47,13 @@ func generalNode(n *html.Node, filename string) { // copyright notices of other projects return } else { - if matches := attrRe.FindStringSubmatch(a.Val); len(matches) == 2 { + for _, matches := range attrRe.FindAllStringSubmatch(a.Val, -1) { translation(matches[1]) } + for _, matches := range attrReCond.FindAllStringSubmatch(a.Val, -1) { + translation(matches[1]) + translation(matches[2]) + } if a.Key == "data-content" && !noStringRe.MatchString(a.Val) { log.Println("Untranslated data-content string (" + filename + "):") |