aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-12-04 17:57:30 +0000
committerGitHub <noreply@github.com>2022-12-04 17:57:30 +0000
commita08584ee367d42de56c5ba6a0fd36ac1067578dd (patch)
tree12664d6c4f088f64a19c066b0bf3cbb537966fb8
parentea86c2b56afeca6450a3e1081c0fd417a09e5434 (diff)
downloadgitea-a08584ee367d42de56c5ba6a0fd36ac1067578dd.tar.gz
gitea-a08584ee367d42de56c5ba6a0fd36ac1067578dd.zip
Ensure that Chinese punctuation is not ambiguous when locale is Chinese (#22019)
Although there are per-locale fallbacks for ambiguity the locale names for Chinese do not quite match our locales. This PR simply maps zh-CN on to zh-hans and other zh variants on to zh-hant. Ref #20999 Signed-off-by: Andrew Thornton <art27@cantab.net>
-rw-r--r--modules/charset/ambiguous.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/charset/ambiguous.go b/modules/charset/ambiguous.go
index c5b0c2c54d..96e0561e15 100644
--- a/modules/charset/ambiguous.go
+++ b/modules/charset/ambiguous.go
@@ -28,6 +28,12 @@ func AmbiguousTablesForLocale(locale translation.Locale) []*AmbiguousTable {
key = key[:idx]
}
}
+ if table == nil && (locale.Language() == "zh-CN" || locale.Language() == "zh_CN") {
+ table = AmbiguousCharacters["zh-hans"]
+ }
+ if table == nil && strings.HasPrefix(locale.Language(), "zh") {
+ table = AmbiguousCharacters["zh-hant"]
+ }
if table == nil {
table = AmbiguousCharacters["_default"]
}