Sxmloc is a project mainly written in Shell, it's free.
Simple XML localization tool
SXmLoc is a set of XSLT stylesheets and shell scripts intended to be used for translating small parts of XML files.
SXmLoc uses GNU gettext[1] as a backend for storing strings that shall be translated but unlike gettext, it does the translations off-line. Normally, when using gettext in C, you insert strings into your program using the gettext function (or _ macro) and the localized string is selected at runtime from a compiled MO file. SXmLoc does not need MO files as the translation is retrieved from the PO file and translated XML is generated.
The typical workflow with SXmLoc is:
Inside the sample/ directory is a short example how the localization can be done, together with a Makefile containing all the necessary commands.
Prerequisities:
SXmLoc does not need to compile anything, thus simply invoking
as root will install SXmLoc into /usr/local/bin and /usr/local/share/sxmloc.
If you wish to install into other directories, you might need to change the PREFIX variable (e.g. run `make install PREFIX=/usr') or, for more subtle changes, set the MY..DIR variables.
For packagers: SXmLoc supports the traditional DESTDIR variable.
The extraction of the strings is pretty straightforward: everything inside the loc:g elements is copied (enclosed inside gettext("...")), the rest of the document is ignored. To bypass possible problems with multiline strings, PHP is used as the intermediary language. This output is then run through xgettext(1) and printed to standard output. The position in the source code is remembered through a comment in the POT file which describes the offsets in the XML tree.
The translations are applied to the original XML file by generating a XSLT that finds the loc:g elements and compares their position with the comment in the PO file. When the position matches, the loc:g is replaced with the translated string. Everything else is copied as-is into the final document.
[1] http://www.gnu.org/software/gettext/ [2] http://xmlsoft.org/XSLT/