0

I'm considering to use react-intl to localize our react app and I'm pondering the the following messages

  • You can put 3 more items in your basket
  • You can put 2 more items in your basket
  • You can put 1 more item in your basket
  • Your basket is full

It's the last class - the zero item case - that I can't see how to do from the examples I'm looking at. Th other cases would be handled like this, I presume:

defaultMessage={`You can put {basketSpaces, number} 
                 more 
                 {
                   basketSpaces, plural,
                   one {item}
                   other {items}
                 }
                 in your basket
                }`}

Is there a way to completely redefine the message that is emitted for a particular number type case?

Caius Jard
  • 72,509
  • 5
  • 49
  • 80

1 Answers1

1

You can do

{basketSpaces, plural, 
  =0{Your basket is full} 
  one{You can put 1 more item in your basket} 
  other{You can put # more items in your basket}
}
Long Ho
  • 599
  • 4
  • 15