10

在 Xcode 6 中,XLIFF 文件格式现在用于字符串的本地化。但是,我需要本地化复数和性别。我怎样才能在 Xcode 6 中做到这一点?

据我了解,XLIFF 文件现在替换了 Localizable.strings 文件。在 iOS 7/OS X 10.9 中,我们可以通过添加 Localizable 来本地化复数和性别。stringsdict但这需要 Localizable.strings 存在。但是既然现在没有 Localisable.strings 文件,我怎样才能让 Localizable.stringsdict 文件工作呢?

4

2 回答 2

11

As of Xcode 6, Apple uses XLIFF as the file format for exporting your project for localization. However, nothing has changed inside the project itself. You should continue using Localisable.strings and Localizable.stringsdict files to handle plurals per Apple's documentation on Handling Noun Plurals and Units of Measurement.

You can refer to this Objective-C project or this Swift project as examples of using strings dictionary files for plurals with Xcode 6.

A little more background on XLIFF and Xcode 6:

XLIFF (XML Localisation Interchange File Format) is an XML-based format created to standardize the way localizable data are passed between tools during a localization process. XLIFF was standardized by OASIS in 2002.

When you click on Editor -> Export for Localization in Xcode, it packages up all of your localizable assets into an XLIFF file that can be handled off to translators for localizing your application's strings. Since XLIFF is a standardized file format, this means translators and translation tools do not need to understand Apple's internal strings format.

Here's an example of the resulting XLIFF document produced by exporting the above referenced Swift project for localization. Now translators can use a translation platform or tool to translate your application's content and return to you a localized XLIFF file. You, as a developer, can then use Xcode's "Import Localizations" feature to import the translated XLIFF file into your project. This will cause Xcode to generate the necessary locale specific strings files from the imported XLIFF.

In short, nothing has changed in how you develop your project. What's been added in Xcode 6 is a new feature to simplify the localization process.

There's one caveat that I should mention though about plurals and exporting for localization. As of Xcode 6.1, Apple's export for localization feature still lacks a way to properly export plurals. This is most likely due to the current XLIFF spec having no standardized way of managing plural representations of a string. There's an open bug with Apple to address this issue.

于 2014-11-14T16:08:49.107 回答
3

从 Xcode 9 开始,XLIFF 导出完全支持复数形式

Xcode 9.0 发行说明

添加了对 XLIFF 导出和导入字符串字典文件的支持,包括支持使用正确的每种语言的复数变体。(16785521)

于 2018-12-12T08:04:33.643 回答