bholloway / react-i18n-interpolation

String interpolation of translated text and react components
MIT License
1 stars 2 forks source link

Better validation for ngettext(number)`template` #8

Open nkbt opened 7 years ago

nkbt commented 7 years ago

screen shot 2017-04-04 at 5 16 32 pm

happened because of

const translationsTemplates = ngettext => ({
  hours: num => ngettext`one hour|${{num}} hours`,
  days: num => ngettext`one day|${{num}} days`,
  weeks: num => ngettext`one week|${{num}} weeks`,
  months: num => ngettext`one month|${{num}} months`,
  years: num => ngettext`one year|${{num}} years`
});

So it is fixed with

hours: num => ngettext(num)`one hour|${{num}} hours`
bholloway commented 6 years ago

Per #15 this error case will be caught because it does not match ngettext(integer) invocation.