用于国际化的 Java 和 GNU gettext
有人有过使用 GNU gettext 进行国际化开发大型 Java 应用程序的经验吗? 我发现我真的很喜欢在源代码中包含英文文本,但我想确保我所做的对于我所在的相对较大的软件项目来说是实用的。
如果您有这方面的经验,您使用什么来查找 Java 中的资源? 我目前正在尝试 Gettext Commons (http://code.google.com/p/gettext -commons/),到目前为止似乎运行良好。
除了 gettext 之外,还有其他方法可以将原始文本保留在源代码中吗? 如果有 Windows 支持的类似工具就太好了。
Has anyone had any experiences developing large Java applications using GNU gettext for internationalization? I find that I really like having the English text in my source code, but I want to make sure that what I'm doing is practical for the relatively large software project I am part of.
If you have experience with this, what are you using to look up the resources in Java? I'm currently trying out Gettext Commons (http://code.google.com/p/gettext-commons/), which seems to be working well so far.
Any alternatives to gettext that keep the original text in your source code? A similar tool that is supported on Windows would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
JSOM 开源 OpenStreetMap Java 编辑器项目正在使用 Gettext 库来处理其所有翻译,并且效果非常好人们可以使用各种翻译工具(如 KBabel、poedit、launchpad...)来处理 po 文件,因此没有平台限制。
另外,我不太明白为什么您认为上述设置不能在任何平台上使用 - 您当然可以在 Windows 中使用 gettext,请参阅: 此处 或此处
考虑到 gettext 的流行程度,我当然会推荐它。
The JSOM open source OpenStreetMap Java editor project is using the Gettext library to handle all its translations and it is working out very well as people are able to use a variate of translation tools (like KBabel, poedit, launchpad...) to work with the po files so there is no platform constraint there.
Also I don't quite see why you think the mentioned setup cannot be used on any platform - you can certainly use gettext in Windows see: here or here
Given how popular gettext is I would certainly recommend it.
您可以只使用 普通旧 Java 消息资源包 相反。
编辑:嗯,我们的开发团队真正使用的是标准的 TMX 格式 允许您在 XML 文件中指定本地化字符串。 它是翻译工具常用的格式。 这是一个免费的,它可以让您更轻松地编辑这些文件。
尽管如此,我之前没有提到过它,因为它没有比消息资源包提供任何真正的优势或功能,除了借助 XML 处理工具提供更好的编码处理(在处理不同语言的国际化文字时,编码可能是一个真正的痛苦)为英语)。
此外,我们真正使用的是我们自己的软件框架,它可以解析此 XML 格式,并让我们可以在语言之间进行更改(在 HTML 页面或 Swing 框架中),而无需重新启动应用程序。 开发一个以这种方式处理直译的简单库并不难,但缺点是您必须实现它。
You could just use plain old Java message resource bundles instead.
Edit: Well, what we really use in our development team is the standard TMX format that lets you specify localization strings in XML files. It is a format commonly used by translation tools. Here is a free one, that lets you edit these files more easily.
Nonetheless I have not mentioned it before because it does not offer any real advantage or functionality over message resource bundles, except for a better encoding handling thanks to XML processing tools (encoding can be a real pain in the neck when handling internationalized literals in languages different to English).
Moreover what we really use is our software is our own framework that parses this XML format and let us change between languages (in HTML pages or Swing frames) without restarting our applications. It is not that hard to develop a simple library that handles literal translations this way, but the downside is that you must implement it.