Package translate :: Package storage :: Module qm |
[hide private]
[frames] | no frames]

# Module qm

source code

Module for parsing Qt .qm files

Notes:

- based on documentation from Gettext's .qm implementation (see write-qt.c) and on observation of the output of lrelease.
- Certain deprecated section tags are not implemented. These will break and print out the missing tag. They are easy to implement and should follow the structure in 03 (Translation). We could find no examples that use these so we'd rather leave it unimplemented until we actually have test data.
- Many .qm files are unable to be parsed as they do not have the source text. We assume that since they use a hash table to lookup the data there is actually no need for the source text. It seems however that in Qt4's lrelease all data is included in the resultant .qm file.

To Do:

- We can only parse, not create, a .qm file. The main issue is that we need to implement the hashing algorithm (which seems to be identical to the Gettext hash algorithm). Unlike Gettext it seems that the hash is required, but that has not been validated.
- The code can parse files correctly. But it could be cleaned up to be more readable, especially the part that breaks the file into sections.

Classes | [hide private]
| qmunit A class representing a .qm translation message.
| qmfile A class representing a .qm file.

Functions | [hide private]
qmunpack(qmfile='messages.mo') Helper to unpack Qt .qm files into a Python string | source code

Variables | [hide private]
| QM_MAGIC_NUMBER = `0x3CB86418L, 0xCAEF9C95L, 0xCD211CBFL, 0x60A`...``

Imports: base, multistring, codecs, struct, sys

Variables Details | [hide private]

  ### QM_MAGIC_NUMBER Value:
      0x3CB86418L, 0xCAEF9C95L, 0xCD211CBFL, 0x60A1BDDDL