Alternatives to gettext?

16,111

Solution 1

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 use gettext'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:

  • OASIS XLIFF
  • GNU gettext po/mo files
  • POSIX catalogs
  • Qt ts/tm files
  • Java properties,
  • Windows resources.

Now:

  • Last two total crap... Very hard to use translate and maintain, do not support plural forms.
  • Qt ts/tm -- requires usage of Qt framework. Have very similar model to gettext. Not bad solution, but limited to Qt. Not so useful in generic programs.
  • POSIX catalogs -- nobody uses them, no plural forms support. Crap.
  • OASIX XLIFF -- "standard" solution, depends on XML, even ICU requires compilation to specific ICU resources for use. Limited translation tools, I don't know any library that supports XLIFF. Plural forms not so easy to use (ICU included some support only in 4.x release).

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.

Solution 2

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:

# 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.

Solution 3

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!)

Solution 4

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

Share:
16,111
Tor Valamo
Author by

Tor Valamo

Updated on June 12, 2022

Comments

  • Tor Valamo
    Tor Valamo almost 2 years

    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.