authgear-server
authgear-server copied to clipboard
Script in UI locale resolves incorrectly
- When ui_locale is zh-Hant, it is treated as zh-Hant-HK in the translation and zh-Hans-CN in the templates
- When ui_locale is zh-Hans, it is also treated as zh-Hant-HK in the translation and zh-Hans-CN in the templates
https://go.dev/play/p/q_haFShsPgG
Interestingly, I got a different result: https://goplay.tools/snippet/VQH4Qs4MXY4
What could be the difference?
Oh, it is the order of supported tag. If we remove zh-TW
from supported tags (Which has Exact
as confidence), and put zh-CN
before zh-HK
, zh-CN
will be selected instead of zh-HK
.
The doc of Match says when there is no match, it returns the first item in the supported tags.
If you put en-US
as the first item, it won't be matched. The problem is the library didn't consider the confidence level if it is not Exact
. (zh-CN
is Low
when matched with zh-Hant
, and zh-HK
is High
, but still zh-CN
were selected)
Maybe related? https://github.com/golang/text/blob/master/language/match.go#L106