mdpo.po module
PO files related stuff.
- mdpo.po.find_entry_in_entries(entry, entries, **kwargs)
Return an equal entry in a set of
polib.POEntry
entries.Finds the first
polib.POEntry
instance in the iterableentries
that is equal, according to its__cmp__
method, to thepolib.POEntry
instance passed asentry
argument.- Parameters:
entry (
polib.POEntry
) – Entry to search for.entries (list) – Entries to search against.
**kwargs – Keyword arguments passed to
polib.POEntry
__cmp__
method.
- Returns:
Entry passed in
entry
argument if an equal entry has been found inentries
iterable, otherwiseNone
.- Return type:
- mdpo.po.mark_not_found_entries_as_obsoletes(pofile, entries)
Mark entries in a PO file obsoletes if are not in a set of entries.
If an entry of the PO file is found in the set of entries, will be marked as no obsolete.
- Parameters:
pofile (
polib.POFile
) – PO file in which the missing entries will be marked as obsoletes.entries (list) – Entries to search against.
- mdpo.po.paths_or_globs_to_unique_pofiles(pofiles_globs, ignore, po_encoding=None)
Convert any path, paths or glob to
polib.POFile
objects.
- mdpo.po.po_escaped_string(chars)
Prepend a
\
character to a string.This is used to escape values inside strings wrapped for the returned character.
- mdpo.po.pofiles_to_unique_translations_dicts(pofiles)
Extract unique translations from a set of PO files.
Given multiple pofiles, extracts translations (those messages with non empty msgstrs) into two dictionaries, a dictionary for translations with contexts and other without them.
- Parameters:
pofiles (list) – List of
polib.POFile
objects.- Returns:
dictionaries with translations.
- Return type:
- mdpo.po.remove_not_found_entries(pofile, entries)
Remove entries in a PO file if are not in a set of entries.
- Parameters:
pofile (
polib.POFile
) – PO file for which the missing entries will be removed.entries (list) – Entries to search against.