Skip to content

Commit

Permalink
Ensure that Chinese punctuation is not ambiguous when locale is Chine…
Browse files Browse the repository at this point in the history
…se (go-gitea#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 go-gitea#20999

Signed-off-by: Andrew Thornton <art27@cantab.net>
  • Loading branch information
zeripath committed Dec 4, 2022
1 parent ea86c2b commit a08584e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/charset/ambiguous.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
Expand Down

0 comments on commit a08584e

Please sign in to comment.