Is there a way to change the application language during runtime?
So, after the change NSLocalizedString
immediately returns the string for the new language.
What I'm doing now is changing the language using the code below:
- (void)onChangeLanguage: (id)sender {
NSArray *lang = [NSArray arrayWithObjects:((InfoWhatever *)sender).language, nil];
[[NSUserDefaults standardUserDefaults] setObject:lang forKey:@"AppleLanguages"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
NSString *currentLanguage = [languages objectAtIndex:0];
NSLog(@"Current language: %@", currentLanguage);
}
The language will change but only after restarting the app.