An Overview of The 5 Most Common #i18n Gremlins

论5种最常见国际化小精灵

2020-09-26 03:00 Lingua Greca

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

阅读模式 切换至中文

I18n Gremlins come in many nasty and disruptive forms. Maybe a concatenated or embedded string. Perhaps the date format shows up wrong or you see square boxes and gobbledegook in your user interface. They are annoying bugs for localized products that detract from your product quality for worldwide users. Typically, they are found late in a development cycle and sometimes sit for months to years in bug tracking backlogs. But you can find these Gremlins and eliminate them as code is being written, when internationalization (i18n) is fast and easy to fix. Let me explain. When developers are creating new products and features, it is easy to inadvertently add i18n Gremlin issues. Some are pretty obvious, like embedding a string (messages in a product interface), rather than using a locale framework and a key, so that words that will need to be translated are all in resource files. It’s one of the most basic practices for i18n – writing software that can be quickly and efficiently translated for worldwide customers. Other i18n Gremlins are a bit more complex. For instance, embedding a font that might work fine in English but is illegible in Chinese, or forgetting to pass locale into a calendar class. We came up with the term Gremlins because, like the mythical sprites they remain hidden and cause sabotage. i18n Gremlins aren’t immediately obvious and often are not found until later, when it costs much more in time and distraction to locate the gremlins’ source and fix the issues. Here are some of the fundamental areas of i18n Gremlins that Lingoport’s Globalyzer software will detect as developers write software: 1. Concatenations Issues: It’s like an Embedded String which cannot be externalized as such. In many languages the word order is likely to be different, so translations will read terribly. The string first needs some redesign. This one comes in all kinds of shapes and sizes. Here is a concatenation example: “Welcome ” + username + ” to our Rebel Outfitter store” Remedy: The typical remedy is to create a parameterized strings and keep the parameter variables outside of the string itself. For instance, the parameterized string may look like “Welcome %{userName} to our Rebel Outfitter store”. 2. Embedded Strings Issues: When you change locale, the string stays the same. The string was hard-coded in the application and is resistant to locale changes. For example if there was simple code that looks like: String d =”All the young ones”; String e =”Having a good time”; Remedy: Externalize the Embedded String from the source code. Generate a Key/Value pair in a resource file, refer to that key in the code to retrieve the value. The value is the string itself. With your locale framework, you can then retrieve the string from a locale dependent resource file. When the string is externalized, the code looks like: String d =getString(“JAVA_TESTSTR_105”); String e =getString(“JAVA_TESTSTR_106”); And the key/value pair in the resource file looks like: JAVA_TESTSTR_105=All the young ones JAVA_TESTSTR_106=Having a good time 3. Locale Sensitive Methods There can be hundreds o these locale sensitive methods, functions and classes depending upon the programming language. They effect issues like date formatting, numerical formatting, character encoding, currency handling, measurements and more. Here are some examples: Date/Time Format Issues: The application may look right but provides the wrong information. If the date shown is 05/06/07 independently of the locale, it means: May 6, 2007 for an American June 5, 2007 for a Frenchman 2005, June 7 for a Japanese Remedy: The application needs to format the data based on the user’s locale and, for instance, show May 6, 2007 as 05/06/07 to an American user 06/05/07 to a French user 07/06/05 to a Japanese user In addition, the date/time may be displayed using Time Zone. The entity or value itself may need to be a GMT date / time. Currency Format Issues: The application displays the same amount whatever the locale/region of the user. For instance, a Canadian user sees $5000 and may think that in Canadian dollars when it’s in US Dollars. Remedy: The application needs to format the number, display the symbol, and most likely use some exchange rate to display the actual currency amount for the user’s language / region. 4. General Patterns Issues: This gremlin may take the form of an encoding like ISO8859-1 when UTF-8 is required, or set a font that cannot be used in Chinese, even decides a format output. Remedy: Make sure to check for each pattern to decide if it is a General Pattern, if more need to be added to your specific application, and how to refactor the code. 5. Static Files Issues: The application serves the same file, maybe a video or a legal HTML file, independently of the locale. For example, a Chinese video is shown to a Russian application user. For example: placemarkAttributes.imageSource = “./img/marker.png”; Remedy: The locale framework needs to provide for an internationalization way to refer to the file so that a locale with a static file name will result in serving a Russian video to the Russian user. All of these types of Gremlins are quickly and easily found using Globalyzer, which can detect i18n Gremlins in a number of ways: In the developer’s IDE – A developer can add Globalyzer i18n detection to their development environment and see i18n issues as they work. During commits or pull requests: As a developer submits her day’s work, a Globalyzer scan can run automatically illustrating any i18n issues. That makes it easy to fix any i18n issues that can arise and then move on. Dashboards for specific repositories, entire development products, or software across your enterprise – gives a broad view of i18n readiness, while also enabling issue drill downs, assignments and other management features. —————————————– Learn more about i18n Gremlins: Webinar Recording: https://lingoport.com/webinar-common-i18n-Gremlins-and-how-to-squash-them/ To see what Gremlins look like within an example application visit: https://rebel.lingoport.com/RebelOutfitters.DarkSide/. Look for the little gremlin characters throughout the site and hover your mouse over them to investigate further. And for a dashboard view see: https://sandbox.lingoport.com/project/extension/lingoport/overview_page?id=RebelOutfitters.DarkSide%3Ascan&qualifier=TRK There are other problems of course that our software suite will solve for you, so that you localization is fast and in tune with software development. To discuss your own localization process, continuous localization and Linguistic QA, please reach out to Gremlins@lingoport.com. Share on Facebook Share on Twitter Share on Google+ Share on Pinterest Share on Linkedin Share on Tumblr Share on Vk Share on Reddit Share by Mail
小精灵捣乱时会显示出许多令人讨厌的内容。可能是一连串连续或嵌入的字符,也可能是日期格式显示错误,或者用户界面显示各种方框和令人费解的内容。 它们是本地化产品造成的各种烦人的漏洞,这些漏洞会降低全球用户的产品质量。通常是在开发周期的后期发现它们的存在,有时会在 漏洞跟踪积压中存留数月或甚至数年。但是您可以在编写代码时发现这些小精灵并消灭它们,此时国际化(i18n)是非常快速地修复它们的。 我来解释一下。当开发人员正在开发新产品和产品功能时,很容易在不经意间添加国际化小精灵漏洞。有些非常明显,比如嵌入一个字符串(产品界面中的消息),而不是使用语言框和密钥,因此需要翻译的单词都在资源文件中。这是国际化编写软件使用的最基本操作之一,可以为全球客户快速高效地翻译。还有一些国际化小精灵要稍微复杂一些。例如,嵌入一种字体,这种字体在英文中可以正常识别,但在中文中却难以辨认,或者忘记将语言环境传递到日历类中。 我们之所以想出“小精灵”这个词,是因为它们就像神话中的小精灵一样,总是隐藏在暗处,然后造成破坏。这些小精灵并不是立即就能发现的,而且通常要等到以后才会发现,这时要找到小妖精的来源并解决问题需要花费更多的时间和精力。 以下是Lingoport的Globalyzer软件在开发人员编写软件时检测到的一些国际化小精灵存在的普遍位置: 1.字符串 问题:这些小精灵就像一个不能具体化的嵌入式字符串。在许多语言中,由于词序可能存在不同,因此翻译起来会非常麻烦。字符串首先需要重新设计,它有各种形状和大小。下面是一个示例:“welcome”+username+“to our Rebel Outfitter store” 解决:典型的解决方法是创建参数化的字符串,并将参数变量保留在字符串本身之外。例如,参数化的字符串可能看起来像“welcome%{userName}to our Rebel Outfitter Store”。 2.嵌入字符串 问题:当你更改语言环境时,字符串会保持不变。因为该字符串在应用程序进行了硬编码,并且可以预防语言环境的更改。例如,简单的代码如下所示: String d =”All the young ones”; String e =”Having a good time”; 解决 :将源代码中的嵌入字符串具体化,在资源文件中生成一个键/值对,在代码中引用该键来检索值。该值就是字符串本身。使用您的语言环境框,就可以从语言环境相关的资源文件中检索字符串。 当字符串具体化时,代码如下所示: String d =getString(“JAVA_TESTSTR_105”); String e =getString(“JAVA_TESTSTR_106”); 资源文件中的键/值对如下所示: JAVA_TESTSTR_105=All the young ones JAVA_TESTSTR_106=Having a good time 3.语言环境敏感的方法 根据编程语言的不同,可以有成百上千的这些对语言环境敏感的方法,如函数和类。它们会影响诸如日期格式、数字格式、字符编码、货币处理、度量等问题。下面是一些例子: 日期/时间格式 问题:该应用程序看上去可能正确,但是提供了错误的信息。 如果显示的日期是07年5月6日(独立于语言环境),则表示: May 6, 2007 for an American June 5, 2007 for a Frenchman 2005, June 7 for a Japanese 解决 :应用程序需要根据用户的语言环境来格式化数据,例如,将2007年5月6号显示为 05/06/07 to an American user 06/05/07 to a French user 07/06/05 to a Japanese user 此外,可以使用时区来显示日期/时间。实体或价值本身可能需要是GMT日期/时间。 货币格式 问题:无论用户的语言环境如何,应用程序都会显示相同的数额。 例如,一个加拿大用户看到5000美元,可能会认为是加元,但实际是美元。 解决 :应用程序需要格式化数字,显示符号,并且很可能使用某种汇率来显示用户语言/区域的实际货币数量。 4.一般模式 问题:当需要UTF-8时,小精灵可能采用类似ISO8859-1的编码形式,或者设置无法在中文中使用的字体,甚至决定格式输出。 解决:确保检查每个模式,以确定它是否是通用模和是否需要将向特定的应用程序添加更多,以及如何重构代码。 5.静态文件 问题:应用程序提供相同的文件,可以是视频也可以是合法的HTML文件,独立于语言环境。例如,一个中国视频被展示给一个俄罗斯应用程序用户。例如: PlaceMarkAttributes.imagesource=“。/img/marker.png”; 解决:语言环境框架需要提供一种国际化的方式来引用文件,这样一个具有静态文件名的语言环境将为俄罗斯用户提供一个俄语视频。 使用Globalyzer可以快速,轻松地找到所有这些类型的小精灵, 它可以通过多种方式检测国际化小精灵: 在开发人员的IDE中——开发人员可以将国际化Globalyzer 检测添加到他们的开发环境中,并在国际化问题运行时查看它们。 在提交或请求期间:开发人员提交不能工作时,Globalyzer扫描就会自动运行,说明任何国际化问题。 这样可以轻松解决可能出现的任何国际化问题,然后继续运行下去。 针对特定存储库、整个开发产品或整个企业的软件的仪表板——提供了关于国际化准备情况的广泛视图,同时还支持问题挖掘、分配和其他管理特性。 ------------- 了解有关国际化小精灵的更多信息: Webinar Recording: https://lingoport.com/webinar-common-i18n-Gremlins-and-how-to-squash-them/ 要查看示例应用程序中的Gremlins是什么样子,请访问:https://rebel.lingoport.com/rebeloutfitters.darkside/。在网站上搜小妖精,并将鼠标悬停在它们上方,进一步搜索。 有关仪表板视图,请参阅:https://sandbox.lingoport.com/project/extension/lingoport/overview_page?id=rebeloutfitters.darkside%3ascan&qualifier=trk 当然,我们的软件套件还会为您解决其他问题,这样您的本地化速度就会更快,并与软件开发保持一致。如果您想讨论您自己的本地化过程、持续本地化和语言QA,请联系Gremlins@lingoport.com。 在Facebook上共 享 在Twitter上共享 在Google+上共享 在Pinterest上共享 在Linkedin上共 享 在Tumblr上共 享 在Vk上共享 在Reddit上共享 通过邮件共享

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

阅读原文