Newer posts are loading.
You are at the newest post.
Click here to check if anything new just came in.

How to get the current iPhone Language Code

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 let’s you query the language by writing the following code:

[NSLocale currentLocale] objectForKey:NSLocaleLanguageCode];

At least one would expect so, but it actually 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 really should call is:
[[NSLocale preferredLanguages] objectAtIndex:0]
Because this gives you not the language associated with the region, but the language the device is actually configured for.

Don't be the product, buy the product!