Skip to content

feat(deepl): add @kiritan/deepl translate middleware - #53

Merged
otnc merged 4 commits into
mainfrom
feat/deepl-middleware-package
Sep 19, 2026
Merged

otnc merged 4 commits into
mainfrom
feat/deepl-middleware-package

Conversation

@otnc

@otnc otnc commented Sep 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix bug(s)
  • New feature(s)
  • Others

Adds @kiritan/deepl, the first official translate-middleware package from the roadmap.

  • deepl(options) is a single-form middleware (one request per item). deeplBatch(options) is a batch-form one: contexts sharing a language pair go out together, up to DeepL's 50 texts per request.
  • %{name} placeholders come back unchanged. They are wrapped in a tag DeepL is told to ignore (tag_handling: xml + ignore_tags), so the rest of the text is XML-escaped on the way in and un-escaped on the way out.
  • en/pt targets map to EN-US/PT-BR since DeepL rejects the bare codes as a target. targetLanguages overrides this per locale, and extraParams is merged into the request body.
  • The package doesn't depend on kiritan: a middleware is just a function, and the types are declared structurally.
  • It comes with its own i18n'd README, a release-deepl.yml workflow (same shape as release-runtime.yml), and entries in the docs tables. The version starts at 0.0.0, so the first minor release gives 0.1.0.

Not verified against the live service: I have no DeepL key. The request shape (endpoint, auth header, body fields, response handling, 50-text limit) is unit-tested against DeepL's documented API with a fake fetch, so please try it once with a real key before the first release.

@kiritan/google-translate is still on the roadmap. Trusted publishing for @kiritan/deepl also needs setting up on npmjs.com before its first release (see CONTRIBUTING.md).

Why?

DESIGN.md chapter 13 listed official translate-middleware packages as future work, and the README/DESIGN wording said only doc examples would exist in v1.

Related issue(s)

closes

Check

  • Check if duplicate PR(s) already exist.
  • Read CONTRIBUTING.md (rules)
  • Run npm run check (lint & format)
  • Run npm run typecheck
  • Run npm run test (functions test)
  • Run npm run build (dist/)
  • (optional) Run npm run test:coverage and check nothing new went uncovered

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The request options can disable placeholder protection, batching ignores DeepL’s body-size limit, and the documented catalog example contains no translatable catalog segments.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Adds a standalone @kiritan/deepl translation middleware with single and batch request modes, placeholder preservation, tests, packaging, documentation, and release automation.

Changes:

  • Implements DeepL translation requests, language mapping, XML-safe placeholders, and batching.
  • Adds unit tests, package metadata, build configuration, lockfile, and release workflow.
  • Updates localized documentation, design notes, contributor guidance, and workspace configuration.
File Description
README.md Lists the new package.
README.ja.md Japanese package listing.
packages/​deepl/​tsdown.config.ts Package build configuration.
packages/​deepl/​tsconfig.json TypeScript configuration.
packages/​deepl/​src/​index.ts DeepL middleware implementation.
packages/​deepl/​src/​index.test.ts API and batching tests.
packages/​deepl/​README.md English package documentation.
packages/​deepl/​README.ja.md Japanese package documentation.
packages/​deepl/​package.json Package metadata and exports.
packages/​deepl/​LICENSE Package license.
packages/​deepl/​base/​README.base.md Localized README source.
package-lock.json Workspace lockfile update.
docs/​DESIGN.md English architecture and roadmap updates.
docs/​DESIGN.ja.md Japanese architecture and roadmap updates.
CONTRIBUTING.md English package and release guidance.
CONTRIBUTING.ja.md Japanese package and release guidance.
base/​README.base.md English/Japanese workspace README source updates.
base/​DESIGN.base.md Design documentation source updates.
base/​CONTRIBUTING.base.md Contribution documentation source updates.
.kiritanconfig Registers package documentation generation.
.github/​workflows/​release-deepl.yml Adds package release workflow.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/deepl/src/index.ts Resolved
Comment thread packages/deepl/src/index.ts Resolved
Comment thread packages/deepl/base/README.base.md Resolved
@otnc
otnc merged commit 9b53a9d into main Sep 19, 2026
4 checks passed
@otnc
otnc deleted the feat/deepl-middleware-package branch September 19, 2026 11:19
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.

2 participants