-
Notifications
You must be signed in to change notification settings - Fork 20
Plurals
In CSV/XLS(X) text in square brackets is a quantity. E.g. the following CSV fragment:
cow[one] ,cow
cow[other],cows
will produce the following XML:
<plurals name="cow">
<item quantity="one">cow</item>
<item quantity="other">cows</item>
</plurals>
Then if you use:
String cowsFound = getResources().getQuantityString(R.plurals.cow, count);
cowsFound
will contain "cow"
if count is 1 or "cows"
otherwise if locale is English (or other which distinguishes those quantities).
Only quantities supported by Android can be used and only those which match grammar rules from locale's language will be used at runtime (eg. zero
won't work in English even if count == 0
). If you place such redundant quantities in languages which don't use them lint will show a warning. On the other hand if you miss some relevant quantity for given language lint will show an error. If that error is ignored (e.g. only zero
is used in default locale and locale at runtime is English)Resources$NotFoundException
will be thrown at runtime.