xbmc/xbmc — pull request #910 by alanwww1 (2012-05-01 00:01:09+00:00)
Title: Gettext PO file support for xbmc (reworked)

This is a rework of PR 868 using standard string functions instead of direct character manipulation.
It serves as a first stage for gettext support in xbmc and having a better web based translation system.

I managed to keep the speed at least 2-3 times fast than the TinyXML parser.
I tested speed with adding these debug lines:

https://github.com/alanwww1/xbmc/commit/03b129b1e824a8dca5212868be54b730fced7581

The results:

English PO: core: 3.97, confl.: 0.37
English XML: core: 10.54, confl.: 0.85

German PO: core: 6.03, confl.: 0.51
German XML: core: 13.22, confl.: 1.21

I also tested if things are ok, with writing out memeory dump files from the filled memory with the original XML file and with the new PO file. The test was done with the same debug commit from my test branch:

https://github.com/alanwww1/xbmc/commit/03b129b1e824a8dca5212868be54b730fced7581

You can see the dump files here:

https://github.com/alanwww1/xbmc/commit/d3b776a9d8379b823c9679f593852e4743faec91

For the English strings, the dump files are binary identical. Also all the other language files are only differ in spots where the original English xml file contained a deleted or blanked entry where the translated language file had a valid entry. These entries does not get into the PO file.

So I think it is safe to say that the parser is working great.

I also updated the xbmc-xml2po utility I've written to version 0.9.
Added ability to convert all strings to utf8 in the PO files. It was tricky for the Win side because of libiconv, but I solved it.

https://github.com/alanwww1/xbmc-xml2po

Windows binary was also updated.

I also added ability to break long lines in gettext rules to look nice and organized. I also extended this capability to not only recognize \n as Line Feed, but also [CR] which we have for skin strings. So the files are looking great. Also the plural form for the specific language gets written into the PO file.

Of course we still have strings.xml as a fallback in case no strings.po file exists in the language directory.

Also (for a short transitional period) I kept the strings.xml files for even where the converted srtings.po files already exist.
The purpose for this is to handle pre written PR-s. I will manually add the new strings coming to the strings.xml files to the new strings.po files.

The new PO files are directly suitable for use with web based translation tools eg. Transifex.net, what I will intend to use for all translations.

Also please check this post about the format:

http://forum.xbmc.org/showthread.php?tid=122255&pid=1072239#pid1072239