Why does my XIB file not localize (iPhone)?

▼魔方 西西 提交于 2019-12-06 23:22:56

问题


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 allways 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!


回答1:


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.




回答2:


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.




回答3:


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.



回答4:


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




回答5:


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!



来源:https://stackoverflow.com/questions/3919396/why-does-my-xib-file-not-localize-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!