Learn kapi › The content engine
Any format, one model
A JSON catalog and a Markdown page, read into the same blocks.
The engine reads every format into one content model: blocks of runs, where inline codes, placeholders and plurals travel with the text. This lab inspects KapiMart's catalog and its About page, pseudo-translates the catalog without losing a placeholder, and re-expresses the page as HTML through the model.
- A storefront's content
ls srcKapiMart's interface strings are a nested JSON catalog; its About page is Markdown. Three locales sit beside the source at different stages: French complete, German two thirds, Japanese one third. - Measure the catalog
kapi stats src/en.jsonThirty-six strings, two hundred words. The numbers a quote starts from. - The catalog as blocks
kapi inspect src/en.json | head -30Every string is a block named by its key, with a revision of its text. The nesting of the JSON is kept in the key path. - The page as blocks
kapi inspect src/about.md | head -34Prose is addressed by structure: the heading, then the paragraph under it. A role says what the block is, so a heading is a heading in every format. - Inline structure travels with the text
kgrep plural src/en.jsonAn ICU plural or select is one block whose runs the model keeps intact, so a translation cannot drop a branch unnoticed. kgrep finds it as text, with the structure visible. - Pseudo-translate
kapi pseudo-translate src/en.json -o src/qps.jsonPseudo-translation accents every letter and leaves every placeholder and plural branch as it was: a cheap test of a layout before a real translation exists. - Placeholders survive
grep -n 'price_each|summary' src/qps.jsonThe price placeholder and the plural's branches are untouched inside the accented text. - Re-express through the model
kconv src/about.md -o src/about.htmlkconv reads one format and writes another. The Markdown heading becomes an h1 because both are the same block with the same role. - The result
head -12 src/about.htmlHeadings, paragraphs and emphasis, carried across. - What the engine reads and writes
kapi formatsEach format has a reader and, where it can write back, a writer, with its edit fidelity named. A faithful writer changes only the bytes that carry the text that changed.