.stringdict not working in iOS8

with some problems using .stringdict. Code like this:

<?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>groups-selected</key> <dict> <key>NSStringLocalizedFormatKey</key> <string>%#@ groups@ </string> <key>groups</key> <dict> <key>NSStringFormatSpecTypeKey</key> <string>NSStringPluralRuleType</string> <key>NSStringFormatValueTypeKey</key> <string>d</string> <key>one</key> <string>%d group selected</string> <key>other</key> <string>%d groups selected</string> </dict> </dict> <key>friends-online</key> <dict> <key>NSStringLocalizedFormatKey</key> <string>%#@ friends@ </string> <key>friends</key> <dict> <key>NSStringFormatSpecTypeKey</key> <string>NSStringPluralRuleType</string> <key>NSStringFormatValueTypeKey</key> <string>d</string> <key>one</key> <string>%d friend online</string> <key>other</key> <string>%d friends online</string> </dict> </dict> <key>points-usage-message</key> <dict> <key>NSStringLocalizedFormatKey</key> <string>%#@ points@ </string> <key>points</key> <dict> <key>NSStringFormatSpecTypeKey</key> <string>NSStringPluralRuleType</string> <key>NSStringFormatValueTypeKey</key> <string>d</string> <key>one</key> <string>%d point will be deducted</string> <key>other</key> <string>%d points will be deducted</string> </dict> </dict> </dict> </plist> 

Localization works in iOS9 + in the simulator and on the device, however for iOS8 it will not work on any, and I just get the output key name ie: points-usage-message . Any ideas what I can do wrong here?

+5
source share
4 answers

Actually, it works on iOS 8.4. We also use the .strinsgdict format. So I added this code:

 <key>points-usage-message</key> <dict> <key>NSStringLocalizedFormatKey</key> <string>%#@ points@ </string> <key>points</key> <dict> <key>NSStringFormatSpecTypeKey</key> <string>NSStringPluralRuleType</string> <key>NSStringFormatValueTypeKey</key> <string>d</string> <key>one</key> <string>%d point will be deducted</string> <key>other</key> <string>%d points will be deducted</string> </dict> </dict> 

to our file, and it works correctly when I got it using this code:

 [NSString localizedStringWithFormat:NSLocalizedString(@"points-usage-message", nil), 42]; 

or fast:

 let localizedFormat = NSLocalizedString("points-usage-message", comment: "") let pointsInfo = String.localizedStringWithFormat(localizedFormat, 42) 

Please try this code and share the results. In addition, you can additionally try to check the membership and localization of the target .strinsgdict file (must be installed in any country).

+4
source

Check out http://maniak-dobrii.com/understanding-ios-internationalization/ , especially the part that reads:

"Quick access to .stringdict: don't forget to have a (at least empty) .strings file with the same name for each localization you support, otherwise .stringdict will not be recognized and used."

In my case, I had a localized .stringdict file and a non-localized .strings file. iOS9 was able to show the correct translation, but iOS8 failed

+4
source

Try to change

 <string>%#@ points@ </string> <key>credits</key> 

to

 <string>%#@ points@ </string> <key>points</key> 

for the points-usage-message string. Both string and key must be the same.

+1
source

Also note. The .stringdict file and .strings should be located at the root of the project. Otherwise, they are not found.

+1
source

Source: https://habr.com/ru/post/1241810/


All Articles