1: Localizations installation project, as shown in the screenshot, the project has English and Russian languages.

2: Create an empty property list file named Localizable.stringsdict and paste the following:
<?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>NumberOfMessages</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>You have a new message.</string> <key>other</key> <string>You have %d new messages.</string> </dict> </dict> </dict> </plist>
3: Localize the file above for each language, see the screenshot, the file is localized for English and Russian:

Using:
String(format: NSLocalizedString("NumberOfMessages", comment: ""), 1)
Conclusion: You have a new message.
String(format: NSLocalizedString("NumberOfMessages", comment: ""), 2)
Conclusion: You have 2 new posts.
Limit rules: In the XML code, pay attention to <key>one</key> and <key>other</key> , here you can use zero , one , two , few , many , other depending on the language and your requirements .
Use the following link for more information on multiple language-specific rules: http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html
source share