Skip to content
SpiraMirabilisPublic

About

A translation and publishing platform

Resources

Stars

4 stars

Watchers

1 watching

Forks

Latest commit

 

History

442 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

T9 — Web Novel Translation & Publishing Platform

T9 started as an AI-powered tool for translating web novels into English and has grown into a full publishing platform. It has two halves that matter about equally:

  • A translation & writing studio — multi-provider AI translation (OpenAI, Claude, Gemini, DeepSeek, OpenRouter, or your local Claude Code or Codex subscription) with an entity glossary that keeps terminology consistent across thousands of chapters, a split-pane proofreading editor, a WYSIWYG editor for original fiction, and batch queue processing.
  • A public reader site — a clean, login-free Library and Reader for your finished work, with chapter scheduling and drip releases, anonymous comments with moderation, RSS feeds, EPUB downloads, reader statistics, and CDN-backed covers and illustrations.

Source languages include Chinese, Japanese, Korean, and Russian, with genre-specific prompt presets (xianxia, light novel, Korean web novel, and more).

Feature Highlights

Translation engine

  • Multi-provider AI translation — OpenAI, Anthropic Claude, Google Gemini, DeepSeek, OpenRouter, and claudecode / codex providers that drive the local Claude Code or Codex CLI (translate on your Claude or ChatGPT subscription with no API key; the queue pauses and resumes automatically around usage limits)
  • Entity consistency — automatically identifies proper nouns and maintains a per-book glossary so names, places, and terms stay consistent across hundreds of chapters
  • Entity review — after each chapter, review newly discovered entities, fix translations, and delete false positives before they propagate; retroactive review revisits earlier entities with AI advice, dictionary lookup, and propagation to affected chapters
  • Queue processing — upload EPUB, FB2, or text files and translate back-to-back with auto-processing; resilient to provider overload (529 responses trigger a patient retry loop instead of burning the retry budget)
  • Streaming output — real-time translation progress with chunk-by-chunk status over WebSocket
  • Genre presets — pre-built prompts per genre, copied per book at creation so you can customize each book's system prompt independently

Books, proofreading & rich content

  • Chapter editor — split-pane view with source on the left, editable English on the right, entity highlighting, CC-CEDICT dictionary lookup, and selection-based LLM retranslation with ruby-text comparison
  • Search & replace — chapter-level or book-wide, regex support, cross-chapter navigation, one-click undo for bulk replacements, and a global search modal on the Books page
  • Markdown rich text — chapters support block-level Markdown (headings, blockquotes, tables, and more) rendered identically in the Reader, EPUB, HTML export, and WordPress
  • Illustrations — in-chapter images via ⟦IMG:id⟧ markers that survive the translate → edit → export pipeline and render inline everywhere
  • Footnotes — persistent per-book footnotes (cultural notes, incantation glosses) that re-anchor automatically on every chapter save

Original works & the Write editor

  • WYSIWYG Write editor (TipTap) for fiction written directly in the browser — original books get it as their default editor, and translation books can use it too
  • Round-trip safety — content is stored as Markdown; every save is serialize → reparse → compare guarded, so the editor can never silently rewrite your text
  • Autosave & revisions — server autosave with optimistic locking (conflict banner instead of silent clobber), plus manual/auto revision snapshots with one-click restore
  • Writing tools — live word count, session counter, daily goal, focus/typewriter mode, Reader-parity preview
  • Grammar & polish — local LanguageTool integration plus an LLM polish pass, with your entity dictionary suppressing false positives on invented names
  • Rich formatting — XenForo-parity tables (multi-paragraph cells, lists in cells), underline and text color, with BBCode export for forum posting

Publishing

  • Drafts & scheduling — every chapter is draft, scheduled, or live (published_at timestamp); scheduled chapters go live automatically with no cron
  • Drip releases — batch-publish a run of chapters with a stagger interval (e.g. one chapter every 12 hours)
  • EPUB export — per-book EPUB generation with covers and illustrations; the public download is published-chapters-only and regenerates itself when a scheduled chapter crosses its publish time
  • WordPress / Fictioneer — publish books to a WordPress site running the Fictioneer theme, incrementally (unchanged chapters skipped)
  • RSS — a site-wide feed of recent chapters plus per-book feeds, with autodiscovery tags on reader pages

The public reader site

  • Library — public book listing with covers, tags, status, and view counts; no login required for readers
  • Reader — chapter navigation, table of contents, full-text search, keyboard and swipe navigation, translated/source/interleaved display modes, light/sepia/dark themes, adjustable font size
  • Comments — anonymous per-chapter comments protected by Cloudflare Turnstile, with optional email reply notifications (and one-click unsubscribe), an admin moderation queue, optional AI auto-moderation, and IP bans that push to the Cloudflare edge
  • Recommendations — a public "recommend me something" form (also Turnstile-protected) feeding an admin review page
  • Reader statistics — view counts and per-chapter reading stats in the admin UI

Per-book modules

Composable text-transform modules, toggled per book (auto by source URL, or forced on/off), each with its own settings:

Module What it does
Traditional → Simplified OpenCC conversion at ingest so Taiwan-sourced raws match your entity glossary
Chatgroup Transformer Normalizes "group chat" novels — wraps 叮!/Ding notifications and username:message lines (entity-verified) into 【…】 blocks, on both source and translated text
Markdown Notifications Renders 【…】 system/notification blocks as boxed tables in the Reader
Chapter Spacing Normalizes paragraph spacing
Unit Converter Converts Chinese/metric units in translations, with annotate or replace modes and LLM false-positive filtering
Partial Repair Re-translates lines that still contain source-language characters after the main pass
novel543 / twkan Site-specific boilerplate strippers for scraped sources

Enabling, disabling, or reconfiguring a module backfills (or reverses) the transformation across the whole book — as a background task with progress in the UI and guardrails so conflicting operations can't run concurrently. Module activity is summarized to the activity log without per-chapter spam.

Infrastructure

  • Dual database backend — SQLite by default, MySQL (with connection pooling) via DB_BACKEND=mysql; schema migrations run automatically
  • Object storage / CDN — covers, illustrations, and EPUBs can be offloaded to S3-compatible storage (DigitalOcean Spaces) and served from CDN URLs
  • Activity log & cost tracking — persistent activity feed plus a per-call API log with token counts
  • Operations — systemd service, watchdog, health endpoint, reverse-proxy configs for Apache/Nginx, and a pytest suite covering the DB layer, HTTP API, and text pipelines

Quick Start

Prerequisites

  • Python 3.10+
  • Node.js 18+ and npm
  • At least one AI provider API key (or a Claude Code or Codex login for the claudecode / codex providers)

Installation

git clone https://github.com/SpiraMirabilis/translate
cd translate

# Python dependencies
pip install -r requirements.txt
pip install -r web/requirements_web.txt

# Frontend dependencies
cd web/frontend && npm install && cd ../..

API Keys

Create a .env file in the project root:

# Add the providers you want to use
OPENAI_KEY=sk-...
ANTHROPIC_KEY=sk-ant-...
GOOGLE_AI_KEY=AIza...
DEEPSEEK_KEY=sk-...
OPENROUTER_KEY=sk-or-...

# Optional: set default models
TRANSLATION_MODEL=claude:claude-sonnet-4-6
ADVICE_MODEL=oai:gpt-5-mini

API keys can also be set through the web GUI on the Settings page. Non-secret settings (models, site branding, feature toggles) live in settings.json, managed from the Settings page — .env is only for secrets and infrastructure.

Launch

./start_web.sh

This starts both the backend API server and the frontend dev server. Open http://localhost:5173 in your browser.

To stop, press Ctrl+C — both servers shut down together.

Getting Started

Once T9 is running, here's how to translate your first book.

1. Create a book

Go to Books and click New Book. Enter a title and author, then pick a genre preset. The genre determines the source language and loads an optimized system prompt — for example, "Chinese Xianxia" includes instructions for cultivation terminology, while "Japanese Light Novel" handles honorifics and Japanese narrative conventions. You can also choose "Custom" and write your own prompt, or check Original work to write fiction directly in the browser instead of translating.

2. Upload your chapters

Go to Queue and upload your source material:

  • EPUB / FB2 — upload the file and assign it to your book. T9 extracts each chapter automatically and adds them to the queue with sequential chapter numbers (FB2/FB2.zip covers Russian sources).
  • Text files — upload individual .txt files, many at once. Chapter numbers are auto-detected from filenames when possible.
  • Paste — for a single chapter, go to the Translate page, paste the source text, and translate it there.

3. Start translating

On the Queue page, select your translation model (and optionally an advice model for entity suggestions and a cleaning model for filtering false-positive entities). Click Process Next to translate one chapter, or enable Auto-process to translate them back-to-back. Check Save as drafts if you want to schedule the releases yourself instead of publishing immediately.

4. Review entities

When the translator finds new proper nouns — character names, places, organizations — it pauses and shows you a review panel. Check each translation, fix mistakes, delete any common words that were misidentified as entities, and click Submit. Translation resumes with the corrected glossary, and those terms stay consistent for every future chapter.

5. Proofread

After a chapter finishes, go to Books, expand the book, and click Edit on the chapter. The split-pane editor shows the source text on the left and the editable English translation on the right. You can proofread and fix the translation while the next chapter processes in the background. Mark it proofread when you're satisfied.

6. Publish

Chapters from the translation pipeline go live immediately by default; original-work chapters are born as drafts. Use the publish chip in either editor (or the batch Publish action on Books) to publish now, schedule for later, or set up a drip release. Then share your public library URL, export an EPUB, or push to WordPress.

Supported Providers

Provider Alias Example Models API Key Env
OpenAI oai gpt-5.4, gpt-5-mini, o3-mini OPENAI_KEY
Anthropic claude claude-sonnet-4-6, claude-opus-4-6, claude-haiku-4-5 ANTHROPIC_KEY
Google Gemini gemini gemini-2.5-flash, gemini-2.5-pro GOOGLE_AI_KEY
DeepSeek ds deepseek-chat DEEPSEEK_KEY
OpenRouter or any model on OpenRouter OPENROUTER_KEY
Claude Code cc sonnet, opus (none — uses your local Claude Code login)
Codex cx gpt-6.2-sol, gpt-6.2-astra, gpt-6.1-sol, gpt-6.1-terra, gpt-6-luna (none — uses your local Codex / ChatGPT login)
Antigravity CLI ag gemini-4-neon-medium, gemini-4-hydrogen-medium, gemini-4-argon-medium, gemini-3.8-flash-medium (none — uses your local agy login)

Model format: provider:model-name (e.g. claude:claude-sonnet-4-6, cc:sonnet, cx:gpt-6-luna)

The cc and cx providers shell out to the Claude Code and Codex CLIs, so translation costs come out of a Claude or ChatGPT subscription instead of API billing. When a usage limit is hit mid-queue, T9 parks the job and resumes automatically when the limit resets.

cx runs each call as an ephemeral codex exec turn in an empty directory with a read-only sandbox, your Codex config ignored, and Codex's agent tools switched off. That keeps Codex's own per-call overhead to about 4k input tokens. CODEX_EFFORT sets the reasoning effort (default medium), and CODEX_BIN points at a non-default binary. Codex returns each response whole rather than token by token, so the progress bar jumps once per chunk. Both cx and cc support the optional Research tools module described below.

