Skip to content

Commit 71afbca

Browse files
authored
Improve backport-locales.go (#23807)
ps: there are more broken translation strings in 1.20 (main), most of them are still caused by incorrect quoting/unquoting. For example, translators might write text ``` `my text ```, such incorrect encoding might break crowdin & Gitea's locale package. In the future, a Go `update-locales.go` should replace the legacy `update-locales.sh`.
1 parent 7422503 commit 71afbca

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

build/backport-locales.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ func main() {
7777
if secNew.HasKey(keyEnUs.Name()) {
7878
oldStr := secOld.Key(keyEnUs.Name()).String()
7979
newStr := secNew.Key(keyEnUs.Name()).String()
80-
// A bug: many of new translations with ";" are broken in Crowdin (due to last messy restoring)
81-
// As the broken strings are gradually fixed, this workaround check could be removed (in a few months?)
82-
if strings.Contains(oldStr, ";") && !strings.Contains(newStr, ";") {
83-
println("skip potential broken string", path, secEnUS.Name(), keyEnUs.Name())
80+
if oldStr != "" && strings.Count(oldStr, "%") != strings.Count(newStr, "%") {
81+
fmt.Printf("WARNING: locale %s [%s]%s has different number of arguments, skipping\n", path, secEnUS.Name(), keyEnUs.Name())
82+
fmt.Printf("\told: %s\n", oldStr)
83+
fmt.Printf("\tnew: %s\n", newStr)
84+
fmt.Println("---- ")
8485
continue
8586
}
8687
secOld.Key(keyEnUs.Name()).SetValue(newStr)

0 commit comments

Comments
 (0)