项目国际化 [英] Internationalization in your projects

查看:21
本文介绍了项目国际化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您是如何在您从事的实际项目中实施国际化 (i18n) 的?

How have you implemented Internationalization (i18n) in actual projects you've worked on?

在阅读了 Joel 的著名文章 The绝对最低要求每个软件开发人员都绝对、肯定地必须了解 Unicode 和字符集(没有任何借口!).但是,除了确保尽可能使用 Unicode 字符串之外,我还没有能够在实际项目中利用这一点.但是,将所有字符串设为 Unicode 并确保您了解所使用的所有内容的编码方式只是 i18n 的冰山一角.

I took an interest in making software cross-cultural after I read the famous post by Joel, The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!). However, I have yet to able to take advantage of this in a real project, besides making sure I used Unicode strings where possible. But making all your strings Unicode and ensuring you understand what encoding everything you work with is in is just the tip of the i18n iceberg.

迄今为止,我所做的一切都是为一群受控的美国英语人士使用,或者 i18n 只是在推动项目上线之前我们没有时间进行工作.因此,我正在寻找人们关于使软件在现实世界项目中更加本地化的任何技巧或战争故事.

Everything I have worked on to date has been for use by a controlled set of US English speaking people, or i18n just wasn't something we had time to work on before pushing the project live. So I am looking for any tips or war stories people have about making software more localized in real world projects.

推荐答案

已经有一段时间了,所以这里不全面.

It has been a while, so this is not comprehensive.

字符集

Unicode 很棒,但你不能忽略其他字符集.Windows XP(英文)上的默认字符集是 Cp1252.在网络上,您不知道浏览器会向您发送什么(尽管希望您的容器能够处理大部分内容).当您使用的任何实现中存在错误时,请不要感到惊讶.当字符集在机器之间移动时,它们可以与文件名进行有趣的交互.

Unicode is great, but you can't get away with ignoring other character sets. The default character set on Windows XP (English) is Cp1252. On the web, you don't know what a browser will send you (though hopefully your container will handle most of this). And don't be surprised when there are bugs in whatever implementation you are using. Character sets can have interesting interactions with filenames when they move to between machines.

翻译字符串

一般来说,译员不是编码员.如果您将源文件发送给翻译人员,他们会破坏它.应将字符串提取到资源文件(例如 Java 中的属性文件或 Visual C++ 中的资源 DLL).应该为翻译者提供难以破解的文件和不会让他们破解的工具.

Translators are, generally speaking, not coders. If you send a source file to a translator, they will break it. Strings should be extracted to resource files (e.g. properties files in Java or resource DLLs in Visual C++). Translators should be given files that are difficult to break and tools that don't let them break them.

翻译人员不知道产品中字符串的来源.没有上下文就很难翻译字符串.如果不提供指导,翻译质量就会受到影响.

Translators do not know where strings come from in a product. It is difficult to translate a string without context. If you do not provide guidance, the quality of the translation will suffer.

在上下文的主题上,您可能会看到多次出现相同的字符串foo",并认为让 UI 中的所有实例都指向相同的资源会更有效.这是一个坏主意.在某些语言中,单词可能对上下文非常敏感.

While on the subject of context, you may see the same string "foo" crop up in multiple times and think it would be more efficient to have all instances in the UI point to the same resource. This is a bad idea. Words may be very context-sensitive in some languages.

翻译字符串需要花钱.如果您发布产品的新版本,则恢复旧版本是有意义的.拥有从旧资源文件中恢复字符串的工具.

Translating strings costs money. If you release a new version of a product, it makes sense to recover the old versions. Have tools to recover strings from your old resource files.

应尽量减少字符串连接和手动操作字符串.在适用的情况下使用格式函数.

String concatenation and manual manipulation of strings should be minimized. Use the format functions where applicable.

翻译人员需要能够修改热键.Ctrl+P为英文打印;德国人使用 Ctrl+D.

Translators need to be able to modify hotkeys. Ctrl+P is print in English; the Germans use Ctrl+D.

如果您的翻译过程需要有人随时手动剪切和粘贴字符串,那您就是在自找麻烦.

If you have a translation process that requires someone to manually cut and paste strings at any time, you are asking for trouble.

日期、时间、日历、货币、数字格式、时区

这些都可能因国家/地区而异.逗号可用于表示小数位.时间可能是 24 小时制.不是每个人都使用公历.你也需要明确.如果您注意在您的网站上将日期显示为美国的 MM/DD/YYYY 和英国的 DD/MM/YYYY,除非用户知道您已经这样做了,否则这些日期是不明确的.

These can all vary from country to country. A comma may be used to denote decimal places. Times may be in 24hour notation. Not everyone uses the Gregorian calendar. You need to be unambiguous, too. If you take care to display dates as MM/DD/YYYY for the USA and DD/MM/YYYY for the UK on your website, the dates are ambiguous unless the user knows you've done it.

尤其是货币

类库中提供的 Locale 函数将为您提供当地货币符号,但您不能只将英镑(英镑)或欧元符号放在以美元为单位的值前面.

The Locale functions provided in the class libraries will give you the local currency symbol, but you can't just stick a pound (sterling) or euro symbol in front of a value that gives a price in dollars.

用户界面

布局应该是动态的.不仅字符串在翻译时可能会加倍长度,而且整个 UI 可能需要反转(希伯来语;阿拉伯语),以便控件从右到左运行.那是在我们到达亚洲之前.

Layout should be dynamic. Not only are strings likely to double in length on translation, the entire UI may need to be inverted (Hebrew; Arabic) so that the controls run from right to left. And that is before we get to Asia.

翻译前测试

  • 对代码使用静态分析来定位问题.至少,利用 IDE 中内置的工具.(Eclipse 用户可以转到 Window > Preferences > Java > Compiler > Errors/Warnings 并检查非外部化字符串.)
  • 通过模拟翻译进行烟雾测试.解析资源文件并将字符串替换为长度加倍并插入时髦字符的伪翻译版本并不难.您不必说一种语言就可以使用外国操作系统.现代系统应该允许您以具有翻译字符串和外国语言环境的外国用户身份登录.如果您熟悉您的操作系统,您可以在不知道该语言的一个单词的情况下弄清楚什么是什么.
  • 键盘映射和字符集参考非常有用.
  • 虚拟化在这里非常有用.

非技术问题

有时您必须对文化差异保持敏感(可能会导致冒犯或不理解).您经常看到的一个错误是使用标志作为选择网站语言或地理位置的视觉提示.除非您希望您的软件在全球政治中表明立场,否则这是一个坏主意.如果您是法国人并且提供了带有圣乔治国旗的英语选项(英格兰的国旗是白色区域上的红十字),这可能会导致许多说英语的人感到困惑 - 假设外语和国家也会出现类似的问题.图标需要经过文化相关性的审查.竖起大拇指或绿色勾号是什么意思?语言应该是相对中性的 - 以特定方式称呼用户在一个地区可能是可以接受的,但在另一个地区被认为是粗鲁的.

Sometimes you have to be sensitive to cultural differences (offence or incomprehension may result). A mistake you often see is the use of flags as a visual cue choosing a website language or geography. Unless you want your software to declare sides in global politics, this is a bad idea. If you were French and offered the option for English with St. George's flag (the flag of England is a red cross on a white field), this might result in confusion for many English speakers - assume similar issues will arise with foreign languages and countries. Icons need to be vetted for cultural relevance. What does a thumbs-up or a green tick mean? Language should be relatively neutral - addressing users in a particular manner may be acceptable in one region, but considered rude in another.

资源

C++ 和 Java 程序员可能会发现 ICU 网站很有用:http://www.icu-project.org/

C++ and Java programmers may find the ICU website useful: http://www.icu-project.org/

这篇关于项目国际化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