authgear-server icon indicating copy to clipboard operation
authgear-server copied to clipboard

Script in UI locale resolves incorrectly

Open fungc-io opened this issue 1 year ago • 6 comments

  • 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

fungc-io avatar Nov 03 '23 12:11 fungc-io

https://go.dev/play/p/q_haFShsPgG

louischan-oursky avatar Mar 26 '24 08:03 louischan-oursky

Interestingly, I got a different result: https://goplay.tools/snippet/VQH4Qs4MXY4

What could be the difference?

tung2744 avatar Mar 26 '24 08:03 tung2744

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.

tung2744 avatar Mar 26 '24 08:03 tung2744

The doc of Match says when there is no match, it returns the first item in the supported tags.

louischan-oursky avatar Mar 26 '24 08:03 louischan-oursky

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)

tung2744 avatar Mar 26 '24 09:03 tung2744

Maybe related? https://github.com/golang/text/blob/master/language/match.go#L106

louischan-oursky avatar Mar 26 '24 09:03 louischan-oursky