XML2PO(1)
π XML2PO π
okay bestie, sit down, hydrate, because we're about to talk about xml2po β yes, that's the XML2PO(1) manual page, and yes, it's giving extremely useful actually. It's a whole little program that yanks the translatable bits out of your DocBook XML, hands you a PO-template file, and then (iconic behaviour) merges your translated stuff right back into the XML. π¦
β¨ NAME β¨
xml2po β a program to create a PO-template file from a DocBook XML file and merge it back into a (translated) XML file. π
πΈ SYNOPSIS πΈ
xml2po [OPTIONS] [XMLFILE]
π DESCRIPTION π
This manual page documents briefly the xml2po command. (Not me being humble, that's literally what it says. π)
xml2po is a simple Python program, and the way that it just... extracts translatable content from free-form XML documents and outputs gettext-compatible POT files? Obsessed. And then β plot twist β translated PO files can be turned into XML output again. It's a whole round trip. π«Ά
It can work its magic with most "simple" tags, fr fr. But for the complicated tags, bestie, you gotta put in the work: one has to provide a list of all the tags which are "final" (meaning they get put into one "message" in the PO file), "ignored" (skipped over entirely, not even acknowledged π), and "space preserving". That's the deal. Periodt.
π OPTIONS π
The program follows the usual GNU command line syntax, with long options starting with two dashes (`-Β΄). A summary of options is included below. Slay.
-a,--automatic-tagsβ Automatically decide if tags are to be considered "final" or not. Let the program cook. π₯-k,--keep-entitiesβ Don't expand entities. This is the default, bestie. See also the-eoption.-e,--expand-all-entitiesβ Expand all entities (includingSYSTEMones). Go big or go home. π₯-m,--mode=TYPEβ Treat tags as type TYPE. Default is:docbook.-o,--output=FILEβ Print the resulting text to the given FILE. Which resulting text, you ask? Depends on the vibe: XML while merging translations with-por-toptions, POT template file while extracting strings, and translated PO file with the-roption. It's giving multitasking. π-p,--po-file=FILEβ Specify a PO FILE containing translation, and output an XML document with the translations merged in. β¨-r,--reuse=FILEβ Specify a translated XML document in FILE with the same structure, to generate a translated PO file for the XML document given on the command line.-t,--translation=FILEβ Specify a MO FILE containing translation, and output an XML document with translations merged in.-u,--update-translation=LANG.poβ Update a PO file usingmsgmerge.-l,--language=LANGβ Explicitly set language of the translation. No guessing games. π-h,--helpβ Show summary of options. (Hi, that's you, right now.)-v,--versionβ Show version of program.
π EXAMPLES π
π Creating POT template files
To create a POT template book.pot from an input file book.xml, which consists of chapter1.xml and chapter2.xml (external entities), run:
/usr/bin/xml2po -o book.pot book.xml chapter1.xml chapter2.xml
To expand entities, use the -e option:
/usr/bin/xml2po -e -o book.pot book.xml
π§ Creating translated XML files (merging back PO files)
After translating book.pot into LANG.po, merge the translations back by using the -p option for each XML file:
/usr/bin/xml2po -p LANG.po -o book.LANG.xml book.xml
/usr/bin/xml2po -p LANG.po -o chapter1.LANG.xml chapter1.xml
/usr/bin/xml2po -p LANG.po -o chapter2.LANG.xml chapter2.xml
If you used the -e option to expand entities, you should use it again to merge back the translation into an XML file. Consistency, bestie:
/usr/bin/xml2po -e -p LANG.po -o book.LANG.xml book.xml
π Updating PO files
When the base XML file changes, the real advantages of PO files come to the surface. π There are 2 ways to merge the translation.
The first is to produce a new POT template file (additionally use the -e if you decided earlier to expand entities). Afterwards run msgmerge to merge the translation with the new POT file:
/usr/bin/msgmerge -o tmp.po LANG.po book.pot
Now rename tmp.po to LANG.po and update your translation. Alternatively, xml2po provides the -u option, which does exactly these two steps for you. The advantage is that it also runs msgfmt to give you a statistical output of translation status β count of translated, untranslated and fuzzy messages. π Additionally use the -e if you decided earlier to expand entities:
/usr/bin/xml2po -u LANG.po book.xml
π SEE ALSO π
msgmerge (1), msgfmt (1)
π«Ά AUTHOR π«Ά
This manual page was written by Daniel Leidert daniel.leidert@wgdd.de for the Debian system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 any later version published by the Free Software Foundation. So like, go forth and remix it, respectfully. π
β COPYRIGHT β
Copyright Β© 2005 Daniel Leidert
okay that's the whole page, you ate that. π no cap, every flag, every example, every entity β all of it, untouched. iykyk.
and that's a wrap, bestie β¨ this page came from the [FIXME: source] situation, dated 2005/02/10, and it lives in the XML2PO(1) section of the manual. mwah. π
π¦ where this page comes from
- epel 9: gnome-doc-utils 0.20.10-30.el9 Β· GPLv2+ and LGPLv2+ and GFDL
- fedora 43: gnome-doc-utils 0.20.10-44.fc43 Β· LGPL-2.1-or-later AND GPL-2.0-or-later AND GFDL-1.1-or-later
- fedora 44: gnome-doc-utils 0.20.10-45.fc44 Β· LGPL-2.1-or-later AND GPL-2.0-or-later AND GFDL-1.1-or-later
- nixos 26.05: gnome-doc-utils 0.20.10
- nixpkgs unstable: gnome-doc-utils 0.20.10
- opensuse-leap 16.0: xml2po 0.20.10-160000.2.2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms