Michal Čihař - Converting locales data

Converting locales data

I already announced that Gammu translations were converted to gettext. Reasons for conversion were written already some time ago. Now I'd like to write about some technical details on conversion.

First I thought the conversion will be simple. Just convert one text file format to other. Unfortunately there were lots of typos in old translations, which I had to fix, because gettext is much stricter about syntax. This itself would be also good reason to switch - old localisations had several types of errors, most frequently bad escaped quotes or messed format strings. This sometimes lead to Gammu crash, because it confuses printf like functions.

Another thing which was broken in old translation were duplicates of some strings. There were about 20 duplicate messages, which only added work to translators and were never used, because Gammu used first string which matched.

After I spot common mistakes, it was quite easy to write conversion script which would handle them. It is written in Python and uses its ConfigParser module to read old localisations. Using already done modules makes thinks a lot easier :-). After reading them, they are fixed to avoid syntax errors in gettext and written in gettext format to new file. All this in 123 lines of code (well, many of this are comments and string constants).

PS: You can download conversion script here, maybe it will be usable also for some other project.