Browse documentation
DocsFormat guide

JSON & HTML

Work with nested application messages and document text while keeping the APIs semantically distinct.

01

JSON has three distinct roles

parse.json_i18n() reads nested application-message JSON. write.json_i18n() writes that shape. stream.write_jsonl() writes line-delimited unit records. Full-model Lokit JSON is loaded with lokit.io.load_lokit_json(); it is not the same as JSON i18n.

json_i18n.py
import lokit
document = lokit.parse.json_i18n(    "en.json",    source_locale="en-US",    target_locale="fr-FR",    target_filepath="fr.json",)
lokit.write.json_i18n(document, "messages.fr.json", nested=True)
02

Extract and restore HTML

HTML parsing extracts translatable document content into the common model and retains the source envelope needed by the convenience output path. Pass the source explicitly when writing a document built elsewhere.

html.py
document = lokit.parse.html(    "index.html",    source_locale="en-US",    target_locale="fr-FR",)
document.export.html("index.fr.html", source_html="index.html")# Or preserve the original envelope explicitly:document.regen.html("index.html", "index.fr.html")
03

Async availability

Both formats provide async unit iterators under lokit.parse.async_. Neither has a synchronous StreamingStructure document parser.