增量本地化如何运作?
我正在尝试构建我的第一个本地化应用程序。我使用 NSLocalizedString 翻译了代码中的所有字符串(与 genstrings 工具一起使用)。现在我遇到了 ibtool。增量本地化如何运作?关于手册页,我应该写这样的内容:
$ ibtool --previous-file path/to/prev.xib \
--incremental-file path/to/inc.xib --localize-incremental \
--write path/to/new.xib mod.xib
Where do I get theincremental file?据我了解,如果我使用版本控制(git/svn),“旧”文件是在几次提交之前,增量文件是 diff,path/to/new.xib 是新生成的 xib 文件。 mod.nib 对我来说是个谜。谁能解释一下这是如何工作的?另外 - 如果没有可用的先前版本(即不进行增量本地化,而是初始本地化),如何开始 xib 的本地化?
I'm trying to build my first localized application. I have all the strings in code translated using NSLocalizedString (for use with genstrings
tool). Now I'm bumping into ibtool
. How does incremental localization work? Regarding to the manual page, I should write something like this:
$ ibtool --previous-file path/to/prev.xib \
--incremental-file path/to/inc.xib --localize-incremental \
--write path/to/new.xib mod.xib
Where do I get the incremental file? To my understanding if I'm using the version control (git/svn), the "old" file is at few commits ago, the incremental file is the diff and path/to/new.xib is newly produced xib file. mod.nib is a mystery to me. Can anyone explain me how this works? Also - how do I start the localization of a xib if no previous versions are available (i.e. doing not incremental, but initial localization)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为他们对术语的选择,特别是
--incremental-file
的选择,导致了混乱。这个想法是,您有两种语言(源语言和目标语言)的旧版本 xib,并且您已经在源语言中更改了它,并且想要更新目标语言版本以匹配。让我们举个例子。您之前有英语(源语言)的 home.xib,并请人将其翻译为法语(目标语言)。此后,您开发了一项新功能,现在拥有英文版 home.xib 的更新版本,其中添加了 UILabel 和 UITextField 并移动了一些内容。您显示的命令可以帮助您获得法语版 home.xib 的更新版本,以便它具有新的 UILabel 和 UITextField,并且内容可以像英语一样移动。请注意,您在新 UILabel 和 UITextField 中设置的任何文本内容都将以英语添加,然后需要翻译为法语 xib(但您可以通过添加
--import-strings-file 并在另一个文件中提供翻译)。
因此,如果我们将您显示的命令映射到此示例:
--previous-file path/to/prev.xib
指定旧英语 xib--incremental-file path/to/inc。 xib
指定旧法语 xib--write path/to/new.xib
指定将要创建的新法语 xibmod.xib
指定新英语xib对于您关于如何进行的其他问题开始这个过程,实际上这取决于您将如何本地化您的 xib。显然,您将创建 xib 的新语言版本(在 XCode 中,您只需将一种语言添加到 xib 的语言列表中,就会自动创建本地化的 xib)。然后,如果您自己在 Interface Builder 中对它们进行本地化,那么您只需在本地化的 xib 中进行相关更改(文本翻译和任何必要的大小调整)即可。或者,您可以将 xib 中的文本提取到
.strings
文件中,翻译它们,然后将它们注入到这些 xib 的相关语言版本中。为此,您将再次使用 ibtool,但在提取阶段使用--generate-strings-file
,在注入阶段使用--import-strings-file
。I think their choice of terminology, particularly for
--incremental-file
, is causing confusion. The idea is that you have an old version of your xib in two languages (source and target) and that you have since changed it in your source-language and want to update the target-language version to match.Let's take an example. You previously had home.xib in English (source language) and got someone to translate it to French (target language). You've since developed a new feature and you now have an updated version of home.xib in English in which you added a UILabel and a UITextField and moved things around. The command you showed can help you get an updated version of home.xib in French so that it has the new UILabel and UITextField and that things are moved around like in English. Note that any textual content that you set in your new UILabel and UITextField will be added in English and will then need to be translated in the French xib (but you can automate this by adding
--import-strings-file
and providing the translations in one more file).So if we map the command you showed to this example:
--previous-file path/to/prev.xib
specifies the old English xib--incremental-file path/to/inc.xib
specifies the old French xib--write path/to/new.xib
specifies the new French xib that will be createdmod.xib
specifies the new English xibFor your other question regarding how you start the process, really it depends how you will localize your xibs. You'll obviously create the new language versions of the xibs (in XCode, you just add a language to the language list of the xib and the localized xibs are created automatically). And then if you localize them in Interface Builder yourself, then you'll simply make the relevant changes (translation of text and any necessary resizing) in the localized xibs. Or you could extract the text in the xibs into
.strings
files, get them translated, and inject them into the relevant language version of these xibs. For this, again you will use ibtool but with--generate-strings-file
for the extract phase and with--import-strings-file
for the inject phase.我为 git 项目编写了一个脚本,它可以自动执行必要的步骤(如上面的答案中所述),以将更改迁移到不同的语言。
用法:
示例:
提交对英语 xib 文件的更改后,在资源文件夹的根目录下运行该脚本。
来源:
I wrote a script for git projects which automates the steps necessary (as described in the answer above) to migrate a change to a different language.
Usage:
Example:
After you've committed your changes to the english xib file, run the script at the root of your resource folder.
Source: