Skip to content

Features: Pluralization Empty states

Rudy Huyn edited this page Aug 1, 2019 · 1 revision

In addition to plural forms, one common task normally delegated to the ViewModel is to display a special message when a quantity is zero, some examples: 'no search results', 'history empty', 'no new messages' etc...

ReswPlus provides a way to automate this task and automatically provide the empty state string when necessary, simply add a _None state to your pluralized strings:

Example:

Resources:

Key Value Comment
ReceivedMessages_None No new messages
ReceivedMessages_One You got {0} message #Format[Plural numberMessages]
ReceivedMessages_Other You got {0} messages

The following code:

<TextBlock Text="{x:Bind strings:Resources.ReceivedMessages_Format(ViewModel.NumberMessage), Mode=OneWay}" />

will automatically display No new messages, You got 1 message, You got 1 messages based on the value of ViewModel.NumberMessage.