开发者

Why does my XIB file not localize (iPhone)?

Situation: I am starting XCode, creating a new project for the iPhone (view application) and loading the XIB file into the IB. I manipulate the view (adding a label with the string "hello"), save, build, run the application, everything is fine. Now i am localizing the XIB. What i do: right-click on the xib-file, adding the desired language and after that, i have two XIB files in my XCode. Looks absolut perfect, just as it is shown in my iPhone Programming book ("the big nerd ranch"). I do change the label in both XIBs to another string, lets say "good morning!".

Problem: Now i clean and rebuild the application - but it a开发者_如何学Pythonllways shows the old XIB-file, allways the string "hello". Even when i change the settings on the iphone to other languages, i allways get the "hello" string shown. But the XIB with "hello" does not exist in my xcode anywhere!

Any hints for me? It makes me go crazy - and i just hope that i am missing a simple thing.

I am using XCode 3.2.3 and SDK 4.0

Thanks a lot in advance!


There are a a few steps to follow, including:

  • ibtool --generate-strings-file Example.strings en.lpoj/Example.xib
  • genstrings -o en.lproj *.m
  • translating the resource file
  • ibtool --strings-file fr.lproj/Example.strings en.lproj/Example.xib –write fr.lproj/Example.xib
  • dragging the translated resource file to the project (in the exact right place).

Have a look at this iPhone localization tutorial for the full steps + screenshots.


iPhone simulator and the device hold a cache of the NIB's. it is easy to clear on the simulator since it can be deleted, but I am trying to figure out how to clear that cache on the device without having to delete the app.


Try this:

  1. Check if you have added Localitations parameter to "Info" tab of your project file
  2. Window - Organizer - Chose your project - Delete derived data
  3. Project Clean
  4. Delete application from your device
  5. Run again.


In my case, I had to restart xcode in addition to deleting the app on the simulator to get it to work.


Xcode has a bug when it comes to localized strings in a xib file. Instead of replacing the localized strings with the actual xib's strings, Xcode keeps the original xib's strings. All you have to do is to convert the Localizable Strings file to an Interface Builder file. You can do that under the Localization section in the interface builder's file properties.

Hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