Universal immersive page translation extension for ETAF
- Emacs Lisp 99.3%
- Makefile 0.7%
Default scripts/publish-packages.py to project from main without --allow-backwards and add unit tests covering revision and safety flags. Add standalone-clone guards to acceptance and api-check targets across all package Makefiles, and align etaf-manual book version tables with current package headers (etaf 0.3.18, etaf-manual 0.1.26). Validation: make structure-check; python3 -m unittest tests/tools/test_publish_packages.py tests/tools/test_repository_policy.py; make -C packages/etaf-manual book-check; make -C packages/ecss check; make -C packages/etaf-install check |
||
|---|---|---|
| docs | ||
| lisp | ||
| tests | ||
| .gitignore | ||
| CHANGELOG.md | ||
| etaf-translate.el | ||
| LICENSE | ||
| Makefile | ||
| README.md | ||
| README.zh-CN.md | ||
etaf-translate
Universal immersive page translation for any mounted ETAF View, plus a lightweight pure-translation quick popup for any Emacs buffer.
Capabilities
- Native
etaf-extextension: registers directly with etaf-ext for shared Host tree caching, atomic multi-owner presentations (companion-inside,companion-after,override), unified mode-line badges, Pure Mode, circuit-breaker isolation, and management insideM-x etaf-ext-manage. - Five focused commands:
etaf-translate-toggle,etaf-translate-panel,etaf-translate-at-point,etaf-translate-paragraphandetaf-translate-mode-cycle— zero redundant minor modes or overlapping commands. - Two modes and three editorial styles: bilingual stacked (
left-bar,muted,tinted) and in-place replacement with hover-original:help-echo— switching instantly from cache. - Minimal floating UI: slim 6-row top-right control panel (
etaf-translate-panelwith live:theme 'autofollowing, automatic sparse persistence toetaf-translate-state-file, and auto-dismiss on buffer switch), pure-translation quick popup (etaf-translate-at-pointtranslating active region or word at point without repeating original text, auto-sizing up to 60% frame height with scrolling), and a clickable buffer-local Mode-line indicator (译[54/155]/译✓/译!N) that preserves the active theme's mode-line. - Structure- and math-aware extraction: groups inline runs into paragraphs, preserves clickable links and emphasis via
<N>...</N>, protects inline code, footnotes and LaTeX math ($...$,$$...$$,\(...\),\[...\]without misclassifying currency) via atomic⟦cN⟧placeholders, skips code blocks and UI chrome, and honors:translate 'no. - Viewport-first streaming & persistent L2 cache: tracks live Host visibility across Emacs windows and
:overflow 'scrollcontainers, streams SSE replies paragraph-by-paragraph, dynamically re-prioritizes on scroll, retries and cascades through a configurable fallback engine, and persists translations in an Emacs 29+ native SQLite WAL L2 cache alongside remembered site rules and glossaries. - Multi-engine suite & built-in providers: built-in
openai(OpenAI / DeepSeek / Ollama SSE),anthropic(Claude Messages SSE),deepl(Free/Pro batch),google(zero-key HTTP),commandandfunctionengines; named profiles; context title and prompt-style presets (technical,academic,literary,concise); and built-in logical-paragraph providers formaillistandetaf-readerplus domain/app rules foretaf-web,etaf-md,etaf-org,etaf-manual,etaf-rssandetaf-telega.
Prerequisites
- Emacs 29.1 or newer (built-in SQLite enables persistent L2 caching automatically; degrades cleanly to L1 memory otherwise)
etaf(>= 0.3.6),etaf-ui(>= 0.3.4),etaf-posframe(>= 0.3.0) andetaf-ext(>= 0.1.0)curlonexec-pathfor the HTTP engines (openai,anthropic,deepl,google)
Minimal Example
;;; -*- lexical-binding: t; -*-
(require 'etaf-translate)
(setq etaf-translate-target-lang "zh-CN"
etaf-translate-default-engine 'openai
etaf-translate-openai-endpoint "https://api.deepseek.com/v1/chat/completions"
etaf-translate-openai-model "deepseek-chat"
etaf-translate-openai-api-key (lambda () (getenv "DEEPSEEK_API_KEY")))
;; Inside any mounted ETAF buffer (etaf-web, etaf-md, maillist, etaf-reader, ...):
(etaf-translate-toggle)
;; Toggle the slim top-right control panel:
(etaf-translate-panel)
;; Quick-translate the active region or word at point in any Emacs buffer:
(etaf-translate-at-point)
Documentation
- Public API inventory: etaf-translate.el
- Usage and extension guide: docs/manual.md
- Maintainer architecture: docs/architecture.md
Validation
make -C packages/etaf-translate check