Home | Trees | Indices | Help |
---|
|
object --+ | list --+ | _BaseFile --+ | POFile
Po (or Pot) file reader/writer. POFile objects inherit the list objects methods.
**Example**:
>>> po = POFile() >>> entry1 = POEntry( ... msgid="Some english text", ... msgstr="Un texte en anglais" ... ) >>> entry1.occurrences = [('testfile', 12),('another_file', 1)] >>> entry1.comment = "Some useful comment" >>> entry2 = POEntry( ... msgid="Peace in some languages", ... msgstr="Pace سلام שלום Hasîtî 和平" ... ) >>> entry2.occurrences = [('testfile', 15),('another_file', 5)] >>> entry2.comment = "Another useful comment" >>> entry3 = POEntry( ... msgid='Some entry with quotes " \"', ... msgstr='Un message unicode avec des quotes " \"' ... ) >>> entry3.comment = "Test string quoting" >>> po.append(entry1) >>> po.append(entry2) >>> po.append(entry3) >>> po.header = "Some Header" >>> print(po) # Some Header msgid "" msgstr "" <BLANKLINE> #. Some useful comment #: testfile:12 another_file:1 msgid "Some english text" msgstr "Un texte en anglais" <BLANKLINE> #. Another useful comment #: testfile:15 another_file:5 msgid "Peace in some languages" msgstr "Pace سلام שלום Hasîtî 和平" <BLANKLINE> #. Test string quoting msgid "Some entry with quotes \" \"" msgstr "Un message unicode avec des quotes \" \"" <BLANKLINE>
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Inherited from Inherited from |
|
|||
Inherited from |
|
|||
Inherited from |
|
Return the string representation of the po file
|
Save the binary representation of the file to *fpath*. **Keyword arguments**:
|
Convenience method that return the percentage of translated messages. **Example**: >>> import polib >>> po = polib.pofile('tests/test_pofile_helpers.po') >>> po.percent_translated() 50 >>> po = POFile() >>> po.percent_translated() 100 |
Convenience method that return a list of translated entries. **Example**: >>> import polib >>> po = polib.pofile('tests/test_pofile_helpers.po') >>> len(po.translated_entries()) 6 |
Convenience method that return a list of untranslated entries. **Example**: >>> import polib >>> po = polib.pofile('tests/test_pofile_helpers.po') >>> len(po.untranslated_entries()) 6 |
Convenience method that return the list of 'fuzzy' entries. **Example**: >>> import polib >>> po = polib.pofile('tests/test_pofile_helpers.po') >>> len(po.fuzzy_entries()) 2 |
Convenience method that return the list of obsolete entries. **Example**: >>> import polib >>> po = polib.pofile('tests/test_pofile_helpers.po') >>> len(po.obsolete_entries()) 4 |
XXX this could not work if encodings are different, needs thinking and general refactoring of how polib handles encoding... Convenience method that merge the current pofile with the pot file provided. It behaves exactly as the gettext msgmerge utility:
**Keyword argument**:
**Example**: >>> import polib >>> refpot = polib.pofile('tests/test_merge.pot') >>> po = polib.pofile('tests/test_merge_before.po') >>> po.merge(refpot) >>> expected_po = polib.pofile('tests/test_merge_after.po') >>> unicode(po) == unicode(expected_po) True |
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Jun 5 14:32:06 2009 | http://epydoc.sourceforge.net |