找到你要的答案

Q:Sane localization workflow using Xcode 6, iOS 8, Storyboards and xliff?

Q:理智的定位流程使用Xcode 6,iOS 8,故事板和XLIFF?

This is ideally what I'd like to do:

  1. Set up a project in Xcode using a base localization of English. Ultimately I want English and let's say Dutch versions of my Localizable.strings and Storyboards
  2. Externalise strings in code with NSLocalizedString, using keys of the form fooViewController.barLabel, being diligent and adding proper context comments with every key
  3. Add a Dutch localization to my Storyboard files
  4. Mark particular labels in the Storyboard as placeholders that will be set at runtime and do not require translations
  5. Add comments for labels in the Storyboard which do require translation
  6. Export the "development language" xliff file (Click on Project, Editor/Export For Localization..., choose "Development Language Only")
  7. Open the English xliff file in a tool like Counterparts or Xliffie or even something web based
  8. Add actual English translations alongside the fooViewController.barLabel keys, and re-save the en.xliff
  9. Create an nl.xliff file from the original en.xliff and add Dutch translations
  10. Import both xliff files into Xcode and have it create the appropriate .strings files for both Dutch and English, for both the keys defined in code and those in the Storyboard; commit the new .strings files into my source repository
  11. At some future point after keys have been added, removed and changed in my source and Storyboards, export the "Development language" en.xliff again as the source of truth
  12. Update the en.xliff and nl.xliff files with current translations, having a tool highlight which keys had been added or removed
  13. Import those xliff files back into Xcode which updates the .strings files I can then check back in to my source repository

Does this make sense? Is this a reasonable thing to want to do? I think so, but it doesn't work.

Here are the problems I ran into:

  • Xcode does not support step 4—the xliff format can mark a key as translate=no, but there is no way to annotate that in Xcode (ideally, Xcode wouldn't export keys marked as placeholders at all.)
  • Xcode does not support step 5—there is no way to set a translator comment for a label. There's not even a way to set the key independent of the placeholder text you put in the label on the Storyboard, which is a massive pain if you find filling labels with Lorem Ipsum useful when laying out your views.
  • When you get to step 10, Xcode complains there is no target language specified in the en.xliff file. There is a way to change the target language (or, at least, create a new file with the target language set to EN) in Counterparts but I couldn't find any way to do this with Xliffie.
  • Upon attempting to re-export the en.xliff file with updated keys, Xcode told me "Localization failed reading "[...]/Supporting Files/en.lproj/Localizable.strings, Please address the issue at file location 782" at which character location I found... an apostrophe. Xcode can't export an xliff file if the source .strings file contains an apostrophe. What in the actual F...?!
  • Step 12 and 13 got weird, and I just don't understand what was happening. Both Counterparts and Xliffie had replaced my original fooViewController.barLabel keys with the English translations and looked like they were trying to tell me I had no English translations. Upon attempting to import the en.xliff back into Xcode it told me I had no translations for all but the new keys and when I went ahead, it wiped the existing translations from the en.lproj/Localization.strings file.

This is a mess.

Translating labels in Storyboards without being able to manually set their keys, add translator comments or mark particular labels as placeholders not-for-translation just doesn't work. We've resorted to connecting every label to an @IBOutlet and setting its translation in viewDidLoad() with NSLocalizedString.

Xcode choking when it attempts to export a .strings file containing an apostrophe beggars belief.

It also seems there's an underlying assumption that if the "development language" in Xcode is English, then the developers are in charge of the English translation. I can imagine no context outside that of a single-person indie developer shop where this is true.

Finally, it also seems I'm missing something about how the tools I've attempted to use structure their workflows. If anyone could enlighten me I'd be quite grateful.

Has anyone managed to construct a workable localization workflow where the developers aren't charged with ultimate editing control over the "development language" and the .strings files checked into the repository are the source of truth?

这是理想的我想做的:

  1. Set up a project in Xcode using a base localization of English. Ultimately I want English and let's say Dutch versions of my Localizable.strings and Storyboards
  2. Externalise strings in code with NSLocalizedString, using keys of the form fooViewController.barLabel, being diligent and adding proper context comments with every key
  3. Add a Dutch localization to my Storyboard files
  4. Mark particular labels in the Storyboard as placeholders that will be set at runtime and do not require translations
  5. Add comments for labels in the Storyboard which do require translation
  6. Export the "development language" xliff file (Click on Project, Editor/Export For Localization..., choose "Development Language Only")
  7. Open the English xliff file in a tool like Counterparts or Xliffie or even something web based
  8. Add actual English translations alongside the fooViewController.barLabel keys, and re-save the en.xliff
  9. Create an nl.xliff file from the original en.xliff and add Dutch translations
  10. Import both xliff files into Xcode and have it create the appropriate .strings files for both Dutch and English, for both the keys defined in code and those in the Storyboard; commit the new .strings files into my source repository
  11. At some future point after keys have been added, removed and changed in my source and Storyboards, export the "Development language" en.xliff again as the source of truth
  12. Update the en.xliff and nl.xliff files with current translations, having a tool highlight which keys had been added or removed
  13. Import those xliff files back into Xcode which updates the .strings files I can then check back in to my source repository

这有意义吗?这是一件合理的事吗?我想是的,但它不起作用。

以下是我遇到的问题:

  • Xcode does not support step 4—the xliff format can mark a key as translate=no, but there is no way to annotate that in Xcode (ideally, Xcode wouldn't export keys marked as placeholders at all.)
  • Xcode does not support step 5—there is no way to set a translator comment for a label. There's not even a way to set the key independent of the placeholder text you put in the label on the Storyboard, which is a massive pain if you find filling labels with Lorem Ipsum useful when laying out your views.
  • When you get to step 10, Xcode complains there is no target language specified in the en.xliff file. There is a way to change the target language (or, at least, create a new file with the target language set to EN) in Counterparts but I couldn't find any way to do this with Xliffie.
  • Upon attempting to re-export the en.xliff file with updated keys, Xcode told me "Localization failed reading "[...]/Supporting Files/en.lproj/Localizable.strings, Please address the issue at file location 782" at which character location I found... an apostrophe. Xcode can't export an xliff file if the source .strings file contains an apostrophe. What in the actual F...?!
  • Step 12 and 13 got weird, and I just don't understand what was happening. Both Counterparts and Xliffie had replaced my original fooViewController.barLabel keys with the English translations and looked like they were trying to tell me I had no English translations. Upon attempting to import the en.xliff back into Xcode it told me I had no translations for all but the new keys and when I went ahead, it wiped the existing translations from the en.lproj/Localization.strings file.

这是一团糟。

翻译标签的故事不能够手动设置他们的钥匙,加上译者注释或标记特定的标签作为占位符不是翻译是行不通的。我们采取了连接每个标签@ IBOutlet并将其翻译viewdidload() NSLocalizedString。

Xcode窒息当它试图出口。字符串文件包含撇号乞丐的信念。

它似乎也有一个基本的假设,如果“发展语言”在Xcode是英语,那么开发商在英语翻译收费。我可以想象没有背景之外,个人开发者的店,这是真的。

最后,我似乎也遗漏了一些我试图使用它们的工作流程的工具。如果有人能开导我,我会非常感激。

有没有人设法构建一个可行的本地化工作流程,开发人员不收取最终编辑控制的“开发语言”和字符串文件检查到存储库是真理的来源?

answer1: 回答1:

We've resorted to connecting every label to an @IBOutlet and setting its translation in viewDidLoad() with NSLocalizedString.

You are doing that right. Seriously. Wrap your development process around it and you'll get way better off than trying to adopt the mess that the Storyboard localization evolved into.

It solves pt.4 - you decide what you put in the Localizable.strings

It solves pt.5 - comments are there by default, for everything that you decide to be localizable. Now to be honest, XCode7 has added a possibility to add notes to resources. Don't use it. For some reason only known to Apple, it is not available for all types of resources. You can't annotate e.g. table headers and footers. More on that later.

I recommend making your own NSBundle.localizedStringForKey wrapper (macro) which provides the value. NSLocalizedString sets value to empty string, essentially forcing key to be used as the fallback translation content. Of all the already existing questionable macros, NSLocalizedStringWithDefaultValue takes the value but also all other 4 required parameters - not something you would like to use often.

Step 10 is caused by you trying to import a Base localization - the fact that it's english does not make any difference. If you want to "translate english" (i.e. professional correcture), you must add english as another standalone localization on top of Base. Technically it boils down to the Base xliff missing <file target-language> and <target xml:lang> properties. Due to some strange xliff mess similar to yours, i had to add those once manually. You don't want to do that :)

Re apostrophe glitch: iOS localization is an unreal garden of wonders, but i'm prety sure it's not THAT unreal :) Try opening the file in some hexcode displaying editor - what XCode renders may be quite different from what the file really contains.

  1. ... even something web based

That's Crowdin for us and it nicely shows everything wrong with Apple's idea of Storyboard localization. Translators need 3 things to do their work professionally: context, context and context. Apple seems to think that translators will gladly install the app, play with it and ask questions to get the context. Because, by default, there is no human context in xliff export. Now with Xcode7, you can add notes, but weirdly not everywhere. Even where you can, your note is appended at the end of already long <note> string with machine context - understandably needed for storyboard import matching, but useless and obstructive for the translator. Furthermore, in reality, the translator is a pro agency, or a language enthusiast. Even if you had a luck with properly equipped enthusiast, or you paid the agency premium for getting an extra customer care, you enter The Hostile Desert Of Beta Distribution Options. Apple's funny Testflight reincarnation will either need the translator to register as an Apple developer, or waiting for Apple's beta review - depending on how early in the app life you need the translation.

BTW i like your blog. Sometimes i feel like dumping my sourness and misfeature fatigue too, but never got as far as you :)

我们采取了连接每个标签@ IBOutlet并将其翻译viewdidload() NSLocalizedString。

你这样做是对的。严重。把你的开发过程围绕它你会得到更好的比试图采取的混乱,故事板定位演变成。

它解决了PT。4你决定你将在localizable.strings

它解决了PT。5评论有默认的,那你决定是本地化的一切。现在,说实话,xcode7增添了一个可能的资源添加注释。不要用它。出于某种原因,只有苹果知道,它不适用于所有类型的资源。你不能诠释如表格页眉和页脚。更多关于稍后。

我建议把自己的NSBundle.localizedStringForKey包装(宏观)提供的价值。nslocalizedstring集值为空字符串,主要是强迫关键作为后备翻译内容。所有已经存在的可疑的宏,NSLocalizedStringWithDefaultValue以价值也是所有其他4所需的参数不是你想用常。

步骤10是由于你试图导入一个基本的本地化-事实上,它的英语没有任何区别。如果你想“翻译英语”(即专业correcture),你必须把英语作为最基础的另一独立的定位。在技术上它归结为基地XLIFF文件目标语言缺失的<;>;和<;目标XML:郎>;性能。由于一些奇怪的XLIFF的混乱与你相似,我不得不把那些曾经手动。你不想那样做:

重新定位是撇号毛刺:iOS奇迹一个虚幻的花园,但我很确定那不是虚幻的:)尝试打开该文件在一些hexcode显示编辑器-什么Xcode提供可能不同于什么真的包含文件。

  1. ... even something web based

这是对我们很好地展示故事板定位苹果的想法错了一切。译者需要3件事做自己的工作:上下文,上下文和上下文。苹果似乎认为译者很乐意安装应用程序,玩它,并提出问题,以获得上下文。因为,默认情况下,有没有人在XLIFF出口下。现在xcode7,你可以添加注释,但奇怪的是并不是到处都是。即使你能,你的注意是附加在已久的& lt结束;注>;机器上下文匹配可以理解为故事导入所需要的字符串,但无用的和阻塞性的翻译。此外,在现实中,译者是一个专业机构,或语言爱好者。即使你有一个运气与装备齐全的爱好者,或者你支付机构保费获得额外的客户关怀,你进入敌对沙漠贝塔分布选项。苹果的滑稽TestFlight轮回都需要译者以登记作为苹果开发者,或者等待苹果的β-审查-取决于早期的应用程序的生命你需要翻译。

顺便说一句,我喜欢你的博客。有时候我觉得我的酸味和倾销特征疲劳过,但从来没有到你:)

ios8  localization  xcode6  uistoryboard  xliff