I'm localizing my iPhone app for multiple languages, and in addition to changing some of the strings I need to change some backgrounds. Is it possible to query the iPhone and get the user's language code?
Thanks!
Take a look at NSLocale:
NSString *language = [[NSLocale currentLocale] objectForKey: NSLocaleLanguageCode];
NSString *countryCode = [[NSLocale currentLocale] objectForKey: NSLocaleCountryCode];
solved my own question!
NSString *language = [[NSLocale preferredLanguages] firstObject];
if (!language) {
language = @"en";
}
NSLog(@"The device's specified language is %@", language);
Swift version :
var language : String! = "en"
if let lng = NSLocale.preferredLanguages().first {
language = lng
}
print("The device's specified language is \(language)")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With