gettext的替代品?

Tor*_*amo 27 localization gettext internationalization

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

开源或专有无关紧要.

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

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

Art*_*yom 43

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

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


编辑:

如果你不喜欢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不是那么好的解决方案吗?

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

  • 看,这是我正在寻找的答案.一些实际的选择.如果它们好或坏都无关紧要,只要我能看到不同的做事方式.显然没有那么多,但这不是重点.;) (7认同)
  • `gettext`很难维护.最后一个版本从2010年开始.但是,如果你尝试从官方代码库构建它,你会发现它没有构建.也没有人支持它. (4认同)
  • gettext中的多个表单对于某些语言来说是不够的,无论如何在字符串中填写复数形式只是极客可以处理的东西,而不是普通的翻译者(具有语言背景).Java属性可以处理复数,请参阅MessageFormat示例:"有{0,选择,0#没有文件| 1#是一个文件| 1 <是{0,数字,整数}文件}."); 看起来像废话(与gettext相同)Windows资源超出了字符串.您可以在WYSIWYG环境中进行翻译,查看对话框和菜单,更改字体(某些语言需要),还有用于验证双快捷键等的工具. (3认同)
  • @Mihai pural形式的范围远远不够好,你通常需要一个简单的等式.XLIFF和gettext支持这个(但是每个稍微不同的wat)和Java属性对于这些urpos来说都不够好.多种形式是相当复杂的问题,到目前为止gettext提供了最佳解决方案. (3认同)

jcd*_*yer 7

Fluent是一个新系统,它提供了许多 gettext 所缺乏的适应性。在 gettext 支持复数的地方,fluent 有一个用于文本变体的通用框架。在 gettext 使用“未翻译”字符串作为其翻译键的情况下,fluent 支持抽象键(允许对恰好在源语言中同名的内容进行多次翻译。 这是一个更广泛的比较

一个流畅的 .ftl 文件示例,取自firefox 的首选项代码库,如下所示:

# 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.
Run Code Online (Sandbox Code Playgroud)