Frage

I am using localization in iOS 7 and have the localizable string files for German and English. When ever i select the corresponding language the localisation works perfect. But if i switch to any other language, then the display is based on the previous selection.

I want it to select english incase of any other language selections, Any thoughts would be appreciated.

War es hilfreich?

Lösung

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.

Andere Tipps

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"];
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top