Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java and GNU gettext for internationalization

Has anyone had any experiences developing large Java applications using GNU gettext for internationalization? I find that I really like having the English text in my source code, but I want to make sure that what I'm doing is practical for the relatively large software project I am part of.

If you have experience with this, what are you using to look up the resources in Java? I'm currently trying out Gettext Commons (http://code.google.com/p/gettext-commons/), which seems to be working well so far.

Any alternatives to gettext that keep the original text in your source code? A similar tool that is supported on Windows would be great.

like image 903
dcstraw Avatar asked Feb 23 '09 21:02

dcstraw


People also ask

How does gettext () work?

The Full Gettext Process Gettext works by, first, generating a template file with all the strings to be translated directly extracted from the source files, this template file is called a . pot file which stands for Portable Object Template.

What does gettext do in Java?

GetText returns the text from the single-line text field. It returns only the first line of a multi-line text field. If you include iStartChar but not iNumChars , GetText returns the text from the iStartChar character to the end of the text.

What is gettext package?

This package offers to programmers, translators, and even users, a well integrated set of tools and documentation. Specifically, the GNU gettext utilities are a set of tools that provides a framework to help other GNU packages produce multi-lingual messages.

What is domain in gettext?

A message domain is a set of translatable msgid messages. Usually, every software package has its own message domain. The domain name is used to determine the message catalog where the translation is looked up; it must be a non-empty string. For the gettext function, it is specified through a preceding textdomain call.


2 Answers

The JSOM open source OpenStreetMap Java editor project is using the Gettext library to handle all its translations and it is working out very well as people are able to use a variate of translation tools (like KBabel, poedit, launchpad...) to work with the po files so there is no platform constraint there. Also I don't quite see why you think the mentioned setup cannot be used on any platform - you can certainly use gettext in Windows see: here or here

Given how popular gettext is I would certainly recommend it.

like image 161
mfloryan Avatar answered Oct 05 '22 07:10

mfloryan


You could just use plain old Java message resource bundles instead.

Edit: Well, what we really use in our development team is the standard TMX format that lets you specify localization strings in XML files. It is a format commonly used by translation tools. Here is a free one, that lets you edit these files more easily.

Nonetheless I have not mentioned it before because it does not offer any real advantage or functionality over message resource bundles, except for a better encoding handling thanks to XML processing tools (encoding can be a real pain in the neck when handling internationalized literals in languages different to English).

Moreover what we really use is our software is our own framework that parses this XML format and let us change between languages (in HTML pages or Swing frames) without restarting our applications. It is not that hard to develop a simple library that handles literal translations this way, but the downside is that you must implement it.

like image 24
Fernando Miguélez Avatar answered Oct 05 '22 05:10

Fernando Miguélez