问题描述
我需要本地化一个正在开发的英语和英语应用程序西班牙语.
I need to localiza a in development app for English & Spanish.
尽管我遵循 Apple 的使用方式 NSLocalizedString &为两者创建 nib,我已经丢失了需要本地化的新字符串的轨道,并惊讶地发现当我更换 master 时我需要用西班牙语重做 nib.
Despite the fact I follow the Apple way of use NSLocalizedString & create nibs for both, I already lost the track of the new string that need to get localized and found with surprise that I need to redo the nibs in spanish when I change the master.
(就像这样 http://www.gigliwood.com/weblog/Cocoa/A_Great_Need_for_Be.html)
我想知道是否存在更好/替代/更自动化的方式.
I wonder if exist a better/alternative/more automated way.
我知道gettext & 的用法poedit 并想知道是否可以使用类似的东西.
I know the use of gettext & poedit and wonder if something like that can be used.
或者如果存在一些脚本或工具.
Or if exist some script or tool for this.
推荐答案
这里确实没有一个简单的解决方案.NIB 需要为每种语言单独布局.在某种程度上,这改善了整体用户界面,因为不同的语言实际上通常需要不同的布局才能看起来最好.俄语和德语在屏幕空间中是比英语更大"的语言.中文通常可以小得多,并且不同的布局看起来更好用中文字符.阿拉伯语和希伯来语是从右到左的,可能需要彻底改变布局.自动布局很容易,但通过在所有语言中呈现不同程度的丑陋来实现这一点.当在开发人员容易和丑陋与开发人员困难和美观之间进行选择时,Apple 几乎总是选择后者.尽管如此,Apple 仍然没有尽可能地简单.
There really isn't an easy fix here. NIBs need to be individually laid out for every language. To some extent, this improves overall user interface, because different languages actually often need different layout to look their best. Russian and German are much "larger" languages in screen real estate than English. Chinese can often be much smaller and a different layout looks better with Chinese characters. Arabic and Hebrew are right-to-left and may need radical changes to layout. Automated layout is easy, but achieves this by being varying levels of ugly in all languages. When given the choice between easy for the developer and ugly vs. difficult for the developer and beautiful, Apple almost always chooses the latter. That said, Apple has still not made it nearly as easy as they could.
所以这里的第一课是保持你的NIB简单.这在 iPhone 上比在 Mac 上更容易,因为 iPhone 没有绑定,而且 iPhone NIB 通常更简单.您还可以对具有非常少量文本(如标题)的 NIB 使用文本注入.文本注入"是在加载视图时为标签使用插座并设置为本地化文本"的一种奇特方式.
So the first lesson here is to keep your NIBs simple. This is easier on iPhone than on Mac because iPhone doesn't have bindings and iPhone NIBs are generally simpler anyway. You can also use text injection for NIBs that have very small amounts of text (like a title). "Text injection" is a fancy way of saying "use an outlet for the label and set it to the localized text when you load the view."
ibtool 能够从 NIB 中拉出字符串并将它们推回,这会很有帮助.我使用了 iLocalize,它有助于与合同本地化人员一起工作,但对您所说的问题并没有真正的帮助.
ibtool is able to pull strings out of NIBs and also shove them back in, which can be helpful. I've used iLocalize, which is helpful for working with contract localizers, but doesn't really help with the problem you're talking about.
我尝试摆脱 NIB 并只使用代码,认为这会使事情变得更容易,但事实并非如此.在 NIB 中布局每种语言比提出在所有语言中看起来都不错的布局逻辑更容易(见第一段).文本注入仅在少数地方有用.如果您可以将您的 NIB 拆分为需要本地化的和不需要本地化的,那会很有帮助.在 iPhone 上,我发现我的 NIB 中实际包含文本或本地化图像的不到一半.
I tried getting rid of NIBs and just using code, thinking it would make things easier, but it really didn't. It was easier to lay out each language in the NIB than to come up with layout logic that would look good in all languages (see first paragraph). Text injection was only useful in a handful of places. If you can split your NIBs up into ones that need to be localized and those that don't, that can be helpful. On iPhone, I found that less than half of my NIBs actually had text or localized images in them.
当然你应该阅读国际化编程主题,但很抱歉,您的问题确实没有简单的答案.运送产品以 19 种语言本地化,我感受到你的痛苦.
Of course you should read Internationalization Programming Topics, but I'm sorry to say there really is no easy answer to your problem. Shipping products localized in 19 languages, I feel your pain.
这篇关于如何简化 iPhone 本地化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!