Posts Tagged ‘Localization’
Getting the current iPhone language
There are situations in which you would like to check the current iPhone language, because maybe you want to provide the user with the possibility of having an app in a language different then default one.
For example, I am developing an application with dish recipes (hmmmm, there are the best Italian recipes). I usually have the iPhone in English, but I would prefer in this case to get the recipes in Italian without having to switch every time the language of my iPhone.
In cases like this, you can check the current language using the following lines of code:
1
2
3 NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];
NSArray* languages = [defs objectForKey:@"AppleLanguages"];
NSString* preferredLang = [languages objectAtIndex:0];
So, we retrieve the list of the Apple Languages (the languages supported by the iPhone) and then, we get the first element, which represents the language of your mobile.
For more information, give a look at this link.
Geppy



