2
votes

I noticed an issue in XCode 4.2 where some localized NIBs don't load the correct image from their respective language bundle.

In one of my controllers, I have several image views. In the English version, I have noticed that some image views grab the french version of the images that are supposed to be loaded on them. The same thing happens to the French version of the NIB.

I have obviously double-checked my image resources and verified that the french images are correctly stored in both the "en.lproj" and "fr.lproj" folders.

Has anyone run into this issue before? The biggest head-scratcher is everytime I run the project, whether in the simulator or the actual phone, the images seem to flip-flop consistently. I don't even have manual calls in my controller to load images. All images are just preset via the NIB.

2
Does that problem always occur with the same images?Nicolas Bachschmidt
At first I thought yes. I have tried recreating the NIBs and manually adding the localized images. For a while the images would load fine in the NIB when I open it in IB. As soon as I run the project, the simulator/iPhone build would only load some images properly. As soon as I open the affected NIB in XCode, some of the images now appear in french (other image views are not affected though). The affected image views are also random. I am really very close to just doing manual calls in my code to load the correct image. :-(Moonjock
Did you find a solution? I have the same problem :(mrmuggles
I ended up manually writing load methods in my viewWillAppear delegate. :-(Moonjock

2 Answers

0
votes

If you localized a resource after it was included in a build, the unlocalized version of the resource remains in the built application. Rebuilding the application only adds new files and updates edited files but don't remove deleted files.

To solve that problem in the simulator, you can open the Organizer (Window > Organizer), select the Projects tab and delete your project's derived data, then rebuild.

To solve that problem on your device, you can delete the application, clean your build products (Product > Clean), then rebuild.

0
votes

I have the same problem and the only solution I have found was to remove the images localization and load them.

UIImage *img = [UIImage imageNamed:NSLocalizedString (@"imageOne.png", @"Main Image")];

And in your Localizble.strings (Spanish) for example, you write:

"imageOne.png" = "imageOne_es.png";

And for Localizble.strings (English):

"imageOne.png" = "imageOne_en.png";