mapbox / locale-utils

0 stars 2 forks source link

Fallback from Mandarin to Chinese #7

Open 1ec5 opened 5 years ago

1ec5 commented 5 years ago

This package should include logic that falls back from any Chinese language code, such as Mandarin (cmn) or Cantonese (yue), to the Chinese macrolanguage code (zh). In addition, a fallback from the Chinese macrolanguage to any available Chinese language code (cmn, yue, wuu, etc.) would also be desirable before the last-resort fallback to null. This would work pretty similarly to the Norwegian fallbacks (#6).

/cc @danpaz @ghoshkaj @chriswu42 @m-stephen @lloydsheng

m-stephen commented 5 years ago

A question to discuss: Is it necessary for input the Chinese macrolanguage: zh-Hans, return a JSON like:

{
     locale: 'zh',
     language: 'cmn',
     script: Hans,
     region: 'CN'
 }

We should make the language code standard more clearly.

1ec5 commented 5 years ago

zh and cmn aren’t necessarily the same thing. So I think we do need to add fallback logic for bestMatchingLocale(), but parseLocaleIntoCodes() should continue to return the same values it did before.