We are currently developing an iPhone app which requires localization support, and I ran into an issue while trying to get currently set language.

Cocoa Touch has a class called NSLocale which lets you query the language by writing the following code:

  [NSLocale currentLocale] objectForKey:NSLocaleLanguageCode];

At least, that’s what you’d expect. Actually, it gives you the language of the region format you have configured in your settings.

For example:
If you have your iPhone language set to ‘English’, but your region format is set to ‘Germany’, the call will return ‘de’ instead of ‘en’.

What you should really call is:

  [[NSLocale preferredLanguages] objectAtIndex:0]

This gives you not the language associated with the region, but the language for which the device is actually configured.