Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Markdown Bilingual SyncNew to Visual Studio Code? Get it now.
Markdown Bilingual Sync

Markdown Bilingual Sync

yxm1122

|
4 installs
| (0) | Free
A translation, review, and export workbench for Markdown technical docs: block-level AI translation, true split preview, locked human edits, briefs, glossaries, and annotations.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Markdown Bilingual Sync

CI License: MIT VS Code Marketplace Version

中文 | English

A translation, review, and export workbench for technical documentation.

Translate Markdown block by block, read it in a true bilingual split preview, review with annotations, and export with a diff. The source stays the single source of truth, and human edits stay locked.

Split bilingual preview: English source on the left, Chinese translation on the right, with translated, stale, and locked counts in the header

Split view: independent scrolling, block-level sync, with translated, stale, and locked counts.

Three layouts: side-by-side, stacked, and split. Split uses two independent panes, not paired blocks stacked in one column.

Three steps

  1. Install from the VS Code Marketplace, or run code --install-extension yxm1122.markdown-bilingual-sync.
  2. Run Markdown Bilingual Sync: Set AI Translation API Key first; pick a provider preset or fill in an OpenAI-compatible endpoint.
  3. Open a .md file and run Translate Current File. Edit, review, and export from the preview.

Requires VS Code 1.95 or later. API keys live only in VS Code SecretStorage; saving the source never calls the translation API. Full provider and batch configuration is under Quick Start; release history is in the CHANGELOG.

Why this exists

Translating technical documentation is not finished when the file has been translated once: terms must stay consistent, human edits must survive the next sync, review notes must be actionable, and batch changes must stay under control. This extension is built around those four problems.

Your edits survive the next sync

Edit a translation in place and save to lock it; nearby blocks show translation locked and source updated states

Edit in place; saving locks the block, and a source change only marks it as locked and stale.

Click a translation to edit it in place. Saving immediately locks the block. Sync, single-block retranslation, and retranslate-all will not overwrite it; when the source changes, the block shows Translation locked · source updated and you choose Mark synchronized or retranslate. Source edits follow the same pattern: stage, review the diff, then write back.

Let the model read the document before translating

Document brief panel with summary, translation guidance, generation locks, and document glossary

Document brief: summary, translation guidance, generation locks, and the document glossary in one panel.

Manually generate a source-language summary, translation guidance (audience, tone, ambiguities, do-not-translate), and a document glossary. The summary describes only the document; guidance stays in the brief. Lock the summary, each of the four brief fields, and the glossary independently; AI generation skips locked items and never overwrites them, while they stay editable and continue to feed translation and review.

Document glossary with term cards pairing payment intent, idempotency key, capture method, rate limit, and webhook

Document glossary: one-row source and target cards; click either side to edit.

The document glossary uses single-row source | target cards; click either side to edit. It joins global and workspace glossaries during translation. The consistency check in the preview toolbar flags glossary and protected-Markdown issues and retranslates each affected block.

Review suggests; you decide

Annotations panel with AI review notes, handling options, and a pending user annotation

AI review only raises notes; adopt, edit, or write your own annotation.

AI review returns notes that may need human verification; it never rewrites the translation. User annotations default to one-shot, can be switched to persistent, and participate automatically in sync, single-block retranslation, and retranslate-all. AI handling options are split into directly usable instructions and read-only advice, and you can write your own.

Batch work with a queue

Block multi-select with three blocks selected and bulk retranslate, review, back-translate, mark synchronized, and delete actions

Select blocks to retranslate, review, back-translate, mark synchronized, or delete in bulk; operations queue.

Click or drag across blocks to select them (Shift-click for a range), then retranslate, review, back-translate, mark synchronized, or delete translations in bulk. Operations on one file run serially while different files run in parallel; the task panel and status bar show running and queued state, and you can keep enqueueing while tasks run.

Features

Translation and sync

  • Blocks as translation units. Translation works on top-level semantic blocks: headings, paragraphs, complete list sections, whole tables, whole blockquotes, and footnote definitions.
  • Protected syntax. Inline code, URLs, and footnote labels are restored before a cache write if the model rewrites them. Footnote definitions are translated while keeping their [^id] labels.
  • Batch translation and incremental sync. Saving the source only marks translations as stale; translation requests are made only by explicit commands.
  • Translation lock. After you edit and save a translation in the cache, that block is protected from automatic retranslation.
  • Back-translate to rewrite the source. Back-translating a block sends the result straight to source staging. Writing it back locks the translation to the new source so sync cannot overwrite it.
  • Stable translation. Retranslation references the previous translation and back-translation references the current source, which reduces wording drift after small edits. Controlled by a setting and a preview toggle.
  • Retranslate a single block, all stale blocks, or all machine translations.
  • Import existing translations. Imports are validated and aligned against the top-level block structure and marked as locked translations. Start from the preview toolbar or the Command Palette.
  • Batch processing. Folder translation packs blocks into batches by token budget, with one concurrency limit shared by files and in-file batches. Successful batches survive failures, and existing caches can be exported in bulk.
  • Cache maintenance. Clear the cache for the current file, or remove every translation cache from extension storage in one step.

