Moving localization folders in Xcode 4

纵然是瞬间 提交于 2019-12-30 07:22:29

问题


I've recently upgraded from Xcode 3 to Xcode 4.2, and migrated an existing iOS apps to use this new version. This app is localized, and I now want to add another language.

Under Xcode 4, when I add the new localization, it creates the country specific folder in the project root. For example:

/fr.lproj

All of my prior language folders are in a Resources sub-folder, however. Such as:

/Resources/de.lproj
/Resources/en.lproj

For the life of me I cannot figure out how to get Xcode 4 to move the new language folder to Resources. There is no GUI option I can find. If I move the physical folder using Finder, Xcode just changes the reference to red, but gives me no option to fix it.

Can anyone help?

UPDATE:

Here are a few screenshots demonstrating the problem (using Chinese this time):

The file listing:

The identity section for that file. Note that I can't change it:


回答1:


Found the solution. It's not pretty, but it works.

Here's what I did:

  1. View the contents of the .xcodeproj folder in Finder
  2. Edit the project.pbxproj file
  3. Search for .lproj within the file
  4. Change the path = section to include the Resources part of the path.
  5. Save, then restart Xcode

This smoothed everything over, and allowed the Localization to reside in the Resources subdirectory.




回答2:


Here's a way how to solve it w/o editing .pbxproj file (Xcode 4.6.3):

  1. select localization parent file (Localizable.strings)
  2. Utility pane > Identity and Type > under Location (Relative to Group) choose path icon and set required new location for localization files
  3. Finder > move all your en.lproj, fr.lproj, etc subfolders to that chosen folder

UPD: doesn't work in Xcode 8 :(




回答3:


This way works on Xcode 5.1 also (Greek example):

  1. Create Resources/el.lproj folder within Localizable.strings file in Finder
  2. Open your project file in Xcode and right-click on Resource folder
  3. Click on "Add File to..." context menu item
  4. Select Localizable.strings file from Resources/el.lproj folder -> OK. Greek Localizable.strings automatically will be added to Localizable.strings files.

You can use the same way to add localization for xib files.




回答4:


The file structure on disk is mostly irrelevant in Xcode. Just move the directory in Finder, then in Xcode you can either: (a) remove the fr.lproj directory and re-add it, or (b) select the red entry, open the right-hand (properties) panel, and near the top you should see the path. Change the path to the new location and it'll go back to black.



来源:https://stackoverflow.com/questions/10237285/moving-localization-folders-in-xcode-4

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