4

我在 iOS 7 中使用本地化,并拥有德语和英语的可本地化字符串文件。当我选择相应的语言时,本地化工作完美。但如果我切换到任何其他语言,则显示基于先前的选择。

我希望它在任何其他语言选择的情况下选择英语,任何想法将不胜感激。

4

2 回答 2

6

AFAIK, this behaviour is a feature, but undocumented? :)

In iOS7, users can set a sorted list of preferred languages. For instance; a French user fluent in German, but not in English, could set French, German, and English as language preference. It's a great feature!!!

So, I think you shouldn't override this feature.

Users can set English as 2nd language easily, choosing 1st English and then choosing it's preferred main language.

于 2013-10-14T08:06:34.587 回答
2

Use the below checking in your main.m

NSString * deviceLanguage = [[NSLocale preferredLanguages] objectAtIndex:0];
NSArray *supportedLanguages = [NSArray arrayWithObjects:@"en",@"de", nil];

if ([supportedLanguages containsObject:deviceLanguage])
   [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:deviceLanguage, nil] forKey:@"AppleLanguages"];
else
   [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"en", nil] forKey:@"AppleLanguages"];
于 2013-10-09T04:53:27.893 回答