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.
- 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?
- Is there XSLT code that provides run-time conversion from English text via message catalog files like gettext() does?
- 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?
- 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