ag drives Google's Antigravity CLI (agy). agy is an agent harness that normally adds about 9.6k tokens of its own instructions and a large tool list (browser, shell, file edits) to every call, so T9 runs each call as a throwaway custom agent with excludeDefaultComponents: true and no built-in tools: the translation prompt is the agent's entire system prompt (a trivial call costs ~430 input tokens instead of ~9.6k). agy also stores every call (a ~1 MB conversation, search-index rows, previews, a log) and has no option to stop it, so each call runs with its own throwaway home holding a private copy of the sign-in (with personal MCP configs/plugins excluded); the whole directory is deleted afterwards, and nothing accumulates. A token agy refreshes during a call is saved back only if it is valid and no other call saved a newer one. The call runs with --sandbox; the user prompt goes in on stdin as one stream-json message, and the answer streams back token by token. Account limits (subscription quota, spend cap, prepaid balance) pause the queue the way a Codex usage limit does. Reasoning effort is part of the model id (gemini-4-neon-medium, -high, …). AGY_BIN points at a non-default binary. ag also supports the optional Research tools module described below (attaching only the scoped read-only t9 MCP server with its 9 eager tools and scoped mcp(t9/<tool>) permissions in the call's throwaway home, enforcing the lookup budget, and stripping pre-tool prose).

To enable research, run the existing read-only MCP service (deploy/t9-mcp-readonly.service, or python3 -m mcp_server --read-only --transport streamable-http --port 8766). In a book's Modules, set Research tools to On. Auto follows Settings → Let CLI translation models use research tools; Off overrides that default. The feature is disabled by default. The legacy claude_code_tools module ID, claude_code_mcp_tools / CLAUDE_CODE_MCP_TOOLS toggle, and claude_code_mcp_url / CLAUDE_CODE_MCP_URL endpoint are retained for compatibility. The standard Docker Compose deployment starts this same server automatically; it uses private loopback in T9's network namespace, with no published MCP port. Research use still requires enabling the existing settings. See Docker research setup.

Research uses nine existing tools: glossary list/search, entity context, chapter reads/summaries/search, book metadata, book grep, and historical notes. The server enforces the book and current-or-earlier chapter boundary supplied by T9 on every request, including queued source text. The boundary must identify a stored or queued chapter. Missing/invalid/unverifiable scope, another book, future chapter reads, and unscoped tools are refused. Broad chapter queries are intersected with the boundary; chapter search applies the boundary in SQL before matching.

Glossary tools reuse T9's existing queries with origin_chapter <= current chapter. They retain current renderings, gender and category, including category filters. Book entries and global entries follow the existing glossary query semantics; unknown origins do not satisfy the boundary. Notes use the existing notes_as_of() rewind: undated corrections stay applied, and legacy notes keep the closest known state. Renderings and gender are never rewound. No chapter prose is fetched to verify entity records. Stored chapter text itself is not versioned; later human edits to an earlier chapter remain visible. Review clients using stdio or the full MCP server keep their existing access. Scope headers are a trusted-local contract, not remote authentication; keep the service on loopback.

Reproduce the synthetic performance check with python benchmark_research_scope.py (900 chapters, 5,000 entries; no real database). The benchmark asserts current fields, corrected renderings, historical notes, and zero chapter-prose queries. On local SQLite fixtures matching the review's two reported book sizes, three-run medians were:

Chapters / entities Full list before → after Single-name search before → after
685 / 12,000 510 → 58 ms 77 → 57 ms
1,754 / 7,700 701 → 40 ms 123 → 34 ms

These synthetic results are not production MySQL latency estimates. The maintainer's production measurements remain the baseline: 22.2–26.2 seconds for large scoped lists, 2.5–2.8 seconds for one-name search, versus the existing search median of 112 ms (p95 465 ms). Removing chapter transfers/scans addresses that regression without increasing timeouts or adding a cache.

Providers check /health for read-only mode and scope support. An unreachable service retains the existing fallback without tools. A reachable service with an outdated, missing or incompatible health contract raises an actionable translation error instead of silently disabling research: restart the read-only service after upgrading, then retry. No tools are sent to an incompatible or full-access server. MCP initialization/tool failures remain optional and the model is told to return only the translation. Usage is recorded in logs/mcp_usage.log; Docker explicitly uses /data/logs/mcp_usage.log on its persistent data mount.

Codex receives only the T9 server and its research-tool allowlist through explicit -c overrides, while retaining --ignore-user-config, its login, the read-only sandbox, and disabled shell/web/apps/plugins. MCP connections are made by the CLI outside the command sandbox; they do not require enabling sandbox network access. Codex CLI must support Streamable HTTP MCP, headers, and enabled_tools (validated with CLI 0.162.1 and 0.170.0). No CLI --max-turns equivalent exists: Codex gets a prompt budget of max_turns - 1 lookups and the provider aborts/reaps a call that exceeds it. Code-mode models receive T9 as a direct tool namespace so lookups stay observable. An excess read may already be in flight when its JSON event arrives. This fails the chunk through the usual retry path without saving partial output. Claude Code keeps its existing native turn cap. Both providers exclude tool output and intermediate reasoning from translations.

Codex CLI 0.162.1 and later (re-checked on 0.170.0) support features.code_mode.direct_only_tool_namespaces: strict configuration parsing accepts ["mcp__t9"] and rejects an invented sibling key. This matches the official configuration reference. The CLI also requires agents.enabled=false to hide agent tools; the legacy features.multi_agent=false override is retained for older versions. Real CLI smoke tests verified direct T9 lookups with agent tools absent. Successful calls allow up to five seconds for normal CLI exit before termination, so post-turn shutdown can persist refreshed subscription credentials. Errors, lookup-budget failures and canceled streams still terminate the isolated process group immediately; a stalled successful shutdown uses the same bounded cleanup.

Providers can be configured and new models added by editing providers/models.json.

Web GUI Pages

Translate (Dashboard)

The main workspace for single-chapter translation. Paste source text, select a book and chapter, choose your models, and hit Translate. The right panel streams the translation output in real time and shows a status log. Options include entity review, entity cleaning, partial repair, unit conversion, and save-as-draft.

Books

Book and chapter management hub. Create books with genre presets, upload cover images, set custom system prompts, manage entity categories, and configure per-book modules. Chapters show draft/scheduled/published state and can be edited, marked proofread, deleted, requeued for retranslation, or batch-published with a drip schedule. Global cross-chapter search (Ctrl+F) jumps directly into the editor. Export EPUBs or publish to WordPress from here.

Chapter Editor

Split-pane proofreading view with source text on the left (read-only) and editable English translation on the right: entity highlighting with inline editing, CC-CEDICT dictionary lookup, selection-based LLM retranslation with ruby-text comparison, chapter- and book-wide search & replace with regex and undo, and the publish chip.

Write Editor

WYSIWYG editor for original fiction (and any translation chapter you open it on). Formatting toolbar and bubble menu, tables, underline/color, inline illustrations, footnotes, live word count and daily goal, focus/typewriter mode, grammar checking with LLM polish, revision history slide-over, and autosave with conflict protection. Storage stays Markdown under the hood, and a round-trip guard blocks any save the serializer can't reproduce exactly.

Entities

Browse, search, edit, and manage the entity glossary. Per-entity categories, gender tracking, translation notes (included in AI prompts), AI advice from a secondary model, dictionary lookup, duplicate detection, and propagation — change an entity's translation and find-and-replace it across all chapters or requeue affected chapters.

Queue

Batch processing for translating many chapters in sequence. Upload .txt, EPUB, or FB2 files, assign them to books, and process back-to-back. Auto-process mode translates continuously, pausing only for entity review.

Comments

Moderation queue for reader comments: approve, delete, reply as admin, ban IPs (optionally pushed to the Cloudflare edge), and review what the AI auto-moderator flagged.

Recommendations

Reader-submitted recommendations from the public form, with admin review.

Stats & Logs

Reader statistics (views per book/chapter), the API call log with per-call token counts and costs, and the persistent activity log.

Settings

Configure provider API keys (with test buttons), default models, site branding for the public reader, the public library toggle, unit conversion rules, traditional→simplified conversion, grammar checking, comment auto-moderation, and WordPress credentials. Non-secret values persist to settings.json; secrets go to .env.

Reader & Library

The same Reader and Library that the public sees, accessible from the admin UI. When the public library is enabled, unauthenticated visitors can browse published books, read published chapters, comment, subscribe to RSS, and download EPUBs — with drafts and scheduled chapters invisible until they go live.

The Public Site

Everything a reader touches is gated on publication state at query time:

  • Library (/library) lists public books with published-chapter counts and last-release dates.
  • Reader serves only published chapters; scheduled chapters appear the moment their time arrives — no cron job, no restart.
  • EPUB download contains published chapters only and regenerates automatically when a scheduled chapter crosses its publish time.
  • RSS — /api/public/feed.rss (site-wide) and per-book feeds with autodiscovery <link> tags on reader pages.
  • Comments are anonymous with Turnstile verification; commenters can opt into email notifications for replies (sent via local Postfix, with unsubscribe links). Comments on unpublished chapters 404.
  • Covers and illustrations are served from CDN URLs when Spaces offload is enabled.

A standalone Apache config (deploy/apache2-reader.conf) exposes only the public surface if you want the admin UI reachable on a separate host or VPN.

WordPress / Fictioneer Publishing

T9 can publish translated books directly to a WordPress site running the Fictioneer theme. A small companion plugin (deploy/fictioneer-rest-meta.php) handles Fictioneer-specific metadata like chapter-to-story linking, word counts, and story ordering.

Setup:

  1. Install the plugin on your WordPress site — copy deploy/fictioneer-rest-meta.php to wp-content/plugins/fictioneer-rest-meta/ and activate it, or run bash deploy/install-wp-plugin.sh /path/to/wordpress.
  2. Create an Application Password in WordPress (Users > Profile > Application Passwords).
  3. Configure T9 — go to Settings and fill in your WordPress URL, username, and the application password. Click Test Connection to verify.
  4. Publish — go to Books, click the globe icon on a book, set the story status and rating, and click Publish All.

Re-publishing is safe and incremental — unchanged chapters are skipped, modified chapters are updated, and new chapters are created. See the Help page in the web GUI for detailed setup instructions and troubleshooting.

Project Structure

t9/
├── start_web.sh           # Launch script (backend + frontend dev server)
├── run_web.py             # Alternative launcher (Python, no Vite)
├── translator.py          # CLI entry point
├── translation_engine.py  # Core translation logic
├── database.py            # Compatibility shim → db/ package
├── db/                    # Database layer: repos (books, chapters, entities,
│                          #   queue, footnotes, revisions, ...), migrations
├── db_backend.py          # SQLite/MySQL backend abstraction
├── modules/               # Per-book transform modules + background task runner
├── providers/             # AI provider modules + models.json
├── prompts/               # System prompt templates per genre
├── genres.json / genres.py
├── epub_processor.py      # EPUB import
├── fb2_processor.py       # FB2 (FictionBook) import
├── output_formatter.py    # Text/HTML/Markdown/EPUB rendering
├── illustrations.py       # ⟦IMG⟧ marker pipeline
├── footnotes.py           # Footnote persistence & re-anchoring
├── spaces.py              # S3/Spaces (CDN) offload
├── settings_store.py      # settings.json (non-secret runtime settings)
├── web/                   # Web GUI + public site
│   ├── app.py             # FastAPI application
│   ├── auth.py            # Session-based authentication
│   ├── cedict.db          # CC-CEDICT Chinese dictionary
│   ├── api/               # REST + WebSocket endpoints (admin + public)
│   ├── services/          # Job manager, exporters, view logger, ...
│   └── frontend/          # React + Vite + Tailwind CSS
│       └── src/pages/     # Dashboard, Books, ChapterEditor, WriteEditor,
│                          # Entities, Queue, CommentsAdmin, Recommendations,
│                          # ReaderStats, ApiCalls, Settings, Help,
│                          # Reader, Library, Login
├── tests/                 # pytest suite (DB layer, HTTP API, text pipelines)
├── deploy/                # systemd units, watchdog, reverse-proxy configs,
│                          # WordPress plugin
├── requirements.txt
└── database.db            # SQLite database (created on first run)

CLI

T9 also has a full command-line interface that supports all operations — translation, book/chapter management, entity review, queue processing, and more. See CLIReadme.md for complete documentation.

Authentication

T9 includes built-in password authentication. If you expose this app to the internet — on a VM, VPS, or through a tunnel — you must enable authentication. Without it, anyone who finds your URL has full access to your API keys, translation data, and database.

To enable it, add T9_PASSWORD to your .env:

T9_PASSWORD=your-secure-password-here

When set, all admin API endpoints and WebSocket connections require a valid session. The public reader endpoints are separate and intentionally unauthenticated — they only ever serve published content from public books, and only when the public library is enabled.

When T9_PASSWORD is not set, authentication is disabled entirely — appropriate for local-only use on 127.0.0.1.

If serving over HTTPS (which you should be, if network-exposed), also set T9_SECURE_COOKIE=true in .env so the session cookie is only sent over encrypted connections.

Your .env file contains API keys and your app password. Lock down its permissions:

chmod 600 .env

Deployment

The deploy/ directory contains ready-to-use configuration files for running T9 on a server.

systemd service

A systemd --user service that manages the app, with a pre-flight check that refuses to start if T9_PASSWORD is not set in .env.

# Build the frontend for production (no Vite dev server needed)
cd web/frontend && npm run build && cd ../..

# Install the service
mkdir -p ~/.config/systemd/user
cp deploy/t9.service ~/.config/systemd/user/

# Edit paths in the service file if your install location differs

systemctl --user daemon-reload
systemctl --user start t9
systemctl --user status t9

# Enable on boot
loginctl enable-linger $USER
systemctl --user enable t9

# View logs
journalctl --user -u t9 -f

Note on lingering: systemctl --user services normally live and die with your login session — without lingering enabled, T9 will stop when you log out and won't start on boot. loginctl enable-linger $USER fixes that, but on many distros it requires root (or polkit authorization), so you may need sudo loginctl enable-linger $USER. Verify with loginctl show-user $USER --property=Linger — it should say Linger=yes.

Watchdog service

An optional watchdog (deploy/t9-watchdog.service + deploy/t9_watchdog.py) monitors the T9 health endpoint and recovers the service if it becomes unresponsive.

LanguageTool grammar server (optional)

The write editor's grammar check proxies to a local LanguageTool HTTP server. bash deploy/setup-languagetool.sh downloads the release, writes the server config, and installs it as a systemctl --user service on 127.0.0.1:8081; add --with-ngrams to also fetch the ~8 GB English ngram data that powers confusion-pair rules (their/there, its/it's). The script is heavily commented for adapting to non-Debian or non-systemd systems. T9 runs fine without it — grammar checking just stays unavailable.

Reverse proxy

Sample configurations for Apache2 and Nginx are in deploy/. Both include HTTPS redirection, WebSocket proxying (important for real-time translation progress and entity review), and appropriate timeouts for long-running WebSocket connections.

  • deploy/apache2-reverse-proxy.conf — requires mod_proxy, mod_proxy_http, mod_proxy_wstunnel, mod_ssl, mod_rewrite
  • deploy/nginx-reverse-proxy.conf — includes a 1-hour proxy_read_timeout on /ws so the connection survives long entity review waits
  • deploy/apache2-reader.conf — standalone config for exposing only the public library/reader

Replace t9.example.com with your actual domain. Both examples assume Let's Encrypt certificates via certbot.

MySQL (optional)

SQLite is the default and needs no setup. For a heavier deployment, set DB_BACKEND=mysql plus the MYSQL_* variables — the schema is created and migrated automatically, and the same code paths run against either backend.

Environment Variables

Secrets and infrastructure go in .env; most other settings are managed from the Settings page (persisted to settings.json).

Variable Description
OPENAI_KEY / ANTHROPIC_KEY / GOOGLE_AI_KEY / DEEPSEEK_KEY / OPENROUTER_KEY Provider API keys
TRANSLATION_MODEL Default translation model (e.g. claude:claude-sonnet-4-6)
ADVICE_MODEL Default entity advice model
T9_PASSWORD Enable authentication (required if exposed to the internet)
T9_SECURE_COOKIE Set to true when serving over HTTPS
T9_PUBLIC_LIBRARY Enable the public library/reader
SITE_NAME / PUBLIC_SITE_NAME Branding for the admin UI / public site
SITE_BASE_URL Public base URL — used for RSS links and email links
GTM_ID Google Tag Manager container ID (GTM-XXXXXXX) for the public reader; blank = no analytics. The admin host never gets the snippet
DB_BACKEND sqlite (default) or mysql
MYSQL_HOST / MYSQL_PORT / MYSQL_USER / MYSQL_PASS / MYSQL_DB / MYSQL_POOL_SIZE MySQL connection settings
SPACES_ENABLED / SPACES_BUCKET / SPACES_REGION / SPACES_PREFIX / SPACES_CDN_BASE S3-compatible object storage (DigitalOcean Spaces) offload
BUCKET_ACCESS_ID / BUCKET_SECRET / BUCKET_ENDPOINT Object storage credentials
BACKUP_BUCKET / BACKUP_BUCKET_REGION / BACKUP_BUCKET_ENDPOINT Private bucket for MySQL dumps (no CDN) — see backup_mysql.sh
BACKUP_BUCKET_ACCESS_ID / BACKUP_BUCKET_SECRET Backup-bucket credentials; fall back to BUCKET_ACCESS_ID/BUCKET_SECRET
CF_TURNSTILE_SITE_KEY / CF_TURNSTILE_SECRET_KEY Cloudflare Turnstile for comments & recommendations
CF_API_EMAIL / CF_API_KEY Cloudflare credentials for pushing comment IP bans to the edge
COMMENT_AUTOMOD_ENABLED / COMMENT_AUTOMOD_MODEL AI auto-moderation of new comments
EMAIL_FROM Sender address for comment reply notifications (local Postfix)
TRAD_TO_SIMP Global default for traditional→simplified conversion at ingest
GRAMMAR_CHECK_ENABLED / LANGUAGETOOL_URL / GRAMMAR_LANGUAGE / POLISH_MODEL Write-editor grammar checking & LLM polish
WP_URL / WP_USERNAME / WP_APP_PASSWORD WordPress publishing credentials
OVERLOAD_RETRY_WAIT_SECONDS Wait between retries when a provider returns 529 Overloaded (default 300)
DEBUG Enable debug logging (True/False)

License

MIT

About

A translation and publishing platform

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages