I have a client who needs localizations for several languages. To retrieve the current language I used
NSString * localeString = [[NSLocale currentLocale] localeIdentifier]; NSString * language = [[[localeString componentsSeparatedByString:@"_"] objectAtIndex:0] uppercaseString];
Most of the time the content of localeString represented the settings in the system preference pane. But if I set English as the first language and Finland as the region in Formats it returns “fi_FI” as the localeString, but uses the Finnish nib files.
To get the languages in the order from the preference pane “Language” one has to use the following code:
NSUserDefaults* defs = [NSUserDefaults standardUserDefaults]; NSArray* languages = [defs objectForKey:@"AppleLanguages"]; NSString* language = [[languages objectAtIndex:0] uppercaseString];
The variable language contains now “EN” as expected.