Skip to content

feat(translate): pass preserve/untranslatable terms through to endpoint - #24

Open
nadaboulaares wants to merge 1 commit into
masterfrom
feat/translate-preserve-terms
Open

nadaboulaares wants to merge 1 commit into
masterfrom
feat/translate-preserve-terms

Conversation

@nadaboulaares

Copy link
Copy Markdown

Follow-up to #23 (review: "No way to mark terms as non-translatable yet. That belongs on the endpoint side, not here").

Server side (recon)

zola side (this PR)

TranslateApiClient now carries caller-supplied untranslatables and sends them per request:

  • Source: TRANSLATE_PRESERVE_TERMS env var (comma-separated, trimmed, blanks dropped) — same knob pattern as TRANSLATE_URL/TRANSLATE_TIMEOUT already on this client. Keeps the fork generic: terms come from the deployment, not code.
  • Wire: {"texts": [...], "target_language": ..., "source_language": "en", "preserve_terms": [...]}field omitted when empty, so the body stays byte-identical for callers with no glossary.
  • OpenRouter path unchanged (its system prompt already carries GLOSSARY). glossary_ok INV-5 gate unchanged — caller terms are trusted to the endpoint's mask/restore.

Tests

152 (cargo test --bin zola), 2 new: payload carries/omits preserve_terms, env parsing trims/drops blanks.

Assumption stated: PR #23 is already merged, so this is a fresh branch/PR rather than a push to the merged PR branch.

#23 review: marking terms non-translatable belongs on the endpoint client.
curriculo-ai getzola#1023/getzola#1133 shipped an optional preserve_terms: list[str] on
POST /translate (masked via the ⟦n⟧ machinery, restored verbatim; terms
under 3 chars ignored server-side). zola now sends it:

- TRANSLATE_PRESERVE_TERMS env var, comma-separated, trimmed, blanks
  dropped — same per-deployment knob pattern as TRANSLATE_URL/TIMEOUT
- TranslateApiClient carries the terms; build_translate_request includes
  preserve_terms only when non-empty, so the body is byte-identical for
  callers with no glossary
- OpenRouter path unchanged (its prompt already carries GLOSSARY);
  glossary_ok INV-5 gate unchanged

Tests: 152 (2 new: payload carries/omits preserve_terms, env parsing).
@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 39658c3a-3c44-4700-b445-7d9dfb534058


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant