0

i've got a IOS project with many different images to display depending on the language, and i can't find a way to force loading the correct image at runtime (not switching a language to another). Actually it seems that the files are loaded before the AppDelegate get a chance to interfer.

if i do in appDelegate (didFinishLaunchingWithOptions:):

[[NSUserDefaults standardUserDefaults] setObject: [NSArray arrayWithObjects: @"es", @"en", nil] forKey:@"AppleLanguages"];

It's already too late, image are already loaded in the wrong language. So in order to accomplish this i have moved the NSUserDefaults into the main() call, and this tricks works. But my questions are: Do Apple will reject my app? And is there a better, clean approach to synchronize a language at compile time (or with plist or something like that)?

Update

it seems that just replacing [[NSUserDefaults standardUserDefaults] setObject: forKey:], further step before calling my nib file did the trick. It's like [NSUserDefaults standardUserDefaults] is called asynchronously. So maybe the setter method was actually evaluated after my nib file was loaded. But can i change the localizable setting via info.plist ?

Mr Bonjour
  • 3,330
  • 2
  • 23
  • 46
  • 1
    XCode is not involved at runtime. So it's the operating system that loads the images, not XCode. But what operating system (iOS, MacOS) are we talking about? Please add the corresponding tag. – Codo Oct 22 '12 at 11:04
  • Codo i have updated my question. This is in IOS, and i was not sure if i could change this behavior strongly at compile time (like into the info.plist), that why i involved Xcode much more than the runtime layer. – Mr Bonjour Oct 22 '12 at 11:11
  • Do like this. I am okay with answer from Gilad. http://stackoverflow.com/questions/1669645/how-to-force-nslocalizedstring-to-use-a-specific-language – Khant Thu Linn Aug 19 '14 at 08:15

1 Answers1

0

You can localize the Info.plist (InfoPlist.strings), which lets you set the Default.png for each language.

ApplinguaRob
  • 304
  • 3
  • 7