Browse documentation
DocsFormat guide

PO & POT

Read Gettext catalogs with statuses, comments, contexts, headers, and plural entries preserved for export.

01

Choose the parsing mode

Use gettext when msgid is source and msgstr is target, source for source-only/POT behavior, or target_as_source when a nonempty msgstr should become the source. Obsolete entries are skipped; plural entries are represented as a base unit plus indexed variants.

gettext.py
import lokit
document = lokit.parse.po(    "fr.po",    source_locale="en-US",    target_locale="fr-FR",    mode="gettext",)
02

Merge target catalogs

po_targets() combines one source catalog and multiple locale files into one multilingual BaseStructure.

merge_po.py
document = lokit.parse.po_targets(    "messages.pot",    {"fr-FR": "fr.po", "de-DE": "de.po"},    source_locale="en-US",)
03

Write and regenerate

There is no synchronous StreamingStructure parser for PO. Use the materialized parser or parse.async_.po() for async unit iteration. Write a fresh catalog with write.po() or preserve an original catalog's envelope with document.regen.po().

write_po.py
lokit.write.po(document, "new.po")document.regen.po("original.po", "updated.po", target_locale="fr-FR")