gettext 的替代品?
gettext 是否有任何通用的本地化/翻译替代方案?
开源或专有并不重要。
当我说 gettext 的替代品时,我指的是一个具有本地化后端的国际化库。
我问的原因是因为(除其他外)我发现 gettext 做事的方式有点麻烦和静态,主要是在后端位。
Are there any general localization/translation alternatives to gettext?
Open source or proprietary doesn't matter.
When I say alternative to gettext, I mean a library for internationalization, with a localization backend of sorts.
The reason I'm asking is because (among other things) I find the way gettext does things slightly cumbersome and static, mostly in the backend bit.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
首先,我认为
gettext
是目前最好的之一。您可以查看
Boost.Locale
,它可能提供更好的 API 并使用gettext
的字典模型:http://cppcms.sourceforge.net/boost_locale/docs/(不是 Boost 的官方部分,仍为测试版)。编辑:
如果您不喜欢
gettext
...这些是翻译技术:
现在:
gettext
具有非常相似的模型。不错的解决方案,但仅限于 Qt。在通用程序中不太有用。现在我们有什么?
GNU
gettext
,广泛使用,有很棒的工具,有很好的复数形式支持,在翻译社区中很受欢迎......所以决定,你真的认为 gettext 不是很好的解决方案吗?
我不这么认为。您根本没有使用过其他解决方案,因此首先尝试了解它是如何工作的。
First of all I think
gettext
is one of the best at this point.You may take a look on
Boost.Locale
that may provide a better API and usegettext
's dictionary model: http://cppcms.sourceforge.net/boost_locale/docs/ (not official part of Boost, still beta).Edit:
If you don't like
gettext
...These are translation technologies:
Now:
gettext
. Not bad solution, but limited to Qt. Not so useful in generic programs.Now what do we have?
GNU
gettext
, widely used, has great tools, has great plural forms support, very popular in translators community...So decide, do you really think that gettext is not so good solution?
I don't think so. You haven't worked with other solutions at all, so try to understand how it works at first place.
Fluent 是一个新系统,它提供了 gettext 所缺乏的许多适应性。 gettext 支持复数形式,而 Fluent 则为文本变体提供了通用框架。 gettext 使用“未翻译”字符串作为其翻译键,而 Fluent 支持抽象键(允许对源语言中恰好同名的内容进行多种翻译。 这里有更广泛的比较。Fluent
.ftl 文件的示例,取自 firefox 的首选项代码库,如下所示:
Fluent is a new system that offers a number of adaptations that gettext lacks. Where gettext supports pluralization, fluent has a generic framework for the text variants. Where gettext uses the "untranslated" string as its translation key, fluent supports an abstract key (allowing multiple translations for something that just happens to be homonymous in the source language. Here is a more extensive comparison.
An example of fluent .ftl file, taken from firefox's preferences codebase, looks like this:
关于 gettext() 和所有支持 gettext() 的有趣评论。
我并不是说它在大多数情况下都不能正常工作,但我尝试用它来管理一个项目,但很快就对使用它的难度感到不知所措。也许今天有一些供翻译人员使用的用户界面,但我什至没有看。字符串的提取和合并并不适合我。
现在,我感谢 Artyom 谈论 XLIFF,这对我的环境来说是一个更好的解决方案,因为一切都是 XML。哦!那里有优秀的编辑。但如果您喜欢 gettext(),您将找不到它们。 8-)
我建议看看这个:
https://sourceforge.net/projects/wordforge2/现在
,这可能会给程序员带来一场噩梦,让一切顺利进行,但我们想要的是翻译人员的梦想成真(随着翻译的涌入,程序员的工作量为零,因为我可以告诉你, gettext() 我必须完成所有工作!)
Interesting comments about gettext() and all those pro-gettext().
I'm not saying that it ain't working right in most cases, but I tried to manage one project with it and quickly felt overwhelm by the hardness of using it. Maybe there are a few user interfaces for translators today, but I did not even look. The extraction and merging of strings is just not doing it for me.
Now, I thank you Artyom for talking about XLIFF which is a much better solution for my environment since everything is XML. Oh! And there are excellent editors out there. But if you like gettext() you won't find them. 8-)
I'll suggest looking at this one for example:
https://sourceforge.net/projects/wordforge2/
Now, this may give the programmer a nightmare to make it all work, but what we want is a dream come true for the translators (and zero work by the programmer as translations pour in, because I can tell you that with gettext() I had to do all the work!)
Zend 有一个替代方案,支持 gettext *.po / *.mo 文件和更多格式。
许多 Apache 服务器会缓存翻译文件,因为 gettext 是作为模块实现的,并且必须重新启动服务器才能刷新翻译数据。
Zend 实现避免了这种情况并支持更多格式:
http://framework。 zend.com/manual/1.12/en/zend.translate.html
There is an alternative from Zend that supports gettext *.po / *.mo files and many more formats.
Many Apache servers cache the translation files because gettext is implemented as a module and the server has to be restarted to refresh the translation data.
The Zend implementation avoids this and supports many more formats:
http://framework.zend.com/manual/1.12/en/zend.translate.html