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.
Short Answer
.stringsdictfiles have no way to support explicit plural rules (other than a custom Apple implementation ofzerowhich is detailed below)Detailed Answer
Normal CLDR implementation:
zero, it will use the CLDR values (most languages have0as value forzero). This also includes languages like Latvian who have20,30, etc. values mapped tozeroand also contradicts Apple's own documentation (this behavior was verified):Source: Foundation Release Notes for OS X v10.9
Custom (Apple) CLDR implementation:
zerocategory from the CLDR even if the rule is not defined for this language (reference here)You can write:
=0and notzerofor negative forms.zerocategory? You simply can't - basically Apple broke linguistic rules by overwriting the CLDR.Complimentary details:
zerodoes not equal0:Conclusion
Tip #1: If you need to use Latvian, you should probably avoid using
zerofor negative forms, and use code instead, with strings outside of thestringsdictfileTip #2: Make sure that your translation process supports this behavior correctly!