Change Language in the app programmatically in iOS

Usually when you support official languages that Apple supports in iOS, there is no reason to provide language switching within the app, just properly set up translations in your project and interface language will automatically switch with the system. But since you want it from the app, there are few ways to go about this:

1) You could force a specific language for just your app with the following code:

[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"zh-Hans", @"en", @"fr", nil] forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];

I would suggest putting this code inside main.m file in “int main” function just before the “return UIApplicationMain”. But this method requires you to kill the app or tell user to restart the app for it to take effect.

You can kill the app without having user to force quit the app using exit(0), but make sure user has chance to abort the action with UIAlertView or similar, or Apple might reject your app.

2) Alternative is implementing your own localization logic, where you just take translations from your own language file. One way is this example which takes translations from official lproj files. This way you can change the language on the fly without a restart, but you have to manually load all label texts from the code. When you change the translation, you have to repopulate the text on screen.

Leave a Comment