{
  "id": 22448825,
  "title": "Building a Layout-Preserving Bilingual Web Translator & Streaming Batch LLM Extension in MV3",
  "url": "https://urgent.news/2026/11/28/building-a-layout-preserving-bilingual-web-translator-streaming-batch",
  "topic": "ai",
  "section": "AI",
  "published": "2026-11-28T21:23:22.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/wang_hao_1eede9603abfba7e/building-a-layout-preserving-bilingual-web-translator-streaming-batch-llm-extension-in-mv3-3c8p"
  },
  "original_language": null,
  "account": "Browser translation extensions often encounter three common user experience issues: translated font or span tags disrupt compact flex navigation bars and buttons. Translating lengthy articles sentence by sentence with an LLM is sluggish and inefficient, wasting tokens on repetitive system prompts. Many contemporary extensions demand user accounts, subscriptions, or intrusive advertisements. To address these problems, I developed Modern Translator (GPL-3.0, v1.1.1), an entirely free, ad-free, and open-source browser extension for Chrome, Edge, and Firefox (version 140 and above).\n\nModern Translator employs a layout engine called Spatial-Budget Bilingual Layout & Ruby Rail Solver. Rather than indiscriminately appending text beside each DOM node, the engine calculates available spatial budgets for inline and block elements. Regular prose paragraphs are rendered in smooth bilingual blocks. Compact UI elements, such as navigation bars, buttons, and badges, automatically transition to Ruby dual-line stacking, preventing translations from overflowing or awkwardly wrapping menus. Translation segments identical to the source text (like code identifiers, proper nouns, and matching abbreviations) are skipped automatically.\n\nThe Super-Streaming LLM Batch Scheduler in Manifest V3 service worker (src/background/llmBatchStream.js) is another key feature. By grouping adjacent viewport segments into streaming batch calls, the latency is reduced, and token usage is minimized by sharing context across paragraphs. This scheduling works in harmony with a global translation cache (translationCache.js), ensuring that toggling between bilingual, original, and translation modes is instantaneous. The extension supports Google Translate, Microsoft Translator, any OpenAI-compatible endpoint, and an optional community-sponsored free LLM quota.\n\nModern Translator also incorporates Shadow DOM Isolation and Cross-Iframe Selection. Popovers and floating controls are mounted within isolated Shadow DOM trees (react-shadow), ensuring that host stylesheets (from sites like GitHub, Notion, and documentation pages) do not leak. Chrome MV3 clipboard writes and TTS audio playback occur via an offscreen document, while Firefox utilizes a compatible background.scripts manifest automatically.\n\nIn version 1.1, Modern Translator expanded its functionality to transform video players into a language study workspace. Subtitle jump and replay functions (represented by / shortcuts) are integrated directly within the player. The AI pre-study component creates vocabulary flashcards, extracted chapter by chapter (including IPA pronunciation, CEFR level, timestamp jump, and self-test mode). A local wordbook, complete with mastery tracking and one-click TSV export compatible with Anki and Excel, is also included. All settings, custom API keys, and the wordbook remain strictly on your device; no login is required. Modern Translator's source code is freely available on GitHub under the GPL-3.0 license, and it is available on the Chrome Web Store and Microsoft Edge Add-ons. Users are encouraged to provide feedback, report issues, and submit pull requests.",
  "summary": "Most browser translation extensions suffer from three recurring UX problems: Appending translated or tags inline breaks compact flex navbars and buttons. Translating an entire article sentence-by-sentence with an LLM is slow and wastes tokens on repeated system prompts. Many modern extensions require accounts, subscriptions, or inject ads. I built Modern Translator (GPL-3.0, v1.1.1) — a…",
  "summary_source": "publisher",
  "key_points": [
    "Modern Translator solves UX issues in browser translation extensions",
    "Layout engine Spatial-Budget Bilingual Layout & Ruby Rail Solver maintains UI elements",
    "Super-Streaming LLM Batch Scheduler reduces latency and token usage"
  ],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}