mozilla / activate.mozilla.community

Activate campaign site
Mozilla Public License 2.0
29 stars 60 forks source link

avoid using zh-CN as localization fallback for zh-TW #362

Closed petercpg closed 4 years ago

petercpg commented 5 years ago

I think this might be a issue at the l10n library side, but please directly use English as fallback, when string is missed in zh-TW localization, instead of using zh-CN strings.

That is, expected: zh-TW -> en ; actual: zh-TW -> zh-CN -> en .

MichaelKohler commented 5 years ago

I think we do not have any preference there, however it might be that fluent (the framework we're using) does. I could imagine it falling back through the "cn" identifier and then back to EN. I'm on my phone right now so hard to say.

@Pike @stasm thoughts here?

stasm commented 5 years ago

It looks like activate.mozilla.community uses fluent-langneg, which is our recommended language negotiation library built upon the RFC4647. Falling back on other regional variants of zh is a feature of the algorithm. I understand that there are reasons to bypass it in some cases. Unfortunately, we don't support any way to do it right now.

@zbraniecki : Would it make sense to consider adding an option to negotiateLanguages to allow overriding certain fallback chains?

zbraniecki commented 5 years ago

The idea of language negotiation is to facilitate custom fallback chains and fallback on "default" ones in the absence.

In that case, I'd expect the user to specify their preferred language fallback chain to be ["zh-TW", "en-US"]. Otherwise we have to try to rely on the data we have. If the user asks for zh-TW we can deduct using likelySubtags[0] that their locale is zh-Hant-TW, but then when we match it against zh-CN which does not have a likely subtag extension, it'll still be treated as zh-*-CN rather than zh-Hans-CN. I looked at matching languages data in CLDR and I'm not sure if there's a good way to algorithmically recognize that TW should not use CN as a fallback.

I'll ask Unicode about it.

[0] https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/likelySubtags.json

MichaelKohler commented 5 years ago

@zbraniecki is there any update here? :)