MrGracket MrGracket - 6 months ago 65
iOS Question

NSLocale preferredLanguages is retrieving always 'en' language

I'm trying to get the correct language in my device (is NOT in the SIMULATOR) with the following code:

NSString * languageLocale = [[NSLocale preferredLanguages] objectAtIndex:0];

And it is always 'en' but my current language is set to Spanish

Any thoughts why is retrieving always 'en' and not the current device language?


After a few research, I found out that the key AppleLanguages was being overwritten. So, the

NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
[defaults objectForKey:@"AppleLanguages"];

It was returning a dictionary list with the overwritten data. I just did this:

NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
NSDictionary * dict = [defaults dictionaryRepresentation];
for (id key in dict) {
    if([key isEqualToString:@"AppleLanguages"]){
        [defaults removeObjectForKey:key];
[defaults synchronize];

In order to delete the whole key and the system reset it and return the correct list.