11# Selectors
22
33```
4- emails = { $unreadEmails ->
4+ emails =
5+ { $unreadEmails ->
56 [one] You have one unread email.
67 *[other] You have { $unreadEmails } unread emails.
78 }
89```
910
10- ``` json
11- {
12- "unreadEmails" : 5
13- }
14- ```
15-
1611One of the most common cases when a localizer needs to use a placeable is when
1712there are multiple variants of the string that depend on some external
18- argument. FTL provides the select expression syntax, which chooses one of the
19- provided variants based on the given selector .
13+ argument. In the example above, the ` emails ` message depends on the value of
14+ the ` $unreadEmails ` external argument .
2015
21- The ` * ` indicator identifies the default selection. A default selection is required.
16+ FTL has the select expression syntax which allows to define multiple variants
17+ of the translation and choose between them based on the value of the
18+ selector. The ` * ` indicator identifies the default variant. A default
19+ variant is required.
2220
23- The selector may be a string, in which case it will be compared directly to the
24- keys of variants defined in the select expression. For number selectors, the
25- variant keys either match the number exactly or they match the [ CLDR plural
26- category] ( http://www.unicode.org/cldr/charts/30/supplemental/language_plural_rules.html )
27- for the number. The possible categories are: ` zero ` , ` one ` , ` two ` , ` few ` ,
28- ` many ` , and ` other ` . For instance, English has two plural categories: ` one ` and
29- ` other ` .
21+ The selector may be a string, in which case it will be compared directly to
22+ the keys of variants defined in the select expression. For selectors which
23+ are numbers, the variant keys either match the number exactly or they match
24+ the [ CLDR plural category] [ ] for the number. The possible categories are:
25+ ` zero ` , ` one ` , ` two ` , ` few ` , ` many ` , and ` other ` . For instance, English has
26+ two plural categories: ` one ` and ` other ` .
3027
3128If the translation requires a number to be formatted in a particular
3229non-default manner, the selector should use the same formatting options. The
@@ -35,8 +32,11 @@ which, for some languages, might be different than the category of the
3532unformatted number:
3633
3734```
38- your-score = { NUMBER($score, minimumFractionDigits: 1) ->
35+ your-score =
36+ { NUMBER($score, minimumFractionDigits: 1) ->
3937 [0.0] You scored zero points. What happened?
4038 *[other] You scored { NUMBER($score, minimumFractionDigits: 1) } points.
4139 }
4240```
41+
42+ [ CLDR plural category ] : http://www.unicode.org/cldr/charts/30/supplemental/language_plural_rules.html
0 commit comments