gettext的替代品?

问题描述 投票:27回答:4

gettext是否有任何通用的本地化/翻译替代方案?

开源或专有无关紧要。

当我说替代gettext时,我的意思是一个国际化的图书馆,有一个本地化的后端。

我问的原因是因为(除其他外)我发现gettext的方式稍微麻烦和静态,主要是在后端位。

localization internationalization gettext
4个回答
43
投票

首先,我认为gettext是目前最好的之一。

你可以看一下Boost.Locale可能提供更好的API并使用gettext的字典模型:http://cppcms.sourceforge.net/boost_locale/docs/(不是Boost的官方部分,仍然是beta版)。


编辑:

如果你不喜欢gettext ......

这些是翻译技术:

  • OASIS XLIFF
  • GNU gettext po / mo文件
  • POSIX目录
  • Qt ts / tm文件
  • Java属性,
  • Windows资源。

现在:

  • 最后两个完全废话...很难使用翻译和维护,不支持复数形式。
  • Qt ts / tm - 需要使用Qt框架。与gettext有非常相似的模型。不错的解决方案,但仅限于Qt。在通用程序中不太有用。
  • POSIX目录 - 没有人使用它们,没有复数形式支持。废话。
  • OASIX XLIFF - “标准”解决方案,取决于XML,甚至ICU也需要编译到特定的ICU资源以供使用。有限的翻译工具,我不知道任何支持XLIFF的库。多种形式不太容易使用(ICU仅在4.x版本中包含一些支持)。

现在我们有什么?

GNU gettext,广泛使用,有很棒的工具,有很多复数形式支持,在翻译社区很受欢迎......

那么决定,你真的认为gettext不是那么好的解决方案吗?

我不这么认为。您根本没有使用其他解决方案,因此请首先了解它的工作原理。


2
投票

关于gettext()和所有那些pro-gettext()的有趣评论。

我并不是说它在大多数情况下都不能正常工作,但我试图用它来管理一个项目,并且很快就被使用它的硬度所震撼。也许今天有一些翻译用户界面,但我甚至没有看。字符串的提取和合并对我来说不是这样。

现在,我感谢Artyom谈论XLIFF,因为一切都是XML,这对我的环境来说是一个更好的解决方案。哦!那里有优秀的编辑。但如果你喜欢gettext(),你就找不到它们了。 8-)

我建议以这个为例:

https://sourceforge.net/projects/wordforge2/

现在,这可能会给程序员一个噩梦,使其全部工作,但我们想要的是翻译人员的梦想成真(程序员在翻译时没有工作,因为我可以用gettext()告诉你不得不做所有的工作!)


2
投票

Zend还有一个替代方案,支持gettext * .po / * .mo文件和更多格式。许多Apache服务器缓存转换文件,因为gettext是作为模块实现的,必须重新启动服务器才能刷新转换数据。

Zend实现避免了这种情况并支持更多格式:

http://framework.zend.com/manual/1.12/en/zend.translate.html


0
投票

Fluent是一个新系统,提供了许多文本缺乏的适应性。 gettext支持多元化,fluent有文本变体的通用框架。 gettext使用“未翻译”字符串作为其翻译键,fluent支持抽象键(允许多次翻译,恰好在源语言中是同义词.Here is a more extensive comparison

firefox's preferences codebase获取的流畅的.ftl文件示例如下所示:

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

blocklist-window =
    .title = Block Lists
    .style = width: 55em

blocklist-description = Choose the list { -brand-short-name } uses to block online trackers. Lists provided by <a data-l10n-name="disconnect-link" title="Disconnect">Disconnect</a>.
blocklist-close-key =
    .key = w

blocklist-treehead-list =
    .label = List

blocklist-button-cancel =
    .label = Cancel
    .accesskey = C

blocklist-button-ok =
    .label = Save Changes
    .accesskey = S

# This template constructs the name of the block list in the block lists dialog.
# It combines the list name and description.
# e.g. "Standard (Recommended). This list does a pretty good job."
#
# Variables:
#   $listName {string, "Standard (Recommended)."} - List name.
#   $description {string, "This list does a pretty good job."} - Description of the list.
blocklist-item-list-template = { $listName } { $description }

blocklist-item-moz-std-listName = Level 1 block list (Recommended).
blocklist-item-moz-std-description = Allows some trackers so fewer websites break.
blocklist-item-moz-full-listName = Level 2 block list.
blocklist-item-moz-full-description = Blocks all detected trackers. Some websites or content may not load properly.
© www.soinside.com 2019 - 2024. All rights reserved.