> For AI agents: the complete documentation index is available at /Prism/llms.txt, the full documentation bundle is available at /Prism/llms-full.txt.

# Page-Synced Bilingual PDF Reading Companion (`/bilingual-read`)

Reading dense English or foreign-language research papers page-by-page often forces constant switching between Zotero and external translation tools—breaking reading flow, corrupting LaTeX formulas, or burning expensive LLM tokens on routine page translation.

Prism's **Page-Synced Bilingual PDF Reading Companion (`/bilingual-read`)** turns your right-hand sidebar into a live, scroll-synchronized translation companion powered by **dedicated non-AI Machine Translation APIs** by default (**zero AI token cost**), while keeping your mathematical notation crisp via offline **KaTeX** and preserving instant access to AI explanations whenever you select a tricky term.

:::tip Zero-AI-Token Dedicated Translation Engines by Default
Out of the box, Bilingual Read uses free, zero-key **Google Translate** (with automatic **Bing Translator** failover and **MyMemory** support)—consuming **0 LLM tokens** and requiring **no API key**. You can also switch to **DeepL**, **Azure / Bing Translator API**, **Google Cloud Translation v2** (BYOK keys stored encrypted in your OS keychain via Zotero's Login Manager), or **100% offline self-hosted LibreTranslate** anytime.
:::

## 1. Ways to Launch

| Entry Point                              | How It Works                                                                                                                                                            |
| ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Context Bar `Bilingual` Pill**         | Click the compact **`Bilingual`** toggle pill right inside the active paper Context Bar whenever a PDF is open.                                                         |
| **Sidebar `Studios ▾` → Bilingual Read** | Toggle the Bilingual Reading Companion from the top-bar Studios menu.                                                                                                   |
| **Chat Slash Command**                   | Type **`/bilingual-read`** (optionally followed by a page number like `/bilingual-read 4` or target language like `/bilingual-read Japanese`) directly in the composer. |
| **Command Palette (`⌘K` / `Ctrl+K`)**    | Press **`⌘K`** / **`Ctrl+K`** → **Bilingual Read**.                                                                                                                     |

## 2. Supported Translation Engines

Configure your default engine in **Settings → MCP & Web → Bilingual PDF Reading Companion** or switch live from the Bilingual Read toolbar:

| Engine                                   | API Key Required? |          Privacy / Local?         | Notes                                                                                    |
| ---------------------------------------- | :---------------: | :-------------------------------: | ---------------------------------------------------------------------------------------- |
| **Google Translate (Free)** _(Default)_  |         No        |               Cloud               | Fast zero-key GTX translation with automatic mirror & Bing failover.                     |
| **Bing Translator (Free)**               |         No        |               Cloud               | Zero-key Edge/Microsoft batch translator (`v3`) with native multi-paragraph arrays.      |
| **MyMemory Translate (Free)**            |         No        |               Cloud               | Free community translation fallback.                                                     |
| **DeepL API (BYOK)**                     |      Optional     |               Cloud               | Auto-detects Free (`:fx` → `api-free.deepl.com`) vs. Pro (`api.deepl.com`) keys.         |
| **Azure / Bing API (BYOK)**              |      Optional     |               Cloud               | Official Azure Cognitive Services Translator v3 with configurable region.                |
| **Google Cloud Translate v2 (BYOK)**     |      Optional     |               Cloud               | Official Google Cloud Translation v2 REST API.                                           |
| **LibreTranslate (Local / Self-Hosted)** |      Optional     | **100% Offline** when on loopback | Point to `http://127.0.0.1:5000` for zero-cloud translation of confidential manuscripts. |

## 3. Page Sync, Layout & KaTeX Formula Fidelity

1. **Debounced Reader Scroll Sync:** As you flip or scroll pages in Zotero's PDF Reader, Prism tracks `Page N / M` with a **350 ms debounce** and immediate `AbortController` cancellation on rapid page flips so intermediate pages never waste bandwidth.
2. **Equation & Code Shielding:** Before calling any translation API, Prism strips running headers, page numbers, and arXiv stamps, rejoins soft line-wraps and hyphenations, skips standalone display equations from MT payloads, and shields inline/display LaTeX (`$...$`, `$$...$$`, `\alpha_t`, `\mathbb{R}^d`), inline code spans, URLs, DOIs, and citation brackets (`[1, 2]`) using safe sentinel tokens—restoring and rendering every formula crisply via **offline KaTeX**.
3. **Bilingual & Clean Modes:** Switch seamlessly between **Bilingual** (stacked original + translated paragraph pairs) and **Clean** (translation-only stream) in one click.
4. **Independent Target Language:** Defaults to your independent **Translation Language** setting (**Settings → General & Persona → Translation Language**) without coupling to your general chat response language, and includes a 1-click toolbar dropdown covering 14+ target languages.

## 4. Instant Disk Cache, Click-to-Highlight & Term Deep-Dives

- **Zero Repeat Cost & 1-Page Prefetch:** Translated pages are cached deterministically on disk (`<ZoteroProfile>/prism-cache/translations/<attachmentKey>.json`) keyed by `(pageNumber, targetLang, engine, textHash)` so revisiting pages loads in `< 10 ms`. Optional **1-page lookahead prefetch** silently prepares `Page N + 1` in the background, and you can toggle **Auto / Paused** sync or **Re-translate** anytime.
- **Click Paragraph → Highlight in PDF:** Click any translated paragraph card to scroll Zotero's PDF Reader directly to the matching original paragraph with a multi-pulse flashing highlight.
- **Select Text → `Explain` / `Ask in Chat` / `Copy`:** Highlight any translated phrase, technical term, or formula inside the Bilingual Companion to surface a floating micro-bar:
  - **`Explain`** opens Prism's ephemeral **Side Question Drawer** right over the Bilingual Reader with full paragraph context—no need to leave the page.
  - **`Ask in Chat`** attaches the selected quote to your main chat composer and switches straight back to Chat.
- **100% Offline Side-by-Side Exports:** Export the **Current Page** or **All Cached Pages** as clean side-by-side **Markdown (`.md`)** or styled light/dark **Standalone HTML (`.html`)** via the toolbar menu.

## 5. Fail-Closed Local-Only Privacy Guardrails

:::warning Strict Fail-Closed Protection for Confidential PDFs
If the open PDF matches your **Local-Only Privacy Guardrail** rules (e.g., tagged `unpublished`, `confidential`, or inside a protected collection—or if privacy metadata cannot be verified), Prism **blocks all cloud translation APIs** (Google, Bing, MyMemory, DeepL, Azure, Google Cloud, and remote LibreTranslate) before a single word leaves your machine.

On protected PDFs, Prism displays a clear Privacy Guardrail notice with 1-click options to:

1. Translate via a **local loopback LibreTranslate** server (`http://127.0.0.1:5000`), or
2. Explicitly fall back to one of your configured **local loopback LLMs** (Ollama / LM Studio / vLLM).
   :::
