Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explicit Plural string using iOS Stringsdict files

I am getting started learning iOS Stringsdict files and found some existing code on a project which used the following syntax:

<key>zero</key>
<string>You no message.</string>

As per the CLDR, zero is an invalid plural in English and we expect to use explicit plural rules (=0 when using ICU MessageFormat)

I tried to find how to use explicit plural rules in iOS Stringsdict files and could not find any way to achieve this. Can someone confirm if this is supported or not?


Example of solutions (I cannot test them but maybe someone can?)

<key>0</key>
<string>You no message.</string>

Or

<key>=0</key>
<string>You no message.</string>

Extra reference on explicit plural rules part of the CLDR implementation of ICU MessageFormat:

https://formatjs.io/guides/message-syntax/#plural-format

=value This is used to match a specific value regardless of the plural categories of the current locale.

like image 206
Nicolas Bouvrette Avatar asked Apr 23 '20 17:04

Nicolas Bouvrette


1 Answers

If you are interested in the zero rule only, it is handled in .stringsdict file for any language.

Source: Foundation Release Notes for OS X v10.9

If "zero" is present, the value is used for mapping the argument value zero regardless of what CLDR rule specifies for the numeric value.

Otherwise, these are the only rules handled (depends on language): zero, one, two, few, many, others

like image 127
paiv Avatar answered Oct 27 '22 09:10

paiv