Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change language of the ios application

I've put my app settings into iPhone Settings panel. I want to switch between languages independently of the iPhone system language. Is it possible? I'm using this advice: How to force NSLocalizedString to use a specific language

But it translates only string inside app, but my nib files are same. How to reload my nibs?

like image 908
Timur Mustafaev Avatar asked Nov 30 '22 07:11

Timur Mustafaev


1 Answers

The key is to override the NSUserDefaults language key before UIApplicationMain() is called in your main() function in main.m. Try something like this in your main() function:

// use whatever language/locale id you want to override
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:@"de_DE", nil]
                                          forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
int retVal = UIApplicationMain(argc, argv, nil, nil);
like image 51
Mike Weller Avatar answered Dec 04 '22 04:12

Mike Weller