From 6e4ba048430b364968f8861731575483cbeb011e Mon Sep 17 00:00:00 2001 From: zeripath Date: Mon, 5 Dec 2022 09:20:38 +0000 Subject: [PATCH] Ensure that Chinese punctuation is not ambiguous when locale is Chinese (#22019) (#22030) Backport #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 Co-authored-by: Lauris BH --- modules/charset/ambiguous.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/charset/ambiguous.go b/modules/charset/ambiguous.go index 9dab3b0951b..ef5e7650a6a 100644 --- a/modules/charset/ambiguous.go +++ b/modules/charset/ambiguous.go @@ -29,6 +29,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"] }