formatjs / intl-messageformat

[MIGRATED] Format a string with placeholders, including plural and select support to create localized messages.
http://formatjs.io/
Other
530 stars 77 forks source link

Empty string in plural syntax throws error #170

Closed infojunkie closed 7 years ago

infojunkie commented 7 years ago

Trying to specify a message like the following:

  favoritesCount: {
    id: 'media.favoritesCount',
    defaultMessage: '{favoritesCount, plural, =0 {} one {1 favorite} other {# favorites}}',
  },

but I get the following error when favoritesCount is zero:

[React Intl] Cannot format message: "media.favoritesCount", using message source as fallback.

Changing the empty string {} to something like {No favorites} does not throw the error.

How can I specify an empty string?

jasonmit commented 7 years ago

Test I created in an attempt to reproduce but returns the expected empty string.

https://github.com/yahoo/intl-messageformat/commit/04b9dd21b982c608883d7508503cee2632569178

Perhaps this is an issue with react-intl?