Reputation: 4971
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.
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
Upvotes: 1
Views: 1726
Reputation: 1067
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.
Upvotes: 0
Reputation: 21
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
Upvotes: 1