Skip to main content

Stateless web-novel translation service with switchable engines

Project description

lncrawl-translator

A web-novel translation service — metadata (titles, author, synopsis, tags) and HTML chapter content — with a focus on Chinese / Korean / Japanese → English. Runs standalone (Docker/uvicorn) or embedded as a Python library inside a host application.

Built as a stateless translation API for lightnovel-crawler, with switchable translation engines (free-tier hosted APIs and CPU-friendly local models). Requests can carry a per-novel glossary that is injected into translations and returned with new terms, so the caller can maintain name/term consistency across thousands of chapters.

Quick start

No config file needed — a curated set of free providers is pre-wired, and the keyless Bing lane (no key required) is the default, so translation works even with zero keys:

docker compose up -d
curl http://localhost:8184/health  # shows which engines came up

Then open http://localhost:8184/ and paste your provider API keys — the matching engines enable instantly, no restart needed.

See docs/deployment.md for engine keys, the keyless Bing lane, and API examples; docs/design.md for the API and architecture; docs/translation-engines.md for the engine research.

API

  • GET / — browser demo & config UI: try translations, watch engine status, and manage the runtime config without leaving the page
  • GET /health — liveness/readiness
  • GET /engines — configured engines with live status (quota, cooldowns)
  • POST /detect — local language detection (no engine quota)
  • POST /translate/text — batched short strings (titles, tags, synopsis)
  • POST /translate/html — one chapter per call, glossary in/new terms out
  • GET /config + CRUD on /providers, /engines, /routing — runtime config management; changes apply atomically and persist to config.yml

The API is unauthenticated by design — run it on localhost or a private network only (see docs/deployment.md).

Use as a library

Install the package (pip install lncrawl-translator; Python 3.9+) and use the embedded service — a thread-safe, synchronous facade that runs the same engine router on its own event loop:

from translator import TranslatorService

service = TranslatorService(config_path="translator.yml")

service.detect(["どこから来ましたか"])                # local, no quota
response = service.translate_text({
    "texts": ["少年は勇者になった"],
    "target_lang": "en",
    "glossary": {"勇者": "Hero"},
})
print(response.translations, response.engine, response.new_terms)

service.close()  # on shutdown

translate_text/translate_html accept an optional signal (threading.Event) for cooperative cancellation and a timeout in seconds.

The dashboard and HTTP API can be mounted into a host ASGI app, sharing the service's live config — edits made in the dashboard apply to the embedded service immediately:

app.mount("/translator", service.create_app())

The mounted app carries no authentication (same as the standalone server) — the host must gate access itself. Language detection is also available without a service: from translator import detect_language.

Development

uv sync
uv run poe check      # ruff + mypy + pytest
uv run poe dev        # dev server with auto-reload
uv run poe start      # production-style server (uvicorn on :8184)
uv run poe live-test  # smoke-test real engines from config.yml (opt-in)

See AGENTS.md for project decisions and conventions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lncrawl_translator-0.1.0.tar.gz (130.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lncrawl_translator-0.1.0-py3-none-any.whl (151.8 kB view details)

Uploaded Python 3

File details

Details for the file lncrawl_translator-0.1.0.tar.gz.

File metadata

  • Download URL: lncrawl_translator-0.1.0.tar.gz
  • Upload date:
  • Size: 130.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for lncrawl_translator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 47cfa1e115d3a28fc3776759c7cc3bd90a034a38812c123b84659c1521a5dc10
MD5 38e0b99593db1e77d47a3d17732e9979
BLAKE2b-256 da93f35daada0edbb106f3dc83334befd867c966831cf50c6589a592456f8e93

See more details on using hashes here.

Provenance

The following attestation bundles were made for lncrawl_translator-0.1.0.tar.gz:

Publisher: publish.yml on lncrawl/translator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lncrawl_translator-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lncrawl_translator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2790071dd44b81903040a70152f34638f7692b9f59b35055bd5ffff4f2ef33de
MD5 ba3118b14eda94b7bc33923fe4b57188
BLAKE2b-256 fa9279a8eaaf927a4f4a63540aac955ee88329b76e9072aa23a3d77a2ec0d89e

See more details on using hashes here.

Provenance

The following attestation bundles were made for lncrawl_translator-0.1.0-py3-none-any.whl:

Publisher: publish.yml on lncrawl/translator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page