My Localizable.stringsdict are as follows. And the locale is ENGLISH,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>numberOfLike</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@value@</string>
<key>value</key>
<dict>
<key>NSStringFormatSpecTypeKey</key>
<string>NSStringPluralRuleType</string>
<key>NSStringFormatValueTypeKey</key>
<string>d</string>
<key>one</key>
<string>%d LIKE</string>
<key>other</key>
<string>%d LIKES</string>
</dict>
</dict>
</dict>
</plist>
but the output is always the "other"
The code of getting the strings is
let format = NSLocalizedString("numberOfLike", comment: "")
let message = String.localizedStringWithFormat(format, 1)
which is "1 LIKES". Any Help?
Sorry Guys, the code works. What goes wrong is I am using in app localization, and the plugin has problems when the device locale is different with the in app locale.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.