0

In my ReactJS project I'm trying to provide a user interface in Swiss German (gsw-CH), including proper formatting of numbers, currencies, dates, and times. It seems like Swiss German is not supported out of the box, because I get this error in console:

Error: [@formatjs/intl Error MISSING_DATA] Missing locale data for locale: "gsw-CH" in Intl.NumberFormat. Using default locale: "en" as fallback. See https://formatjs.io/docs/react-intl#runtime-requirements for more details

Is there a way (maybe some polyfill) to support Swiss German formatting? I also don't understand why date formatting uses German month and weekday names instead of English (the default locale). For instance it uses "Dezember" (de) instead of "December" (en) or "Dezämber" (gsw-CH). Looking into @formatjs/intl-datetimeformat/locale-data I see files for gsw, gsw-LI, and gsw-FR. So I tried using "gsw-LI" instead of "gsw-CH", but I get the same error and the same result.

The IntlProvider class seems to support this scenario, as it has options to define formats for numbers, dates, etc. But so far I have not found out how these options need to be set. I could not find a sample.

Timo Kunze
  • 135
  • 1
  • 6
  • Have you asked the folks that take care of the localization code to add support? If not, can you do that, given that it's an open source project? (because getting them to do it helps the entire world, rather than the kind of thin you're asking for, which only helps you) – Mike 'Pomax' Kamermans Nov 10 '20 at 19:41
  • 1
    Good point. https://github.com/formatjs/formatjs/issues/2304 However, I'm still interested in a solution that I can use with current version of react-intl. – Timo Kunze Nov 10 '20 at 22:53
  • nice - hopefully someone can help sort out a not-official-solution in the mean time. Might also be worth noting in your issue (and post? maybe?) that as per [RFC 5646](https://tools.ietf.org/html/rfc5646), locale codes like `gsw-CH` are entirely valid (a lot of folks mistakenly believe that they have to be two lowercase, two uppercase, which even in [BCP 47](https://tools.ietf.org/html/bcp47) was very much not true) – Mike 'Pomax' Kamermans Nov 10 '20 at 23:51
  • I use `de` for this case. It work great – Nguyễn Anh Tuấn Feb 07 '22 at 08:20

0 Answers0