Preview and editing

  • Bilingual preview. Side-by-side, stacked, and a true split layout. The split layout gives the source and the translation independent scrolling panes with block-level scroll sync. Renders GFM, syntax highlighting, KaTeX, footnotes, and GitHub Alerts.
  • In-preview editing. Click source or translation content to edit the underlying Markdown in place. A saved translation is locked immediately; source edits can be staged, reviewed as a diff, and then written back.
  • Block multi-select and operation queue. Click or drag across blocks to select them (Shift-click for a range), then retranslate, review, back-translate, mark synchronized, or delete translations in bulk. Operations on one file run serially while different files run in parallel; the task panel and status bar show running/queued state, and you can keep enqueueing while tasks run.
  • Translation Tasks view. A status bar button toggles a native TreeView showing the batch overview, active tasks, recent completions, and runtime status. Clicking a task opens the bilingual preview at its block (or the first block for file batches), while row actions can open the source file or cancel. Consecutive block tasks are grouped into collapsible rows, and hovering shows status plus retry counts. The view title's Change Languages action uses a native QuickPick to switch or swap source/target languages.

Quality and review

  • Document brief, glossary, and generation locks. Manually generate a source-language summary, translation guidance (audience, tone, ambiguities, do-not-translate), and a document glossary. The summary describes only the document; translation guidance stays in the brief. Lock the summary, each of the four brief fields, and the glossary independently; locked items are skipped by AI generation and never overwritten, but remain editable and continue to be used for translation/review. The brief is stored with the translation cache and can be edited or cleared in the preview.
  • Block annotations and review. AI review returns notes that may need human verification; it never rewrites the translation. User annotations default to one-shot, can be switched to persistent, and participate automatically in sync, single-block retranslation, and retranslate-all. Sync retranslates blocks with pending annotations (locked blocks still need a manual single-block retranslation); stable translation still sends the previous-translation reference, but the system prompt explicitly makes annotations override it. Untranslatable or deleted blocks do not accept applicable annotations. AI review can return up to three handling options: an instruction is a self-contained message for the translator with a proposed one-shot/persistent mode, and can be used or edited before use; advice is read-only and only for decisions that need a human. You can also write your own. Adopting an instruction creates a user annotation with that mode and marks the AI annotation answered. Annotations live in a local sidecar, not in the cache Markdown or exports.
  • Layered glossaries. Global and workspace term lists plus an AI-generated document glossary stored with the summary. The preview toolbar can check machine translations for glossary and protected-Markdown issues and retranslate each affected block.

Integration, export, and localization

  • Agent-managed briefs and glossaries. Five native Language Model Tools let Copilot / VS Code agents read, create, and update document briefs, document glossaries, and global/workspace glossaries. Writes are confirmed, refresh open previews, and override generation locks by default while keeping the locks set.
  • Export to a language-suffixed file in the same folder, after confirming a split diff.
  • Structural problems are reported before export or retranslation. The cache write is rejected when the model returns a system prompt, an echoed request, or untranslated source text. Missing inline code or glossary targets trigger one corrective retry first.
  • Any Markdown-like language ID. Works with the standard Markdown language ID and with environment-specific IDs such as skill from Qoder; the file content stays Markdown.
  • Swappable translation service. OpenAI-compatible endpoints or any custom HTTP service, with built-in presets for common providers. API keys are stored only in VS Code SecretStorage.
  • Full localization of the extension: English is the source language, Chinese is loaded when VS Code's display language is zh-cn, and the command and settings manifests switch with it.

Installation

Install Markdown Bilingual Sync from the VS Code Marketplace, or run:

code --install-extension yxm1122.markdown-bilingual-sync

Requires VS Code 1.95 or later (the extension uses Webviews, SecretStorage, WorkspaceEdit, and Language Model Tools).

The main branch may be ahead of the Marketplace build; use the source build below for the latest commits.

Build from Source

Requires Node.js 20 or later:

git clone https://github.com/yxm1122/Markdown-Bilingual-Sync.git
cd Markdown-Bilingual-Sync
npm ci
npm run package

The build output is artifacts/vsix/markdown-bilingual-sync.vsix, which you can install with code --install-extension artifacts/vsix/markdown-bilingual-sync.vsix. To debug, press F5 in VS Code to launch the Extension Development Host; see Development for the full command list.

Quick Start

  1. Open a .md file that has been saved to disk.
  2. Check the language pair in Settings; the default is en → zh-CN.
  3. Run Markdown Bilingual Sync: Set AI Translation API Key and paste your key.
  4. Choose a translation service in Settings, or run Markdown Bilingual Sync: Apply Translation Provider Preset…:
    • Set markdownBilingualSync.provider to openai.
    • Set markdownBilingualSync.apiBaseUrl, for example https://api.openai.com/v1.
    • Set markdownBilingualSync.apiModel, for example gpt-4o-mini.
    • Or set the provider to http and configure httpEndpoint, httpHeaders, httpBody, and httpResponsePath.
  5. Run Markdown Bilingual Sync: Test AI Translation Connection to verify that the endpoint, model or template, and key work.
  6. Run Markdown Bilingual Sync: Translate Current File. The bilingual preview opens in a new tab in the current editor group; the editor window is not split automatically.
  7. Later, after you edit and save the source, run Sync Translation to translate only missing or stale blocks.
  8. For an existing translation, click Import translation in the preview toolbar, or run Import Existing Translation… from the Command Palette, to import it as locked translations.

