We built a translation pipeline that treats content as segments, not pages, and remembers every segment it has translated.
Key design decisions
- Block-aware segmenting. A tokenizer and segmenter turn block markup, classic HTML and shortcodes into text runs. Inline tags become numbered placeholders (
<1>link</1>), so the AI never sees URLs, classes or attributes. Translatable attributes (alt, title, placeholder, aria-label, button values) and whitelisted block-comment attributes become their own segments. Rendering a document with no translations reproduces the input byte for byte.
- Translation memory keyed by content. Each segment is hashed (
sha1 of its whitespace-normalized, placeholder-masked source) per locale pair. On a sync, hits are reused and only new or changed segments are sent, batched into one structured-output request.
- Human edits always win. Memory entries have a status:
machine, review, approved or human. An AI write never replaces a human entry, a forced re-translation skips human and approved segments, and a translation post edited directly in WordPress is detected by fingerprint and left alone.
- Checked answers. Every answer is checked for exact placeholders and glossary rules (do-not-translate and forced terms). Failing segments get one corrective retry; if they still fail, the best attempt is repaired so the markup stays valid and flagged for review.
- Arithmetic outside the model. Imperial and metric measurements and currency amounts are detected in code, and the exact converted values are passed with the segment, so the model does not do the maths itself.
- One engine, three storage models. Providers write Polylang linked posts and terms through the
pll_* API, join WPML translation groups through WPML's public hooks, or, for TranslatePress, write strings into its dictionary using its own parser and query classes, with paragraphs that contain links registered as translation blocks.
Architecture
Post_Document builds a document from title, content, excerpt, slug, SEO fields (Yoast SEO and Rank Math), WooCommerce attributes, custom fields and terms. Sync_Engine resolves segments against the translation memory, calls the Translator (the Google Gemini API, gemini-2.5-pro by default) for the rest, and passes the rendered values to Post_Writer or the TranslatePress backend. Bulk jobs run in a background queue (Action Scheduler or WP-Cron) with a cost estimate, and saving a translated source post queues a delta sync automatically. A shared core used across DEV3's plugins provides the API client, encrypted key storage, usage logs and licensing; the admin UI is React.