如何让 Xcode 6 生成的 XLIFF 文件导入回 Xcode - 重命名是不够的

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26346003/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 05:51:51  来源:igfitidea点击:

How to get Xcode 6 generated XLIFF files to import back into Xcode - renaming is not enough

iosxcodelocalizationxcode6xliff

提问by ToddB

How to export a base development language XLIFF file from Xcode 6 and then re-import it to configure additional localizations. (E.g. export en.xlifffile and use it to create fr.xlifffile if you want to add French to an English development language project)

如何从 Xcode 6 导出基本开发语言 XLIFF 文件,然后重新导入它以配置其他本地化。(例如en.xlifffr.xliff如果您想将法语添加到英语开发语言项目中,则导出文件并使用它来创建文件)

回答by ToddB

I am posting this as an "answer your own question" because I spent hours trying to figure this out and as far as I can tell Apple hasn't documented it.

我将此作为“回答你自己的问题”发布,因为我花了几个小时试图弄清楚这一点,据我所知,Apple 还没有记录下来。

The Apple documentation implies it should be sufficient to rename an exported base language XLIFF with a language prefix to be able to import. I.e. if the base localization is English, you should be able to create a file that you can import for French localization just by renaming it from en.xliffto fr.xliff.

Apple 文档暗示将导出的基本语言 XLIFF 重命名为能够导入的语言前缀就足够了。也就是说,如果基本定位是英语,你应该能够仅仅通过重新命名它创建一个文件,你可以导入法国本地化en.xlifffr.xliff

Renaming the file is not enough. You also need to add a target-languageattribute to every fileelement.

重命名文件是不够的。您还需要target-language为每个file元素添加一个属性。

From this:

由此:

<file original="MyApp/MyApp-Info.plist" source-language="en" datatype="plaintext">

<file original="MyApp/MyApp-Info.plist" source-language="en" datatype="plaintext">

To this:

对此:

<file original="MyApp/MyApp-Info.plist" source-language="en" datatype="plaintext" target-language="fr">

<file original="MyApp/MyApp-Info.plist" source-language="en" datatype="plaintext" target-language="fr">

Now you can import the file to Xcode and it will create the new localization

现在您可以将文件导入 Xcode,它将创建新的本地化