NSUserDefaults and default language used for I18N
- by fedmest
I have searched around a lot for this and found some answers that sounded quite like what I wanted but never worked. I simply need to have my iPhone app load NIBs and Localizable.strings that I decide (through user selection) rather than the ones that are established through the global iPhone/iPad settings.
General consensus seems to be that this line
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObject:@"ro"] forKey:@"AppleLanguages"];
would do the trick (in this specific case, load the NIBs and Localizable.strings in ro.lproj) but I have not had such luck. It keeps on looking for the files in en.lproj or whatever language I chose in the Settings app.
I have then tried adding this line
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObject:@"ro_RO"] forKey:@"AppleLocale"];
and to my great surprise, it worked! ...only once :-( then back to the same issue. Has anyone got any idea how to solve this issue? The aforementioned code was added at the very start of applicationDidFinishLaunching, which is before any NIBs or strings files should be loaded.