NSUserDefaults and default language used for I18N

Posted by fedmest on Stack Overflow See other posts from Stack Overflow or by fedmest
Published on 2010-05-16T17:38:59Z Indexed on 2010/05/16 17:40 UTC
Read the original article Hit count: 260

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.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about internationalization