# intellism/vscode-comment-translate architecture

> Architecture diagram of the GitHub repository intellism/vscode-comment-translate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/intellism/vscode-comment-translate
- Repository: https://github.com/intellism/vscode-comment-translate

## Overview

Comment Translate is a VS Code extension for translating code comments, strings, selections, Markdown, and Copilot chat. The main workflow starts when a developer invokes a command or a registered editor feature; language-aware parsing and translation produce hover, inline, preview, or replacement results. The graph includes README-documented service and interaction branches, while omitting unverified implementation links where excerpts do not establish the call.

Main entry points: [`src/extension.ts`](https://github.com/intellism/vscode-comment-translate/blob/master/src/extension.ts) (Extension activation), [`src/translate/manager.ts`](https://github.com/intellism/vscode-comment-translate/blob/master/src/translate/manager.ts) (Translation manager), [`src/syntax/Comment.ts`](https://github.com/intellism/vscode-comment-translate/blob/master/src/syntax/Comment.ts) (Comment parsing), [`src/languageFeature/markdownPreview.ts`](https://github.com/intellism/vscode-comment-translate/blob/master/src/languageFeature/markdownPreview.ts) (Markdown preview)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Extension entry"]
  node_activation["Extension activation<br/>[extension.ts]"]
  node_commands["Commands<br/>[command.ts]"]
  node_selection["Selection replacement"]
  node_configuration["Language settings<br/>[configuration.ts]"]
end

subgraph group_editor["Code understanding"]
  node_comment["Comment parsing<br/>[Comment.ts]"]
  node_grammar["TextMate grammars<br/>[TextMateService.ts]"]
  node_compile["Translation preparation<br/>[compile.ts]"]
  node_language["Language detection<br/>[lang.ts]"]
  node_markdownparse["Markdown document processing"]
end

subgraph group_translation["Translation services"]
  node_manager["Translation manager<br/>[manager.ts]"]
  node_google["Google Translate<br/>[GoogleTranslate.ts]"]
  node_bing["Bing Translate<br/>[BingTranslate.ts]"]
  node_transmart["TranSmart Translate"]
  node_copilotprovider["Copilot translation provider"]
end

subgraph group_results["Editor experiences"]
  node_hover["Hover translation<br/>[hover.ts]"]
  node_immersive["Immersive comments<br/>[decoration.ts]"]
  node_markdown["Markdown preview<br/>[markdownPreview.ts]"]
  node_markdownfs["Translated Markdown provider"]
  node_completion["Naming suggestions<br/>[completion.ts]"]
end

subgraph group_integrations["Chat and extensions"]
  node_ali["AliCloud provider<br/>[translateAli.ts]"]
  node_copilotchat["Copilot chat participant<br/>[translate.ts]"]
  node_prompt["Chat prompt<br/>[prompt.ts]"]
end

node_developer(("Developer"))
node_translationservice{{"Translation service"}}
node_copilot{{"GitHub Copilot Chat"}}

node_developer -->|"starts extension"| node_activation
node_activation -->|"registers commands"| node_commands
node_activation -->|"registers hover"| node_hover
node_activation -->|"registers browsing"| node_immersive
node_activation -->|"registers preview"| node_markdown
node_activation -->|"registers completion"| node_completion
node_activation -->|"registers participant"| node_copilotchat
node_activation -->|"initializes"| node_manager
node_activation -->|"initializes parser"| node_comment
node_activation -->|"shows language controls"| node_configuration
node_commands -->|"dispatches replacement"| node_selection
node_selection -->|"extracts comment text"| node_comment
node_selection -->|"requests translation"| node_manager
node_comment -->|"creates grammar"| node_grammar
node_hover -->|"parses hovered text"| node_comment
node_hover -->|"prepares translation"| node_compile
node_immersive -->|"extracts comment blocks"| node_comment
node_immersive -.->|"translates comments"| node_compile
node_compile -->|"requests translation"| node_manager
node_compile -.->|"detects language"| node_language
node_markdown -->|"translates document"| node_markdownparse
node_markdown -->|"requests translation"| node_manager
node_markdown -->|"updates provider"| node_markdownfs
node_completion -->|"uses naming results"| node_selection
node_manager -->|"dispatches provider"| node_google
node_manager -->|"dispatches provider"| node_bing
node_manager -->|"dispatches provider"| node_transmart
node_manager -->|"dispatches provider"| node_copilotprovider
node_google -.->|"sends translation request"| node_translationservice
node_bing -.->|"sends translation request"| node_translationservice
node_transmart -.->|"sends translation request"| node_translationservice
node_manager -->|"supports extension provider"| node_ali
node_copilotchat -->|"builds prompt"| node_prompt
node_copilotchat -->|"requests translation"| node_manager
node_copilotchat -.->|"registers chat participant"| node_copilot

click node_activation "https://github.com/intellism/vscode-comment-translate/blob/master/src/extension.ts"
click node_commands "https://github.com/intellism/vscode-comment-translate/blob/master/src/command/command.ts"
click node_selection "https://github.com/intellism/vscode-comment-translate/blob/master/src/command/replaceSelections.ts"
click node_configuration "https://github.com/intellism/vscode-comment-translate/blob/master/src/configuration.ts"
click node_comment "https://github.com/intellism/vscode-comment-translate/blob/master/src/syntax/Comment.ts"
click node_grammar "https://github.com/intellism/vscode-comment-translate/blob/master/src/syntax/TextMateService.ts"
click node_compile "https://github.com/intellism/vscode-comment-translate/blob/master/src/syntax/compile.ts"
click node_language "https://github.com/intellism/vscode-comment-translate/blob/master/src/lang.ts"
click node_hover "https://github.com/intellism/vscode-comment-translate/blob/master/src/languageFeature/hover.ts"
click node_immersive "https://github.com/intellism/vscode-comment-translate/blob/master/src/languageFeature/decoration.ts"
click node_markdown "https://github.com/intellism/vscode-comment-translate/blob/master/src/languageFeature/markdownPreview.ts"
click node_markdownparse "https://github.com/intellism/vscode-comment-translate/blob/master/src/syntax/markdownDocument.ts"
click node_markdownfs "https://github.com/intellism/vscode-comment-translate/blob/master/src/languageFeature/translatedMarkdownFs.ts"
click node_completion "https://github.com/intellism/vscode-comment-translate/blob/master/src/languageFeature/completion.ts"
click node_manager "https://github.com/intellism/vscode-comment-translate/blob/master/src/translate/manager.ts"
click node_google "https://github.com/intellism/vscode-comment-translate/blob/master/src/translate/GoogleTranslate.ts"
click node_bing "https://github.com/intellism/vscode-comment-translate/blob/master/src/translate/BingTranslate.ts"
click node_transmart "https://github.com/intellism/vscode-comment-translate/blob/master/src/translate/TranSmartTranslate.ts"
click node_copilotprovider "https://github.com/intellism/vscode-comment-translate/blob/master/src/translate/CopilotTranslate.ts"
click node_ali "https://github.com/intellism/vscode-comment-translate/blob/master/src/plugin/translateAli.ts"
click node_copilotchat "https://github.com/intellism/vscode-comment-translate/blob/master/src/copilot/translate.ts"
click node_prompt "https://github.com/intellism/vscode-comment-translate/blob/master/src/copilot/prompt.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_activation,node_commands,node_selection,node_configuration toneBlue
class node_comment,node_grammar,node_compile,node_language,node_markdownparse toneAmber
class node_manager,node_google,node_bing,node_transmart,node_copilotprovider toneMint
class node_hover,node_immersive,node_markdown,node_markdownfs,node_completion toneRose
class node_ali,node_copilotchat,node_prompt,node_developer,node_translationservice,node_copilot toneIndigo
```

## Components

### Extension entry

- [Extension activation](https://github.com/intellism/vscode-comment-translate/blob/master/src/extension.ts): `src/extension.ts`
- [Commands](https://github.com/intellism/vscode-comment-translate/blob/master/src/command/command.ts): `src/command/command.ts`
- [Selection replacement](https://github.com/intellism/vscode-comment-translate/blob/master/src/command/replaceSelections.ts): `src/command/replaceSelections.ts`
- [Language settings](https://github.com/intellism/vscode-comment-translate/blob/master/src/configuration.ts): `src/configuration.ts`

### Code understanding

- [Comment parsing](https://github.com/intellism/vscode-comment-translate/blob/master/src/syntax/Comment.ts): `src/syntax/Comment.ts`
- [TextMate grammars](https://github.com/intellism/vscode-comment-translate/blob/master/src/syntax/TextMateService.ts): `src/syntax/TextMateService.ts`
- [Translation preparation](https://github.com/intellism/vscode-comment-translate/blob/master/src/syntax/compile.ts): `src/syntax/compile.ts`
- [Language detection](https://github.com/intellism/vscode-comment-translate/blob/master/src/lang.ts): `src/lang.ts`
- [Markdown document processing](https://github.com/intellism/vscode-comment-translate/blob/master/src/syntax/markdownDocument.ts): `src/syntax/markdownDocument.ts`

### Translation services

- [Translation manager](https://github.com/intellism/vscode-comment-translate/blob/master/src/translate/manager.ts): `src/translate/manager.ts`
- [Google Translate](https://github.com/intellism/vscode-comment-translate/blob/master/src/translate/GoogleTranslate.ts): `src/translate/GoogleTranslate.ts`
- [Bing Translate](https://github.com/intellism/vscode-comment-translate/blob/master/src/translate/BingTranslate.ts): `src/translate/BingTranslate.ts`
- [TranSmart Translate](https://github.com/intellism/vscode-comment-translate/blob/master/src/translate/TranSmartTranslate.ts): `src/translate/TranSmartTranslate.ts`
- [Copilot translation provider](https://github.com/intellism/vscode-comment-translate/blob/master/src/translate/CopilotTranslate.ts): `src/translate/CopilotTranslate.ts`

### Editor experiences

- [Hover translation](https://github.com/intellism/vscode-comment-translate/blob/master/src/languageFeature/hover.ts): `src/languageFeature/hover.ts`
- [Immersive comments](https://github.com/intellism/vscode-comment-translate/blob/master/src/languageFeature/decoration.ts): `src/languageFeature/decoration.ts`
- [Markdown preview](https://github.com/intellism/vscode-comment-translate/blob/master/src/languageFeature/markdownPreview.ts): `src/languageFeature/markdownPreview.ts`
- [Translated Markdown provider](https://github.com/intellism/vscode-comment-translate/blob/master/src/languageFeature/translatedMarkdownFs.ts): `src/languageFeature/translatedMarkdownFs.ts`
- [Naming suggestions](https://github.com/intellism/vscode-comment-translate/blob/master/src/languageFeature/completion.ts): `src/languageFeature/completion.ts`

### Chat and extensions

- [AliCloud provider](https://github.com/intellism/vscode-comment-translate/blob/master/src/plugin/translateAli.ts): `src/plugin/translateAli.ts`
- [Copilot chat participant](https://github.com/intellism/vscode-comment-translate/blob/master/src/copilot/translate.ts): `src/copilot/translate.ts`
- [Chat prompt](https://github.com/intellism/vscode-comment-translate/blob/master/src/copilot/prompt.ts): `src/copilot/prompt.ts`

### Other components

- **Developer**
- **Translation service**
- **GitHub Copilot Chat**

## Connections

- Developer → Extension activation: starts extension (evidence: `src/extension.ts`)
- Extension activation → Commands: registers commands (evidence: `src/extension.ts`)
- Extension activation → Hover translation: registers hover (evidence: `src/extension.ts`)
- Extension activation → Immersive comments: registers browsing (evidence: `src/extension.ts`)
- Extension activation → Markdown preview: registers preview (evidence: `src/extension.ts`)
- Extension activation → Naming suggestions: registers completion (evidence: `src/extension.ts`)
- Extension activation → Copilot chat participant: registers participant (evidence: `src/extension.ts`)
- Extension activation → Translation manager: initializes (evidence: `src/extension.ts`)
- Extension activation → Comment parsing: initializes parser (evidence: `src/extension.ts`)
- Extension activation → Language settings: shows language controls (evidence: `src/extension.ts`)
- Commands → Selection replacement: dispatches replacement (evidence: `src/command/command.ts`)
- Selection replacement → Comment parsing: extracts comment text (evidence: `src/command/replaceSelections.ts`)
- Selection replacement → Translation manager: requests translation (evidence: `src/command/replaceSelections.ts`)
- Comment parsing → TextMate grammars: creates grammar (evidence: `src/syntax/Comment.ts`)
- Hover translation → Comment parsing: parses hovered text (evidence: `src/languageFeature/hover.ts`)
- Hover translation → Translation preparation: prepares translation (evidence: `src/languageFeature/hover.ts`)
- Immersive comments → Comment parsing: extracts comment blocks (evidence: `src/languageFeature/decoration.ts`)
- Immersive comments → Translation preparation: translates comments
- Translation preparation → Translation manager: requests translation (evidence: `src/syntax/compile.ts`)
- Translation preparation → Language detection: detects language
- Markdown preview → Markdown document processing: translates document (evidence: `src/languageFeature/markdownPreview.ts`)
- Markdown preview → Translation manager: requests translation (evidence: `src/languageFeature/markdownPreview.ts`)
- Markdown preview → Translated Markdown provider: updates provider (evidence: `src/languageFeature/markdownPreview.ts`)
- Naming suggestions → Selection replacement: uses naming results (evidence: `src/languageFeature/completion.ts`)
- Translation manager → Google Translate: dispatches provider (evidence: `src/translate/manager.ts`)
- Translation manager → Bing Translate: dispatches provider (evidence: `src/translate/manager.ts`)
- Translation manager → TranSmart Translate: dispatches provider (evidence: `src/translate/manager.ts`)
- Translation manager → Copilot translation provider: dispatches provider (evidence: `src/translate/manager.ts`)
- Google Translate → Translation service: sends translation request
- Bing Translate → Translation service: sends translation request
- TranSmart Translate → Translation service: sends translation request
- Translation manager → AliCloud provider: supports extension provider (evidence: `src/extension.ts`)
- Copilot chat participant → Chat prompt: builds prompt (evidence: `src/copilot/translate.ts`)
- Copilot chat participant → Translation manager: requests translation (evidence: `src/copilot/translate.ts`)
- Copilot chat participant → GitHub Copilot Chat: registers chat participant
