Reputation: 25983
I can get the user's language preferences by looking at [NSLocale preferredLanguages]
. But if I offer 'en' and 'fr' translations, and the user's preferences are 'en-GB', 'de', 'fr', 'en' will they see my 'en' or my 'fr' translation? How do I get the language that the user is currently seeing in my app?
Upvotes: 1
Views: 108
Reputation: 4185
If you want to see which of your localizations is being used, store a string in your strings file describing it ("en", "fr" or whatever) and then load it with NSLocalizedString.
Upvotes: 3
Reputation: 76001
Multiple people claim the right way to do this would be:
NSArray *languages = [NSLocale preferredLanguages];
NSString *currentLanguage = [languages objectAtIndex:0];
Use at your own risk, though. NSLocale
docs don't mention anything about first element being the current one.
Upvotes: 0
Reputation: 727
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
NSString *currentLanguage = [languages objectAtIndex:0];
Upvotes: 0