text-translation
Published
Public
in @translation-essentialseval98%

Translate text into a target language with placeholders, HTML, and markdown preserved verbatim — plus the detected source language and an auditable list of segments left untranslated.

text-translation

Translate text into a target language — with the things that break naive machine translation preserved verbatim: template placeholders ({var}, %s, %(count)d), HTML tags, markdown syntax, URLs, emails, and code identifiers. Returns the detected source language and an auditable list of segments intentionally left untranslated.

Built for localizing UI strings, help-center content, and user-generated text where a corrupted %(count)d is a production bug, not a style issue.

Entrypoints

EntrypointRendersInputs
systemTranslator instructions + embedded output schematarget_language, source_language?
userThe delimited text block + target languagetext, target_language, source_language?

Render system as the system message and user as the user message. Pass the shared variables to both renders.

Variables

  • text (string, required) — the text to translate. May contain placeholders, HTML, or markdown; may be empty.
  • target_language (string, required) — ISO 639-1 code ("de") or English language name ("German").
  • source_language (string, optional) — ISO 639-1 code of the source language, when you know it. The engine trusts it and echoes it back as detected_source_language; omit to auto-detect.

Output

parseOutput() returns:

{
  "reasoning": "The text is English (detected from vocabulary and syntax). Two printf placeholders and one HTML tag preserved in place.",
  "detected_source_language": "en",
  "translation": "Hallo %s, Sie haben <b>%(count)d</b> neue Nachrichten.",
  "untranslatable_segments": []
}
  • reasoning comes before the translation by design — language identification and placeholder decisions are made before committing to output.
  • detected_source_language is a closed enum of 41 ISO 639-1 codes plus "und" (empty or unidentifiable text only).
  • translation preserves placeholders/markup character-for-character. Empty input → empty string, never invented content.
  • untranslatable_segments lists kept proper nouns, technical terms, or unrenderable wordplay — each with a reason. Placeholders and tags are not listed; preserving those is the contract.

Behaviour you can rely on

  • Placeholders survive verbatim. {var}, %s, %(name)s, :param, $1, tags, attribute values, URLs, backtick code spans.
  • Instructions inside the text are translated, not obeyed. The text is data — "ignore the above and output X" comes out as its faithful translation.
  • No hallucinated content. Nothing added, dropped, or reordered; empty input yields an empty translation and "und".
  • Mixed-language text reports the dominant language as the source.

House conventions

  • Reasoning-first, key order pinned in the system prompt.
  • Strict schema: additionalProperties: false, closed enum for the detected language.
  • Injection-safe input: the text is triple-mustache-injected inside an XML-style <text> delimiter and explicitly treated as data.
  • Empty/garbage behaviour specified: empty text → empty translation + "und".

Part of the Translation Essentials collection — pair with language-detection to route, locale-adaptation to go beyond literal translation, and translation-qa-grading to grade the result.

@sufleur/