Workflow & Semantics

Source Text Is the Reference

  • The source is never rewritten automatically. It changes only when you explicitly edit or delete source text, or confirm a back-translation write-back.
  • Saving the source updates stale status and refreshes the preview. It does not call the translation API.
  • Sync Translation processes only missing and stale blocks.
  • Sync, retranslation, and batch translation write to the cache in batches. If a run fails or is cancelled midway, batches already written are kept and missing blocks are retried on the next sync.
  • To switch models or refresh existing machine translations, use Retranslate All. Locked translations are never overwritten.

Translation Lock and In-Preview Editing

  • Click a translated block in the preview to show its original Markdown inline. Save and lock writes it to the global cache and marks the block as a locked translation.
  • You can also run Edit Cache and edit the cache file directly; saving locks the block in the same way.
  • Clicking source content lets you edit the original Markdown inline. Stage changes renders the staged source in the preview immediately and adds an Apply source changes button at the top. Clicking it shows a split diff of Current source and Updated source; confirm to write back to the .md file and save it.
  • Every block has Insert and Delete buttons. Clicking one expands it into Source and Translation choices; the button collapses when the pointer leaves the block.
    • Insert → Source opens an inline editor after the block. Stage new block makes it appear in the preview immediately. Insert at start at the top inserts a block at the beginning of the document.
    • Insert → Translation writes a standalone translation block to the cache. It goes straight into export without touching the source. You can Back-translate that block to generate a source candidate, stage it, and write it back with your other source changes so the two become a pair.
    • Delete → Source marks the block as source pending delete and dims it in the preview; Undo delete restores it. After the write-back, any machine or locked translation for that block is demoted to a standalone locked translation (a target anchor) and kept in exports, while markers for copied blocks and deleted translations are removed.
    • Delete → Translation stores a deletion marker with a backup, keeping the anchor. Later syncs skip the block and exports exclude its content. Undo delete restores the original translation, or the original copied or untranslated state, without calling the AI again. Copied blocks such as code and math, and blocks that were never translated, can be deleted the same way.
    • A standalone inserted translation can be deleted directly. It is removed from the cache permanently, with no undo.
    • All staged source edits, insertions, and deletions are written back in one diff confirmation; Reset staged changes clears everything.
  • Staged changes are tracked per block. If the source file is modified externally in the meantime, staging is cleared and you are asked to edit again.
  • When the source changes again, locked translations enter the Translation locked · source updated state and are not overwritten automatically.
  • To accept the current source, use Mark synchronized.
  • To translate one block again, use Retranslate on that block.
  • Every translated block has a Back-translate button: it translates the translation back into the source language and puts the result directly into source staging, with no extra dialog. Apply source changes writes it to the source file and locks that translation to the new source. If the result matches the current source, nothing is staged.
  • Stable translation is on by default: retranslation (single block, stale blocks, or all) references the previous translation, back-translation references the current source, and explicitly retranslating a human block also references its previous translation. The Reference previous translation switch in the preview affects only the current session; the stableTranslation setting controls the default.
  • The document brief can only be generated manually (OpenAI-compatible and Mock providers); with a custom HTTP provider you write it by hand. Generation produces a summary, translation guidance (brief), and a document glossary. The Document brief panel shows status, total token estimate, and staleness; the summary stays visible, while translation guidance and the glossary are mutually exclusive collapsed sections (both collapsed initially) and the glossary uses single-line flow cards (source | target; short cards fit their content, long text is ellipsized and scrolls on the hovered side), and clicking either side edits just that side inline. One Save brief action writes all three to the cache. The summary and brief output language is controlled by assistantLanguage (target by default; it can follow the source or use a specific BCP-47 tag). Generation also reads whitelisted frontmatter (title, name, description, tags, keywords, categories, audience, product, project, version, locale, lang, type, docType) and the workspace-relative path as read-only metadata in the user message; the raw frontmatter is no longer repeated to the summary model. The Use document brief context switch in the preview affects only the current session; the summaryContext setting controls the default. The summary, each guidance field, and the glossary can be locked independently. Locks are stored in the cache marker; generation trims the prompt and output contract to unlocked items, ignores returned locked values, and sends no request when everything is locked. Locked content still participates in translation/review and remains editable. Clearing the brief removes its locks. The summary now covers only purpose, scope, structure, and key concepts; audience, tone, terminology decisions, and do-not-translate rules are handled only by the brief. This boundary was evaluated over multiple runs on 19 cases with DeepSeek-V3.2.
  • The brief is stored as a dedicated marker in the cache and takes no part in block alignment or export. It is shown as Possibly stale after the source changes but is still used as context, and clearing the cache removes it. Brief generation accepts about 12k input tokens; beyond that, write it manually. Single-block retranslation and back-translation also send read-only neighboring blocks from the same section, which helps short headings and paragraphs keep their local meaning.

Block Status and Cache Markers

Block state model: untranslated, translated, stale, translation locked, locked with an updated source, and deleted; side notes cover copied blocks, target-only blocks, and staged source edits

Block state model: automatic writes never overwrite locked translations; saving the source only marks stale.

Automatic writes never overwrite a locked translation. Saving the source only marks blocks stale; it never calls the translation API.

Cache anchors (<!-- mbs:... -->) have five modes:

Mode Used by Meaning
auto Normal blocks Machine translation. src records the source hash from the last translation, so the block becomes stale after the source changes.
human Normal blocks Locked translation, set by import, manual editing, marking synchronized, or back-translation write-back.
copy Normal blocks Not translated and copied verbatim from the source, such as code or math.
target Standalone translation blocks A translation with no matching source, always shown as a locked translation. Produced when a normal translation's source is deleted.
deleted Normal blocks Translation deletion marker; the content is an mbs-deleted marker with a backup. Excluded from sync and export.

Block statuses after alignment: untranslated, copy-pending, translated, stale, human, human-stale, copy, copy-stale, deleted. There are also three staged states: source pending insert, source pending delete, and translation pending generation.

Operation Cache Source Description
Sync / retranslate stale / retranslate all Writes auto or copy Unchanged Skips human, deleted, and normal copy blocks; keeps successful batches on failure
Retranslate this block Writes auto Unchanged Falls back to a full-file sync when there is no cache; on a deleted block it restores the translation
Edit/save translation Writes human Unchanged Validates the source hash, cache ID, and baseline text before saving
Mark synchronized Writes human Unchanged Accepts the current source and locks the block
Delete translation / undo delete Writes or removes deleted Unchanged Keeps a backup when a translation exists; writes an empty marker otherwise
Insert translation Writes target Unchanged Goes straight into export; can be turned into human after back-translating a source
Delete standalone translation Removes the anchor Unchanged Cannot be undone
Stage source edit Unchanged Applied, then written After write-back, normal translations become stale according to src
Stage source deletion Demoted after applying Applied, then written Normal translations become target; copy and deleted entries are removed
Back-translate (existing translation) Writes human after applying Applied, then written The result goes to source staging; no dialog is shown automatically
Stage source insertion Unchanged Applied, then written New source blocks are translated on the next sync

Split Layout and Scroll Sync

  • The preview header switches between Side by side, Stacked, and Split layouts; the choice is remembered across sessions.
  • Split creates two independent scrolling panes for source and translation instead of placing both languages side by side within each block.
  • Scrolling either pane follows the matching block and interpolates by scroll progress within that block, so long blocks keep the other pane moving instead of pinning it to the block top. Blocks that exist on one side only, because of an insertion or deletion, show the same block header and placeholder note as the side-by-side and stacked layouts in the empty pane, so both sides keep a one-to-one row correspondence.
  • Editing source or translation, inserting, deleting, retranslating, back-translating, and undoing deletions all still work in the split layout. Retranslate is on the source block and Go to source is on the translation block, while insert and delete buttons appear in both panes.
  • Each block header has a ⋯ (more) button in its top-right corner that hides the block's action buttons by default. Clicking it expands them below the header, and they collapse when the pointer leaves the block. In Source only or Target only mode the ⋯ button is hidden and the actions sit inline on the right of the header.
  • Source only and Target only modes work with the split layout: they keep the corresponding pane and let it fill the width.
  • In the split layout, each pane header has a Read-only preview button. When enabled, that pane hides block headers, status, and actions and renders its Markdown continuously, while the other pane stays editable and can enter read-only mode independently. Switching read-only mode or layout preserves both scroll positions instead of jumping to the top.
  • Read-only state is per pane and applies only to the current preview session; closing the preview restores editing.
  • Read-only mode affects display and editing only. It does not change sync, export, or cache semantics, and blocks that exist on one side do not produce placeholders in the other pane; only content that actually exists is rendered.

Importing Existing Translations

  • Click Import translation in the preview toolbar, or run Import Existing Translation… from the Command Palette.
  • Select an existing translation .md file, for example guide.zh.md.
  • Each top-level block is validated: source and translation must have the same block count and block types, so paragraphs cannot drift out of alignment.
  • All translatable blocks are written to the cache as Translation locked; structural blocks such as code and math are copied from the source.
  • Existing cache entries are overwritten after a confirmation. No cache backup is provided.
  • The imported file must not contain extension anchors. If you pick a cache file, the extension prompts you to use the anchor-free translation Markdown instead.
  • Importing neither calls the AI nor modifies the source file.

Custom HTTP Provider

  • Enabled when markdownBilingualSync.provider is set to http.
  • Supported request methods are POST, PUT, and PATCH; httpHeaders and httpBody are JSON templates.
  • Template variables: {{text}}, {{id}}, {{kind}}, {{headingPath}}, {{sourceLanguage}}, {{targetLanguage}}, {{apiKey}}, {{referenceText}}, {{referenceRole}}, {{summary}}.
  • The custom HTTP provider sends one request per block. With httpResponseType set to json, the text is extracted through httpResponsePath; with text, the response body is used as the translation directly.
  • Reference translations and document summaries are sent only when the template explicitly references {{referenceText}} or {{summary}}. {{referenceRole}} is either previous-target or previous-source.
  • Example httpBody:
    {"text":"{{text}}","source_language":"{{sourceLanguage}}","target_language":"{{targetLanguage}}"}
    
  • Example httpHeaders:
    {"Content-Type":"application/json","Authorization":"Bearer {{apiKey}}"}
    
  • httpResponsePath accepts values such as translation, data.translations.0.text, or result[0].text.
  • Endpoint addresses must use HTTPS except for localhost/127.0.0.1/[::1]. {{apiKey}} is substituted only while a request is made and is never written to settings or logs.

Clearing Caches

  • Clear Current Translation Cache deletes the cache for the current file, so you can translate or import again. This cannot be undone.
  • Clear All Translation Caches recursively deletes every cache file under the extension's globalStorageUri/cache and is meant for a full reset. This cannot be undone.
  • If a cache file is open in an editor, the clear command asks you to close that tab first, so the editor cannot keep holding deleted content.
  • While a sync or import is running, clearing all caches is rejected to avoid interleaving writes and deletions.
  • Open Translation Cache Folder still lets you browse every cache file.

Batch Translation and Export

  • Batch Translate Folder… recursively finds .md files under the selected folder, skips exports for the current target language (for example *.zh.md), and translates each file incrementally.
  • Batches are packed dynamically from the estimated token budget; apiBatchSize is only a hard limit on block count. Concurrent calls are still coalesced across files, but each batch stays within one document and keeps a section whole unless that section alone exceeds the limits.
  • File-level concurrency, batches within one file, and manual sync requests all share the translationConcurrency limit (default 8, maximum 100).
  • Each successful batch is written to the cache immediately. If later batches for a file fail, the successful blocks are kept and the failed ones stay untranslated; the next sync fills only the gaps.
  • Before batch translation starts, open Markdown files in the folder are saved. The progress notification can be cancelled. One file failing does not stop the others, and details go to the Output panel.
  • Batch Export Folder… first scans the folder for Markdown files with a cache and builds an export queue; files whose content is unchanged and files without a cache are skipped.
  • Batch export shows a single summary confirmation and no per-file diff dialog. After you confirm, language-suffixed files are written in queue order and each target path is logged.

Task Panel

  • The Translation Tasks button in the status bar shows a running indicator and the active/limit concurrency while tasks are running; click it to show or hide the task view.
  • The task panel is a native VS Code TreeView in the Translation Tasks activity-bar container. On first use, drag it to the right secondary sidebar if you prefer; VS Code remembers the location. The status bar button still toggles it directly.
  • Upgrade note: the view container ID changed from the old dotted value to markdownBilingualSyncTasks. If the view disappears after upgrading, drag it from the activity bar once.
  • The view contains:
    • Batch overview: active files, active block progress, failed blocks, concurrency usage, and waiting requests.
    • Active tasks: file, phase, block progress, failure count, elapsed time, and errors; inline actions open the source file, open the preview, or cancel.
    • Recently completed: recently finished tasks with elapsed/failure details, plus a command to clear history.
    • Runtime status: translation service, model or template, batch budget, and block limit.
  • The view title provides cancel all, clear history, open output, and Change Languages. Language switching uses a native QuickPick for source, target, or swap; options come from markdownBilingualSync.supportedLanguages and writes keep the existing setting scope. Changes affect only later translations and exports.
  • Batch translation and command- or preview-triggered full-file syncs no longer show VS Code progress or completion notifications; progress and results go to the view. Cancel confirmations, import/export confirmations, and API prompts are still shown.
  • Task rows aggregate file-level batch and sync operations. Single-block retranslation or back-translation in the preview keeps its brief inline feedback and does not create its own row.
  • The status bar button does not open the task view automatically; it toggles the view when clicked.

Provider Presets

  • Run Apply Translation Provider Preset… to switch in one step between OpenAI, DeepSeek, SiliconFlow, Ollama, LM Studio, custom HTTP, and Mock.
  • Presets write only endpoint settings such as provider, apiBaseUrl, and apiModel, never the API key.
  • Presets for local services use HTTP addresses on 127.0.0.1; all other addresses must use HTTPS.
  • Presets overwrite the current endpoint and model settings. The API key still has to be saved separately with Set AI Translation API Key.

Export

  • Export Translations… writes a language-suffixed file in the same folder, for example docs/guide.zh.md.
  • A side-by-side diff is shown before writing; the dialog closes after you cancel or write, leaving no extra diff tab.
  • The target file is checked again before writing and is not overwritten if it was modified externally during confirmation.
  • Exported files have internal anchors stripped and are durable assets for use across devices and projects.

Commands

Command titles follow VS Code's display language. The table lists the English titles, which are shown when VS Code itself is in English; other display languages show localized titles.

Command Description
Translate Current File Translates missing blocks for the first time and opens the preview
Open Bilingual Preview Opens or shows the preview in a new tab in the current editor group
Sync Translation Translates only missing and stale blocks
Retranslate Stale Translations Retranslates all stale machine translations
Retranslate All Machine Translations Forces retranslation of all auto blocks; locked translations are kept
Export Translations… Writes a language-suffixed file after a side-by-side diff confirmation
Edit Translation Cache Opens the global translation cache for the current file
Refresh Bilingual Preview Refreshes the preview manually
Open Translation Tasks Panel Shows or hides the Translation Tasks TreeView to check progress or cancel tasks
Open Translation Cache Folder Opens the global cache folder
Clear Current Translation Cache Deletes the cache for the current file (cannot be undone)
Clear All Translation Caches Recursively deletes every cache in extension storage (cannot be undone)
Import Existing Translation… Imports an existing translation Markdown file block by block and locks it
Batch Translate Folder… Recursively translates Markdown files in a folder, skipping exports for the target language
Batch Export Folder… Queues exports for Markdown files in a folder that already have a cache
Edit Global Glossary Opens the user-level glossary.json
Edit Glossary (Global or Workspace) Choose the global list or the workspace-root .mbs-glossary.json
Set AI Translation API Key Writes the key to SecretStorage
Apply Translation Provider Preset… Switches to OpenAI/DeepSeek/SiliconFlow/Ollama/LM Studio/HTTP/Mock
Test AI Translation Connection Sends a short test request and reports the model or template, latency, and a sample translation
Clear AI Translation API Key Deletes the key from SecretStorage

Glossaries and consistency check

  • Global: globalStorage/glossary.json, shared across all workspaces.
  • Workspace: .mbs-glossary.json in the workspace root; commit it with the project if the team should share terms. “Workspace” means the VS Code workspace folder; in a multi-root workspace the folder containing the source file is used. With no workspace open, only the global glossary applies.
  • Document: generated by the AI together with the document brief and stored in the cache's mbs-summary metadata. The preview's Document brief panel shows the terms as flow cards; click a card to edit, add or delete terms, or switch to bulk source => target editing. With a custom HTTP provider the glossary cannot be generated automatically, but you can edit it after writing a brief manually. Clearing the brief also clears the document glossary.
  • Merge order is global → workspace → document; a document entry overrides an earlier entry with the same source. The user glossaries are sent as constraints when the AI generates the document glossary, but only terms that appear at least twice in the source and are not user-glossary duplicates are kept. Each source gets exactly one target; entries with /, 、, or, or 或 alternatives, code, URLs, HTML, or an identical target are discarded. The filter applies only to newly generated entries; existing document terms (including user edits) are preserved. Bad entries already in an old cache are not removed automatically; clear the summary before regenerating for a full rebuild.
  • The preview's Check action scans machine translations for missing glossary targets and protected Markdown. Results are grouped by block; selecting one retranslates that block. Locked translations are skipped, so manual work is never overwritten.

Agent Integration

The extension exposes document-brief and glossary operations through native VS Code Language Model Tools for GitHub Copilot / VS Code agents (VS Code 1.95+). The tools appear in the agent's tool list automatically; no separate MCP configuration is required.

Tool Purpose
mbs_get_document_brief Read the summary, translation requirements, generation locks, and document glossary
mbs_update_document_brief Create or update a document brief; brief fields merge, and an empty string clears a field
mbs_update_document_glossary Add, update, remove, or replace the document glossary
mbs_get_glossary Read the global, workspace, or effective user glossary with filtering and paging
mbs_update_glossary Update the global or workspace glossary

Example prompts in Copilot agent mode:

  • "Read the document brief for docs/guide.md."
  • "Change the audience to backend developers, make the tone more concise, and add the term cache => 缓存."
  • "Add API => 接口 to the global glossary."

Behavior:

  • Write tools show a confirmation first. Confirmed writes still use the existing cache file lock, dirty-file protection, and preview refresh.
  • Generation locks are overridden by default but are not cleared; the result reports which locks were overridden.
  • A document glossary requires a non-empty summary. When creating a document brief, provide summary in the same call.
  • File arguments prefer absolute paths and also accept workspace-relative paths. When omitted, the active editor is used; in a multi-root workspace with no active editor, pass file explicitly.
  • Only local Markdown/Skill source files are accepted. Cache files and glossary files are rejected as file.
  • No new setting is added; the tools can be enabled or disabled in the Chat tool picker.

Settings

Setting Default Description
markdownBilingualSync.provider mock mock, openai, or http
markdownBilingualSync.apiBaseUrl https://api.openai.com/v1 OpenAI-compatible endpoint; /chat/completions is appended automatically; plain HTTP is allowed only for localhost/127.0.0.1/[::1]
markdownBilingualSync.apiModel gpt-4o-mini Model name supported by the server
markdownBilingualSync.apiThinkingMode default default omits enable_thinking and uses the provider default; enabled sends true; disabled sends false. Only some services support explicit modes
markdownBilingualSync.apiDisableThinking false Legacy switch used only when apiThinkingMode is default; prefer apiThinkingMode
markdownBilingualSync.apiBatchSize 50 Hard limit on blocks per batch; the actual batch size is determined by the token budget
markdownBilingualSync.apiBatchTokenBudget 2000 Estimated token budget for the input of each batch; overly small batches are avoided; summary/brief, neighbor context, user annotations, reference translations, and glossary count toward it, output is counted separately
markdownBilingualSync.translationConcurrency 8 Concurrency limit shared by file-level translation, in-file batches, and manual requests (1–100)
markdownBilingualSync.stableTranslation true Retranslation references the previous translation and back-translation references the current source, reducing wording drift; can be toggled temporarily in the preview
markdownBilingualSync.summaryContext true Uses the manually generated document brief (summary + brief) as context for sync, retranslation, and back-translation; can be toggled temporarily in the preview
markdownBilingualSync.apiTimeoutMs 120000 Timeout for a single request in milliseconds, shared by the OpenAI-compatible and custom HTTP providers
markdownBilingualSync.httpEndpoint empty Full URL of the custom HTTP endpoint; may contain template variables
markdownBilingualSync.httpMethod POST Request method for the custom HTTP endpoint: POST, PUT, PATCH
markdownBilingualSync.httpHeaders Default Bearer template Request header JSON template
markdownBilingualSync.httpBody Default text template Request body JSON template; one request per block
markdownBilingualSync.httpResponseType json json or text
markdownBilingualSync.httpResponsePath translation JSON path to the translation text
markdownBilingualSync.sourceLanguage en Source language
markdownBilingualSync.targetLanguage zh-CN Target language; one target language per file
markdownBilingualSync.supportedLanguages ["zh-CN"] Languages offered by the source/target quick switches in the task panel, shown in array order. Invalid or blank entries and case-insensitive duplicates are ignored, and the current sourceLanguage and targetLanguage are always included
markdownBilingualSync.assistantLanguage target Output language for the document brief (summary, translation guidance) and review annotations. target follows the target language (default), source follows the source language, or use a BCP-47 tag such as zh-CN. Document glossary pairs keep the translation language pair

provider, the endpoint, model, HTTP template, batch settings, and assistantLanguage are application-level settings and cannot be overridden by a workspace.

Security & Privacy

  • API keys are stored only in VS Code SecretStorage and never written to settings, workspaces, logs, prompts, or caches. The {{apiKey}} variable in custom HTTP templates is substituted only when a request is made.
  • The OpenAI-compatible and custom HTTP providers use separate SecretStorage keys; the legacy shared key is only a fallback for upgrade migration. After switching provider or endpoint, run Test AI Translation Connection again to confirm the key matches the target service.
  • Source write-backs (document replacement, saving, cache reconciliation) and sync tasks share one file lock. A failed write-back restores the in-memory document, so no unsaved intermediate state is left behind.
  • Unknown variables in HTTP templates, invalid request headers, newline injection, and remote plain HTTP connections are rejected, and error messages mask keys.
  • Document text is sent to the configured translation service; check the data handling policy of that service.
  • Raw HTML is not rendered. The Webview restricts scripts and resources with CSP and a nonce.
  • Translation caches live in the extension's globalStorageUri, not in the project folder.
  • Moving a project, clearing extension storage, or uninstalling the extension loses caches and lock state. Export anything you need to keep.
  • The global glossary is a user-level resource and is not shared through the repository. The workspace glossary lives in the project directory and is shared with the repository; the document glossary exists only in the local translation cache.

