I want to translate this string using a plurar stringdict in swift for iOS
Using a simple plural without pla
Positional parameters n$ are one-based, so in
let label = String.localizedStringWithFormat(format, kidsIds.count, "Name")
"Name" is the second parameter, and you reference it with %2$@:
<key>NSStringLocalizedFormatKey</key>
<string>%#@format@</string>
<key>format</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>li</string>
<key>one</key>
<string>Sleeps at %2$@</string>
<key>other</key>
<string>Sleep at %2$@</string>
</dict>
In your code, %1$@ refers to the first argument kidsIds.count.
That is not a string which leads to the crash.
Alternatively, put it into the NSStringLocalizedFormatKey:
<key>NSStringLocalizedFormatKey</key>
<string>%#@format@ at %@</string>
<key>format</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>li</string>
<key>one</key>
<string>Sleeps</string>
<key>other</key>
<string>Sleep</string>
</dict>