Alexandr Alexandr - 2 years ago 147
iOS Question

How do I get current application locale?

I need to get current locale. Not user locale but my application locale.

Let's say my application has two localizations (in project settings): English (default) and French. If user sets French language on iPhone then my application will display French interface. If user sets German language on iPhone then my application will display English interface (because English is default).

So how do I get current application locale that is showing right now?
Thanks in advance.

Answer Source

The selected answer returns the current device language, but not the actual language used in the app. If you don't provide a localization for the preferred language in your app

 NSString *language = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0]

 NSLocale *locale = [NSLocale currentLocale];
 NSString *countryCode = [locale objectForKey: NSLocaleCountryCode];

NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
NSString *country = [usLocale displayNameForKey: NSLocaleCountryCode value: countryCode];

NSLog(@"country   .   %@",country);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download