Should you use XLIFF for software localization?

您应该使用XLIFF进行软件本地化吗?

2020-04-08 10:40 Smartcat

本文共1140个字,阅读需12分钟

阅读模式 切换至中文

In this article, we take a look at the pros and cons of one of the most popular formats for storing and handling localized strings to help you decide if it’s a good fit for you. XLIFF - Standard File Format for Translations What does XLIFF look like? Integrating XLIFF into your code XLIFF localization process “What if we are Agile developers?” “Long story short When you’re just starting to develop your app, localization might not seem like something you have to think about much. But this comes at a cost later: As you grow and eventually decide to translate your software to other languages, you might find yourself with a plethora of strings that you have no idea how to deal with in other languages. As a result, you have to invest extra time thinking about what to do, you cannot make quick changes to the localized versions of your app, and end up with low-quality translations because you haven’t provided the translators with the right context to get the job done. To avoid these pains in the future, it’s important to think about localization, or at least internationalization, in the very first phases of development. And the main question is: What localization format should you choose? Below, we take a look at XLIFF, one of the most sophisticated formats for software localization. Unlike JSON and YAML, it is not well-known among software engineers and developers. So, should you still consider using it? Let’s find out. What does XLIFF look like?An OASIS standard, XLIFF — XML Localization Interchange File Format — is the de-facto language industry standard for exchanging localized strings between applications. As such, it has the highest level of support in most translation tools and has the most comprehensive solutions for the most common localization issues. Companies such as Apple and Microsoft choose XLIFF as the basis for their internationalization frameworks. As the name suggests, XLIFF is an XML-based format, meaning that any parser that works with XML will work with XLIFF as well. This makes it easier to use for both translation platforms and for localization libraries. Here’s what a typical XLIFF looks like: The main parts of an XLIFF file are and elements, with the former containing the smallest indivisible “atoms” of text — say, sentences, — and the latter grouping them into bigger, “molecular” elements — say, paragraphs. Each contains the and elements, containing the segment text in the source and target languages, respectively. (Note that, unlike translation memories, an XLIFF file can contain only one target language, so there is no such thing as a “multilingual XLIFF”.) Another important element is , which allows you to add comments that might help translators understand the context. For example, the text “Sign in” can refer to a button title or a window caption, which, in some languages, will mean a different grammatical form should be used in each case. Finally, there’s the id attribute, which allows you to uniquely identify each string in case you’re using key-based internationalization. (The alternative is default language-based internationalization, which has its pros and cons but is generally less popular.) Integrating XLIFF into your codeNow that you know what an XLIFF file looks like and are familiar with its basic elements, it’s time to integrate it into your code. Here’s a list of popular development environments with their level of XLIFF support: Objective C and Swift — used for developing iOS and Mac apps — support XLIFF 1.2 specification via Xcode. XLIFF 2.0 is not supported. Angular also natively supports XLIFF 1.2 but not 2.0. React has a converter between its native format and XLIFF. So does Polymer. Vue does not support XLIFF, and we weren’t able to find any trustworthy libraries that allow conversion between XLIFF and Vue’s i18n plugin. Node.js has plenty of XLIFF packages to choose from. Ruby has a few gems for XLIFF conversion and/or import, too. C#: The XlfParser library can convert XLIFF files to C# resource files. Java and Android both use different approaches to localization but can utilize the OpenXLIFF set of filters to process XLIFF files. Python has very few XLIFF packages, and it is not clear if they are well-maintained. So what are your options if your development platform does not support XLIFF? The first one is obvious: Don’t use XLIFF. Although it is indeed the most standardized and well-thought-out localization format, modern translation tools such as Smartcat can easily work with other file formats, be it Android XML, JSON or even YAML. The second option is to use a standalone converter such as the already mentioned OpenXLIFF — or write one yourself. After all, XLIFF is nothing but an XML, and there are plenty of libraries that support working with XML files for any language and environment out there. Finally, you can use different formats for different environments while synchronizing their translations during localization using translation memories. XLIFF localization processNow that we have our internationalization framework built around XLIFF, you probably want to translate these strings. To have an XLIFF file translated, you first need to open it with an XLIFF editor or translation tool. Below, we show you how this is done in Smartcat. So, first you upload your XLIFF file: You can then invite and assign people to translate your strings to the target languages. (Smartcat has no limits on the number of users.) These can be your own in-house specialists, your community members, or freelancers you invite from Smartcat’s marketplace. Each translator will see the document in a bilingual editor, with source elements on the left and target elements on the right: Once they have entered all the translated text, you can download the XLIFF file again and push it to your repository.“What if we are Agile developers?”Now, if your company has adopted an Agile development process you might not want to waste time manually pulling your XLIFFs, having them translated, and pushing them back to the repository. You can configure a continuous localization process, where strings are synced automatically between your repo and the translation tool of your choice. In the case of Smartcat, this is done through a Serge+Smartcat bundle. What sort of results can you expect? Well, Kaspersky was able to cut their hours of localization by six, so you decide. Long story shortThough verbose and sometimes obscure compared to, say, JSON or YAML, XLIFF can boast the biggest support among translation tools. So if you want to approach software localization systematically and consistently, spending the extra time setting up an effective XLIFF localization process can pay back and produce faster and higher-quality translations in the long run. What do you use? Are you going to give XLIFF a go? Let us know in the comments!
在本文中,我们将查看存储和处理本地化字符串的最流行格式之一的利弊,以帮助您确定它是否适合您。 XLIFF-翻译的标准文件格式 XLIFF是什么样子的? 将XLIFF集成到代码中 XLIFF本地化过程 “如果我们是敏捷开发人员呢?” “长话短说 当你刚刚开始开发你的应用程序时,本地化似乎不是你必须考虑的事情。 但这是有代价的:随着您的成长并最终决定将软件翻译成其他语言,您可能会发现自己遇到了大量的字符串,而您不知道如何在其他语言中处理这些字符串。 因此,你必须投入额外的时间来思考该做什么,你不能快速地对你的应用程序的本地化版本进行更改,并且最终得到低质量的翻译,因为你没有为翻译人员提供正确的上下文来完成工作。 为了避免将来的这些痛苦,在开发的最初阶段就考虑本地化,或者至少考虑国际化是很重要的。 而主要的问题是:你应该选择什么样的本地化格式? 下面,我们来看看XLIFF,它是软件本地化的最复杂的格式之一。 与JSON和YAML不同,它在软件工程师和开发人员中并不知名。 那么,你是否还应该考虑使用它呢? 让我们一探究竟。 XLIFF是什么样子的?一个OASIS标准,XLIFF-XML本地化交换文件格式-是在应用程序之间交换本地化字符串的事实上的语言行业标准。 因此,它在大多数翻译工具中具有最高级别的支持,并且对于最常见的本地化问题具有最全面的解决方案。 苹果和微软等公司选择XLIFF作为其国际化框架的基础。 顾名思义,XLIFF是一种基于XML的格式,这意味着任何使用XML的解析器也将使用XLIFF。 这使得它更容易用于翻译平台和本地化库。 下面是典型的XLIFF的样子: XLIFF文件的主要部分是元素,前者包含最小的不可分割的文本“原子”--比如句子,后者将它们分组为更大的“分子”元素--比如段落。 每个包含元素,分别包含源语言和目标语言中的段文本。 (请注意,与翻译存储器不同,XLIFF文件只能包含一种目标语言,因此不存在“多语言XLIFF”这一说法。) 另一个重要元素是,它允许您添加注释,以帮助翻译人员理解上下文。 例如,文本“登录”可以指按钮标题或窗口标题,在某些语言中,这意味着在每种情况下应使用不同的语法形式。 最后,还有id属性,它允许您在使用基于键的国际化时唯一地标识每个字符串。 (另一种选择是基于默认语言的国际化,它有其优点和缺点,但通常不那么受欢迎。) 将XLIFF集成到您的代码中既然您知道XLIFF文件是什么样子的,并且熟悉它的基本元素,那么是时候将它集成到您的代码中了。 下面列出了一些流行的开发环境及其XLIFF支持级别: Objective C和Swift-用于开发iOS和Mac应用程序-通过Xcode支持XLIFF1.2规范。 不支持XLIFF 2.0。 Angular还支持XLIFF1.2,但不支持2.0。 React在其原生格式和XLIFF之间有一个转换器。 聚合物也是。 Vue不支持XLIFF,我们也找不到任何值得信任的库来允许XLIFF和Vue的i18n插件之间的转换。 node.js有大量的XLIFF包可供选择。 Ruby也有一些用于XLIFF转换和/或导入的gem。 C#:XlfParser库可以将XLIFF文件转换为C#资源文件。 Java和Android都使用不同的本地化方法,但是可以利用OpenXLIFF过滤器集来处理XLIFF文件。 Python的XLIFF包很少,而且还不清楚它们是否得到了很好的维护。 那么,如果您的开发平台不支持XLIFF,您有什么选择呢? 第一条很明显:不要使用XLIFF。 虽然它确实是最标准化,最深思熟虑的本地化格式,但像Smartcat这样的现代翻译工具可以轻松地与其他文件格式一起工作,无论是Android XML,JSON,甚至是YAML。 第二种选择是使用一个独立的转换器,比如前面提到的OpenXLIFF-或者自己编写一个。 毕竟,XLIFF只不过是一种XML,而且有很多库支持在任何语言和环境中使用XML文件。 最后,您可以对不同的环境使用不同的格式,同时在使用翻译存储器进行本地化期间同步它们的翻译。 XLIFF本地化过程既然我们有了围绕XLIFF构建的国际化框架,您可能想要翻译这些字符串。 要翻译XLIFF文件,首先需要用XLIFF编辑器或翻译工具打开它。 下面,我们将向您展示如何在Smartcat中实现这一点。 因此,首先上传XLIFF文件: 然后,您可以邀请并指派人员将您的字符串翻译为目标语言。 (Smartcat对用户数量没有限制。) 这些人可以是您自己的内部专家,您的社区成员,或者您从Smartcat的市场邀请的自由职业者。 每个翻译人员将在双语编辑器中看到文档,左侧是源元素,右侧是目标元素: 一旦他们输入了所有的翻译文本,您就可以再次下载XLIFF文件并将其推送到您的存储库中。“如果我们是敏捷开发人员呢?”现在,如果您的公司采用了敏捷开发流程,您可能不想浪费时间手动拉出XLIFF,将其翻译并推回到存储库中。 您可以配置一个连续的本地化过程,其中字符串在您的repo和您选择的翻译工具之间自动同步。 对于Smartcat,这是通过serge+Smartcat包完成的。 你能期待什么样的结果? 卡巴斯基把他们的本地化时间缩短了6个小时,所以你决定吧。 长话短说尽管与JSON或YAML相比,XLIFF冗长且有时晦涩难懂,但XLIFF在翻译工具中拥有最大的支持。 因此,如果您想要系统地和一致地进行软件本地化,那么花费额外的时间建立一个有效的XLIFF本地化过程可以得到回报,并且从长远来看可以产生更快和更高质量的翻译。 你用什么? 你要给XLIFF一个机会吗? 在评论中让我们知道!

以上中文文本为机器翻译,存在不同程度偏差和错误,请理解并参考英文原文阅读。

阅读原文