Change iphone app language with buttons and without restart of the app

Sarah Geebelen picture Sarah Geebelen · Dec 11, 2012 · Viewed 7.4k times · Source

I want to change the language of my app. At the moment I am doing it at the following way. I have two buttons which are change the languages in NSUserDefaults. But before this affects my app I need to restart it.

Here is my code.

- (IBAction)changeDutch:(id)sender {
    [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"nl", @"en", nil] forKey:@"AppleLanguages"];

}
- (IBAction)changeEnglish:(id)sender {
    [[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"en", @"nl", nil] forKey:@"AppleLanguages"];
}

This works fine. But I don't want every time to restart my app. Can anyone tell me how to do that?

Kind regards!

Answer

Hesham picture Hesham · Dec 11, 2012

Check out HMLocalization: https://github.com/HeshamMegid/HMLocalization

It's a replacement for the default localisation framework. It has a demo showing how to change language without having to restart the app.