开发者

Add new language to existing Xcode project localization

I'm working on an existing Xcode 3.2.2 Universal iPhone OS project which is already localized for 4 languages (EN, IT, DE and FR). We are now adding a new language (JA) into this project.

Each existing .lproj folder (en.lproj, it.lproj, de.lproj and fr.lp开发者_开发知识库roj) has almost 60 files - including PNGs, HTMLs and the Localizable.strings file. Each one of those files appear as localized groups inside Groups & Files in Xcode. They're spread all over the tree.

If I right-click one of those groups (say, Localizable.strings) inside Xcode, Get Info, click on "Add Localization" and type "ja" - as the Xcode docs suggest, nothing happens. From what I read in this newgroup, it's possibly because of the way those folders are named. If they were named like English.lproj and Italian.lproj, this was supposed to work.

So, for me to actually import a new language localized file into the existing group, I have to:

  1. Right-click the localized group file.
  2. Choose "Add Existing File".
  3. Select the corresponding file inside the ja.lproj folder.

I'm about to get a new ja.lproj folder with those 60 localized files and would love to import them in the project in a way that doesn't involve searching for every single file in Groups & Trees and performing those steps... for every one of those 60 files.

Is that possible? Is there a right (or better) way to import a new language into this Xcode project?


I found one simple solution. After you right click any multi lingual resource file and choose |Add|Existing Files...| you can select at once all files you wish to add. After you choose the encoding, xCode will automatically add all files under the resources they should be in. I hope this will work for you.


In Xcode 7+ it's pretty simple:

  1. Choose your localizable.strings file and tap on "Localize...":

Add new language to existing Xcode project localization

  1. Next window will ask you if you want the current localizable.strings file should be the default language, in my case English should be the default so I chose 'Base'

  2. Choose your project from the navigation bar, choose your project again, switch to 'Info' and tap the '+' button below the Localizations title:

Add new language to existing Xcode project localization

  1. All you have to do now is to choose the langauge you want to translate and mark ONLY the Localizable.strings file:

Add new language to existing Xcode project localization

  1. Now it will be added to the Localizble.strings file and the actual string that will be shown to the user will be according to his OS language (As long as you have NSLocalizedString all over your app):

Add new language to existing Xcode project localization


This is what I found works:

  1. click add localization;
  2. replace all the files in the new .lproj folder with localized files;
  3. delete the localization, and choose "keeping files";
  4. done.


The mailing list post basically sums up the issue: Xcode expects to find language bundles with names like "English.lproj", "Italian.lproj", etc. If you change those names, Xcode looses the ability to treat them as language bundles, and then you have to add files using the method you described. There's nothing wrong with how you're adding them to the project, that's just how Xcode works.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