Motivation
Chinese language has historically multiple language codes (RFC 5646 with ISO-639
zh). Practically, the most frequently used ones are zh-CN (for Simplified Hanzi Script of Chinese Mandarin language mainly used in PRC, etc.), zh-TW (for Traditional Hanzi Script of Chinese Mandarin language mainly used in Taiwan, etc.), zh (usually equivalent of zh-CN). There are also less used zh-HanS and zh-HanT that are almost share the same effect as zh-CN and zh-TW respectively with regions not specified.
The new ECMAScript Intl API will give different display names for all those codes, but will carry their semantically regional and political message. I want my application to be neutral so I would like to use zh-HanS and zh-HanT instead of zh-CN and zh-TW.
Problem
Most of modern browsers will always use Accept-Language: zh-CN; zh; for zh-CN/zh-HanS, and Accept-Language: zh-TW; zh; for zh-TW/zh-HanT in HTTP headers. Since zh-HanS/zh-HanT are not used, if I use them in my application as src/i18n/zh-HanS/src/i18n/zh-HanT, detectLocale(initAcceptLanguageHeaderDetector({headers}) of typesafe-i18n will fail to find the correct locale, tries to fallback to zh, but then fail and fallback to baseLocale (often en).
Question
How can I make aliases for them and let the detector fallback to the correct language?
The generated
detectLocalefunction defined as following insrc/i18n/i18n-util.tswill uselocales(a generated variable showing a list of locale files).So we need to
detectLocaleFnabove intead (detectLocale from 'typesafe-i18n/detectors')In your detection code,