In case you want to use the application in a language / region / format other than the selected iPhone settings value. An example application with its own internal language settings.
I know how to change the language, but what about the region / format?
To easily override the selected language in the settings, you can run this code in the main
[[NSUserDefaults standardUserDefaults]
setObject:[NSArray arrayWithObject:@"sv"]
forKey:@"AppleLanguages"];
To view the change in action, let's display the current settings below the code
NSString *locale = [[NSLocale currentLocale] localeIdentifier];
NSLog(@"current locale: %@", locale);
NSArray* preferredLangs = [NSLocale preferredLanguages];
NSLog(@"preferredLangs: %@", preferredLangs);
When exiting as
current locale: en_US
preferredLangs: ( sv )
But I want to change this language to sv_SE
How can I override the locale (region / format) in the iPhone settings in the same way?
source
share