Closed Xi-Plus closed 3 years ago
Can't do this in loadTwinkleCoreMessages
because we don't know in advance whether messages are present or not, and trying each fallback option one by one will take up too much time blocking Twinkle from starting up.
Instead, what we can do is to resolve all fallbacks at a build stage itself. We already have the build-i18n script that sanitises messages for XSS issues and commits the output to i18n branch. We can extend this script to also resolve all fallback messages for all languages. A list of fallback langs is available here which I generated by processing the MW source code.
If some messages is missing in zh-hant, we can fill those messages from zh-hans when we build the i18n files. But zh-tw messages is not exists in twinkle-core. Shoule we generate zh-tw.json by coping zh-hant.json or directly set fallback language in messenger.ts?
Shoule we generate zh-tw.json by coping zh-hant.json
Yes we can do that. Don't think there's any downside to having a lot of message files on the i18n branch.
When I set my language to zh-tw, Twinkle failed to load messages and fallbacks to en. It's better to load zh-hant messages.
Fallback sequence: zh-tw, zh-hant, zh-hans, en.
Some info: https://www.mediawiki.org/wiki/Manual:Language#Fallback_languages