简体   繁体   English

为现有Xcode项目本地化添加新语言

[英]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). 我正在研究现有的Xcode 3.2.2通用iPhone OS项目,该项目已经针对4种语言(EN,IT,DE和FR)进行了本地化。 We are now adding a new language (JA) into this project. 我们现在在这个项目中添加一种新语言(JA)。

Each existing .lproj folder ( en.lproj , it.lproj , de.lproj and fr.lproj ) has almost 60 files - including PNGs, HTMLs and the Localizable.strings file. 每个现有的.lproj文件夹( en.lprojit.lprojde.lprojfr.lproj )都有近60个文件 - 包括PNG,HTML和Localizable.strings文件。 Each one of those files appear as localized groups inside Groups & Files in Xcode. 这些文件中的每一个都在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. 如果我右键单击Xco​​de中的其中一个组(例如, Localizable.strings ),获取信息,单击“添加本地化”并键入“ ja ” - 正如Xcode文档建议的那样,没有任何反应。 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. 如果他们被命名为English.lprojItalian.lproj ,那么这应该可行。

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. ja.lproj文件夹中选择相应的文件。

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. 我即将获得一个包含这60个本地化文件的新ja.lproj文件夹,并且希望以不涉及搜索Groups&Trees中的每个文件并执行这些步骤的方式在项目中导入它们。对于这60个文件中的每一个。

Is that possible? 那可能吗? Is there a right (or better) way to import a new language into this Xcode project? 是否有正确(或更好)的方式将新语言导入此Xcode项目?

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. 选择编码后,xCode会自动将所有文件添加到它们所应用的资源下。我希望这对你有用。

In Xcode 7+ it's pretty simple: 在Xcode 7+中,它非常简单:

  1. Choose your localizable.strings file and tap on "Localize...": 选择您的localizable.strings文件,然后点击“Localize ...”:

在此输入图像描述

  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' 下一个窗口会询问您是否希望当前的localizable.strings文件应该是默认语言,在我的情况下,英语应该是默认语言,所以我选择了'Base'

  2. Choose your project from the navigation bar, choose your project again, switch to 'Info' and tap the '+' button below the Localizations title: 从导航栏中选择项目,再次选择项目,切换到“信息”,然后点击“本地化”标题下方的“+”按钮:

在此输入图像描述

  1. All you have to do now is to choose the langauge you want to translate and mark ONLY the Localizable.strings file: 您现在要做的就是选择要翻译的语言并仅标记Localizable.strings文件:

在此输入图像描述

  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): 现在它将被添加到Localizble.strings文件中,将向用户显示的实际字符串将根据他的操作系统语言(只要你的应用程序中有NSLocalizedString):

在此输入图像描述

This is what I found works: 这是我发现的作品:

  1. click add localization; 点击添加本地化;
  2. replace all the files in the new .lproj folder with localized files; 用本地化文件替换新.lproj文件夹中的所有文件;
  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. 邮件列表帖子基本上总结了这个问题:Xcode希望找到名称如“English.lproj”,“Italian.lproj”等的语言包。如果你更改这些名称,Xcode就无法将它们视为语言包,然后你必须使用你描述的方法添加文件。 There's nothing wrong with how you're adding them to the project, that's just how Xcode works. 你如何将它们添加到项目中没有错,这就是Xcode的工作原理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM