Rahul Raj
Rahul Raj

Reputation: 367

Localization in iOS 7 : Selects the language settings used previously

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.

Upvotes: 4

Views: 3306

Answers (2)

jmontane
jmontane

Reputation: 76

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.

Upvotes: 6

Anusha Kottiyal
Anusha Kottiyal

Reputation: 3905

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"];

Upvotes: 2

Related Questions