1

Complete C++ i18n gettext() “hello world” example shows a standard way to handle messages in a C++ program using gettext(). The message catalogs are stored in Portable Object files based upon a Portable Object Template file created directly from the C++ source code using xgettext, msginit and msgfmt. What is the corresponding method for handling messages by XSLT?

Specifically, to make C++ hello-world code support i18n one just adds two includes, calls some setup functions and wraps strings in calls to gettext():

#include <libintl.h>
#include <locale.h>
..
    setlocale(LC_ALL, "");
    bindtextdomain("hellogt", ".");
    textdomain( "hellogt");
    std::cout << gettext("hello, world!") << std::endl;
...

Then the English text is extracted from the source program and converted to a Portable Object Template for use by translators who create Machine Object message catalog files for use by the run-time program using utilities programs: xgettext, msginit and msgfmt. Finally, the Linux shell command for identifying the run-time language as Spanish is shown when the program is invoked.

The main purpose of doing a hello-world program is to connect all of the system parts to get a virtually useless example to function. So, as the C++ example shows for C++ in a Linux environment I am looking for the same thing but for XSLT instead.

  1. In the C++ example there is a set of include files and object files that are linked into hellogt. Is there code for XSLT that provides the functionality of setlocale, bindtextdomain and textdomain? How does the code connect to the user's runtime language?
  2. Is there XSLT code that provides run-time conversion from English text via message catalog files like gettext() does?
  3. Are there utility programs for extracting the Engish text from a source XML file for use by the translators along with programs to convert the results to run-time usable message catalog files like xgettext, msginit and msgfmt do?
  4. How is the identify of the user runtime language specified?

For example, I have a Javascript application, Emle, that processes XML using XSLT into HTML. The messages are defined in an application specific collection of language specific XML files. They are extracted using application specific XSLT code. Though this speaks to #2 the method does not appear to lend itself to being able to take advantage of translation services like those provided by LaunchPad. An example Emle English message file used by Emle XSLT file

Community
  • 1
  • 1
CW Holeman II
  • 4,661
  • 7
  • 41
  • 72
  • Are you looking for a generic way to map a given message like misc-all-fireFoxOnly from your source file into all instances of the corresponding target HTML file for all instances of misc-all-fireFoxOnly in the target, using only XSLT? So, you start with some file that happens to have misc-all-fireFoxOnly in it, and end up with a HTML file that uses misc-all-fireFoxOnly without having to actually map from source to target - is my understanding right? – Erik Westermann Jul 09 '09 at 15:15
  • I am looking for XSLT code to add into my code along with support utilities to process the messages. I added more details to the question. – CW Holeman II Jul 09 '09 at 20:19

2 Answers2

1

If non-XML tools are acceptable, then this Perl tool does the job of generating and keeping in sync a set of gettext PO files of an XML data file and its translations.

http://po4a.alioth.debian.org/man/man3pm/Locale::Po4a::Xml.3pm.php

user241170
  • 21
  • 1
0

After some looking I found this: http://xmlguru.cz/2006/10/saxon-gettext I've yet to read it fully to see if and how it answers your question, but I offer the link hoping it helps.

awatts
  • 1,008
  • 8
  • 13