Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Getting current device language in iOS?

I'd like to show the current language that the device UI is using. What code would I use?

I want this as an NSString in fully spelled out format. (Not @"en_US")

EDIT: For those driving on by, there are a ton of useful comments here, as the answer has evolved with new iOS releases.
by

2 Answers

akshay1995
This will probably give you what you want:

NSLocale locale = [NSLocale currentLocale];

NSString
language = [locale displayNameForKey:NSLocaleIdentifier
value:[locale localeIdentifier]];

It will show the name of the language, in the language itself. For example:

Français (France)
English (United States)
RoliMishra
Solution for iOS 9:

NSString language = [[NSLocale preferredLanguages] objectAtIndex:0];


language = "en-US"

NSDictionary *languageDic = [NSLocale componentsFromLocaleIdentifier:language];


languageDic will have the needed components

NSString *countryCode = [languageDic objectForKey:@"kCFLocaleCountryCodeKey"];


countryCode = "US"

NSString languageCode = [languageDic objectForKey:@"kCFLocaleLanguageCodeKey"];

Login / Signup to Answer the Question.