mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-22 09:54:24 +01:00
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`.
This commit is contained in:
parent
7422503341
commit
71afbcafa9
|
@ -77,10 +77,11 @@ func main() {
|
||||||
if secNew.HasKey(keyEnUs.Name()) {
|
if secNew.HasKey(keyEnUs.Name()) {
|
||||||
oldStr := secOld.Key(keyEnUs.Name()).String()
|
oldStr := secOld.Key(keyEnUs.Name()).String()
|
||||||
newStr := secNew.Key(keyEnUs.Name()).String()
|
newStr := secNew.Key(keyEnUs.Name()).String()
|
||||||
// A bug: many of new translations with ";" are broken in Crowdin (due to last messy restoring)
|
if oldStr != "" && strings.Count(oldStr, "%") != strings.Count(newStr, "%") {
|
||||||
// As the broken strings are gradually fixed, this workaround check could be removed (in a few months?)
|
fmt.Printf("WARNING: locale %s [%s]%s has different number of arguments, skipping\n", path, secEnUS.Name(), keyEnUs.Name())
|
||||||
if strings.Contains(oldStr, ";") && !strings.Contains(newStr, ";") {
|
fmt.Printf("\told: %s\n", oldStr)
|
||||||
println("skip potential broken string", path, secEnUS.Name(), keyEnUs.Name())
|
fmt.Printf("\tnew: %s\n", newStr)
|
||||||
|
fmt.Println("---- ")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
secOld.Key(keyEnUs.Name()).SetValue(newStr)
|
secOld.Key(keyEnUs.Name()).SetValue(newStr)
|
||||||
|
|
Loading…
Reference in a new issue