L20n by example

6. Selectors

One of the most common cases when a localizer needs to use a placeable is when there are multiple variants of the string that depend on some external argument.

L20n provides a select expression that chooses one of the provided variants based on the given selector.

By default, when a number is used as a selector, L20n implicitly uses PLURAL formatter that selects the proper plural case for a given language. In English it will be either one or other.

{ "unreadEmails": 5 }
emails = { $unreadEmails -> [one] You have one unread email. [other] You have { $unreadEmails } unread emails. }