Localization

  • English is the default and source language. Chinese is loaded when the VS Code display language is zh-cn; other languages fall back to English.
  • The manifest (extension display name and description, command titles and category, view names, setting descriptions, and enum descriptions) uses package.nls.json / package.nls.zh-cn.json; runtime strings use l10n/bundle.l10n.json / l10n/bundle.l10n.zh-cn.json.
  • Runtime strings live in src/i18n/en.ts (English source) and src/i18n/zh.ts; errors and warnings are grouped by domain in src/i18n/errors/*.ts and resolved for the current locale through tError().
  • Webview strings are injected into the page by the host as localized UI_TEXT; <html lang>, language names, and date and duration formats use vscode.env.language and Intl.
  • After adding or changing strings, run npm run l10n:build (it also runs as part of npm run compile, vscode:prepublish, typecheck, test, and test:watch), then npm run typecheck and npm test.
  • npm run watch builds the bundle once before it starts but does not watch en.ts, zh.ts, or errors/*; after changing strings, run npm run l10n:build again and reload the extension host.

Known Limitations

  • Only local file workflows are supported; there are no cloud task queues or multi-user collaboration features.
  • Code blocks, math, HTML, and frontmatter are copied as-is by design and never sent for AI translation.
  • In-preview editing is per block; cross-block selection and large structural rearrangements are not supported. For complex restructuring, edit the source file directly.
  • Scroll sync uses block anchors and proportional in-block interpolation; when block heights differ greatly, the panes may not align pixel-for-pixel, but the other pane keeps moving through long blocks.
  • Importing a translation requires the source and translation to match one-to-one in top-level block count and type; structural mismatches reject the import.
  • Provider requests share the translationConcurrency limit (default 8). Lower it when you hit rate limits; for files with many blocks, consider raising apiBatchTokenBudget.
  • Batch export provides a single summary confirmation rather than a per-file diff; use the regular export when you need per-file confirmation.
  • Provider presets overwrite the current endpoint and model settings but never write or clear the API key.
  • The custom HTTP provider sends one request per block and does not support a batch items protocol; services that require batching need an OpenAI-compatible adapter in front.
  • The Source insert and delete actions modify the source file, while Delete → Translation only writes a deletion marker and keeps the anchor; it does not delete the source block. Standalone translation blocks have no source and are removed from the cache immediately when deleted, with no undo.
  • Standalone translation blocks are written straight to the cache and do not modify the source. If their anchor source block is deleted, they are placed after the preceding remaining source block or at the end of the translation.
  • After a source block is deleted and written back, its translation is demoted to a standalone translation block (a target anchor), which avoids orphaned anchors and does not block later syncs.
  • Caches cannot be recovered inside the extension after clearing the current cache or all caches; export translations you need to keep first.
  • Back-translation runs per block and does not back-translate a whole document automatically.
  • Document briefs and document glossaries are generated only on explicit request; the custom HTTP provider cannot generate them and requires manual input, and very large documents (over about 12k tokens) are not generated in segments.
  • Summaries, briefs, read-only neighbor context, user annotations, and stable references increase input tokens for every translation; these fixed contexts count against each batch budget.
  • Mermaid diagrams, raw HTML, custom prompts, and streaming output are not supported.
  • Glossaries merge global → workspace → document. The document glossary is AI-generated with the brief and keeps only recurring terms that are not user-glossary duplicates; review it before relying on it, and add important one-off terms manually. Clearing the brief also clears it.
  • AI review is triggered manually (per block, or Review entire document next to Sync) and only returns annotations, never automatic rewrites. User annotations default to one-shot and expire after one translation; turn off Apply once to keep them active for future translations. Pending annotations pull non-locked translated blocks into the sync queue; locked blocks need a manual single-block retranslation, and deleted/copy/untranslatable blocks are never force-overwritten and do not accept applicable annotations. After a successful translation, the block is marked Applied or Not applied based on whether its target text changed; multiple annotations on one block share that heuristic result. Only AI instructions are adoptable; adoption uses the proposed mode, which can still be changed in the composer, while advice stays read-only. Annotations are grouped into collapsible My annotations and AI review sections; the panel can be dragged and stays open while the page scrolls. They are stored in a local sidecar and are not shared through the workspace. Mock and custom HTTP providers do not read annotations; only OpenAI-compatible providers apply them, and the preview shows a warning otherwise.
  • The UI ships in English (the source language) and zh-cn, with other VS Code languages falling back to English. Interface, preview, and notification strings come from src/i18n/en.ts / src/i18n/zh.ts, errors and warnings from src/i18n/errors/*, and manifest strings from package.nls*.json.
  • The GitHub README is in Chinese, while this English README is used for the Marketplace listing; both are maintained. The UI itself supports English and zh-cn.
  • Sync is not real-time: saving only changes the state, and translation is triggered by explicit commands.

License

This project is released under the MIT License (see the LICENSE file in the repository root). You may use, modify, and distribute it freely, provided you retain the copyright and license notice.

Development

npm ci
npm run typecheck
npm test
npm run compile
npm run preview:sample
npm run ui:matrix
npm run ui:perf
npm run package

typecheck, test, compile, test:watch, and package generate the l10n bundle automatically; to change text only, run npm run l10n:build on its own. watch builds the bundle once at startup but does not watch the locale folders.

ui:matrix captures three themes × three layouts × three modes plus summary, dialogs, editing, read-only, busy, narrow, and empty states with headless Edge. ui:perf records a 320-block baseline for mount, input, and scrolling. Outputs go to artifacts/ui-matrix/ and artifacts/ui-perf/. Both require a local Edge (set EDGE_PATH if needed) and do not run in CI.

The package output is artifacts/vsix/markdown-bilingual-sync.vsix, and the sample document is samples/demo.md.

See docs/ for architecture, cache format, the preview protocol, the development workflow, and testing guidance. Translation-quality evaluation is documented in docs/evaluation.md, and AI annotation evaluation in docs/annotation-evaluation.md; run npm run eval:translation -- --provider mock and npm run eval:annotations -- --provider mock for offline pipeline smoke tests.

CI is configured in .github/workflows/ci.yml: every push and pull request runs npm ci, type checking, and the full test suite, then packages a VSIX as a build artifact.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft