Alternatives to gettext?
Asked Answered
E

4

36

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.

Eddins answered 2/2, 2010 at 16:12 Comment(6)
What exactly of gettext do you find cumbersome?Fukien
It's hard to point at something specific, but it's something to do with the workflow of it that feels inefficient.Eddins
I don't think you would find much better things. It has very good range of tools to work with for translation and message extracting and so on. It is the most popular one and probably you just need to learn it well.Dorian
I agree that it's good. But that doesn't mean it's optimal...Eddins
Can you explain exactly what you don't like?Dorian
I'm asking about alternatives to gettext, not bashing gettext.Eddins
D
48

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.

Dorian answered 2/2, 2010 at 16:16 Comment(12)
See, this is an answer I was looking for. Some actual alternatives. Doesn't matter if they're good or bad, just that I can see different ways of doing things. Apparently there aren't so many, but that's not the point. ;)Eddins
Translation these days is not done in Notepad, there are WYSIWYG tools for localization and as for development. Java or Windows resources are not in any way more difficult to translate and maintain than anything else.Astonish
Plural forms in gettext are not enough for some languages, and anyway cramming plural forms in the string is something only geeks can handle, but not normal translators (with linguistic background). Java properties can handle plurals, see MessageFormat Example: "There {0,choice,0#are no files|1#is one file|1<are {0,number,integer} files}."); Looks like crap (same as gettext) The Windows resources go beyond strings. You can translate in a WYSIWYG environment and see the dialogs and menus, change the fonts (some languages need that), there are tools to validate for double quick-keys, etc.Astonish
AFAIK Qt ts/tm has no support for plural forms too.Freewill
@Mihai The range in pural forms is far from good enough, you usually need an simple equation. XLIFF and gettext support this (however each one in little bit different wat) and Java properties are not good enough for these urposes. Plural forms is quite compilcated issue and so far gettext provides best solution so far.Dorian
@Freewill Qt has plural forms suport, but the model is little bit different from gettext. See: doc.trolltech.com/qq/qq19-plurals.htmlDorian
gettext is very poorly maintained. The last release is back from 2010. However, if you try building it from the official code repository you will find it does not build. There no one around to support it either.Septuor
Boost locale is now part of the Boost release: boost.org/doc/libs/1_55_0/libs/locale/doc/html/…Consuela
@Septuor gettext seems to be actively maintained as of Jan 4, 2015 - see ftp.gnu.org/gnu/gettext, where the most recent build prior to this date is Dec 24, 2014.Fennelflower
@DanNissenbaum I'm happy to see that. I hope the library is finally buildable using the official repository. Thanks for the head's up.Septuor
XLIFF support in ICU is not good either. If you keep XLIFF files as they suggest and use their XLIFF To ICU ResourceBundle Format Converter, whose newest version was released on 2007-Aug-20, you will find it error-prone and barely do the task.Infatuation
@gili how often do you actually need to "maintain" such a stable tool in such a stable context? Lastest release february 2024.Abraham
J
11

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.
Jessie answered 27/3, 2019 at 22:58 Comment(1)
Abstract keys sound great but is unhelpful in practice: (a) code typically doesn't contain words but whole sentences, and these usually aren't homonymous, (b) if they are homonymous, code typically tries to avoid the ambiguity and you print "lime fruit" and "limestone", (c) if you still need/want the homonym (space constraints, or there's always enough context) you can let the software say "lime-fruit" and "lime-stone" and you give gettext a to-English file that "translates" both lime-fruit and lime-stone to lime.Angloamerican
E
4

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

Embolic answered 19/9, 2011 at 6:30 Comment(2)
I am aware this post is old. There is very good library Translate Toolkit (toolkit.translatehouse.org). Point of gettext is: How do you define strings to translate and strings to not to. How do you extract those strings. How do you import back translated strings that are kept up-to-date after long time. It is not about editor you use to translate. You can convert po to XLIFF and back with Toolkit, using script, no handwork.Neoptolemus
Yeah, my experience was around 2004 when I had to do all the work by hand to get everything to be translated. Today we have much better tools!Embolic
G
2

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

Geniagenial answered 15/11, 2012 at 4:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.