@techfetch-dev/project-translator 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +428 -0
- package/l10n/bundle.l10n.ar-ae.json +6 -0
- package/l10n/bundle.l10n.ar-eg.json +6 -0
- package/l10n/bundle.l10n.ar-sa.json +26 -0
- package/l10n/bundle.l10n.de-de.json +26 -0
- package/l10n/bundle.l10n.es-es.json +26 -0
- package/l10n/bundle.l10n.fr-fr.json +26 -0
- package/l10n/bundle.l10n.ja-jp.json +26 -0
- package/l10n/bundle.l10n.json +25 -0
- package/l10n/bundle.l10n.ko-kr.json +26 -0
- package/l10n/bundle.l10n.pt-br.json +26 -0
- package/l10n/bundle.l10n.ru-ru.json +26 -0
- package/l10n/bundle.l10n.zh-cn.json +28 -0
- package/l10n/bundle.l10n.zh-tw.json +26 -0
- package/out/cli.js +281 -0
- package/package.json +944 -0
- package/package.nls.ar-sa.json +41 -0
- package/package.nls.de-de.json +47 -0
- package/package.nls.es-es.json +47 -0
- package/package.nls.fr-fr.json +32 -0
- package/package.nls.ja-jp.json +47 -0
- package/package.nls.json +45 -0
- package/package.nls.ko-kr.json +47 -0
- package/package.nls.pt-br.json +47 -0
- package/package.nls.ru-ru.json +47 -0
- package/package.nls.zh-cn.json +47 -0
- package/package.nls.zh-tw.json +47 -0
- package/project.translation.schema.json +368 -0
- package/prompts/diff_system_prompt.en.md +198 -0
- package/prompts/diff_system_prompt.md +198 -0
- package/prompts/system_prompt_part1.en.md +78 -0
- package/prompts/system_prompt_part1.md +78 -0
- package/prompts/system_prompt_part2.en.md +140 -0
- package/prompts/system_prompt_part2.md +139 -0
- package/resources/project-translator.png +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Project-Translation
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
# Project Translator
|
|
2
|
+
|
|
3
|
+
An easy-to-use vscode extension for multi-language localization of projects.
|
|
4
|
+
|
|
5
|
+
Project repository: `https://github.com/Project-Translation/project_translator`
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
1. Marketplace:
|
|
11
|
+
- VS Code Extensions Marketplace: [https://marketplace.visualstudio.com/items?itemName=techfetch-dev.project-translator](https://marketplace.visualstudio.com/items?itemName=techfetch-dev.project-translator)
|
|
12
|
+
- Open VSX Registry: [https://open-vsx.org/extension/techfetch-dev/project-translator](https://open-vsx.org/extension/techfetch-dev/project-translator)
|
|
13
|
+
2. Search for `techfetch-dev.project-translator` in the VS Code Extensions view and click install
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
<!--  -->
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
## Available Translations
|
|
20
|
+
|
|
21
|
+
The extension supports translation to these languages:
|
|
22
|
+
|
|
23
|
+
- [简体中文 (zh-cn)](./readmes/README.zh-cn.md)
|
|
24
|
+
- [繁體中文 (zh-tw)](./readmes/README.zh-tw.md)
|
|
25
|
+
- [日本語 (ja-jp)](./readmes/README.ja-jp.md)
|
|
26
|
+
- [한국어 (ko-kr)](./readmes/README.ko-kr.md)
|
|
27
|
+
- [Français (fr-fr)](./readmes/README.fr-fr.md)
|
|
28
|
+
- [Deutsch (de-de)](./readmes/README.de-de.md)
|
|
29
|
+
- [Español (es-es)](./readmes/README.es-es.md)
|
|
30
|
+
- [Português (pt-br)](./readmes/README.pt-br.md)
|
|
31
|
+
- [Русский (ru-ru)](./readmes/README.ru-ru.md)
|
|
32
|
+
- [العربية (ar-sa)](./readmes/README.ar-sa.md)
|
|
33
|
+
- [العربية (ar-ae)](./readmes/README.ar-ae.md)
|
|
34
|
+
- [العربية (ar-eg)](./readmes/README.ar-eg.md)
|
|
35
|
+
|
|
36
|
+
## Samples
|
|
37
|
+
|
|
38
|
+
| Project | Original Repository | Description | Stars | Tags |
|
|
39
|
+
| ----------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
40
|
+
| [algorithm-visualizer](https://github.com/Project-Translation/algorithm-visualizer) | [algorithm-visualizer/algorithm-visualizer](https://github.com/algorithm-visualizer/algorithm-visualizer) | :fireworks:Interactive Online Platform that Visualizes Algorithms from Code | 47301 | [`algorithm`](https://github.com/topics/algorithm), [`animation`](https://github.com/topics/animation), [`data-structure`](https://github.com/topics/data-structure), [`visualization`](https://github.com/topics/visualization) |
|
|
41
|
+
| [algorithms](https://github.com/Project-Translation/algorithms) | [algorithm-visualizer/algorithms](https://github.com/algorithm-visualizer/algorithms) | :crystal_ball:Algorithm Visualizations | 401 | N/A |
|
|
42
|
+
| [cline-docs](https://github.com/Project-Translation/cline-docs) | [cline/cline](https://github.com/cline/cline) | Autonomous coding agent right in your IDE, capable of creating/editing files, executing commands, using the browser, and more with your permission every step of the way. | 39572 | N/A |
|
|
43
|
+
| [cursor-docs](https://github.com/Project-Translation/cursor-docs) | [getcursor/docs](https://github.com/getcursor/docs) | Cursor's Open Source Documentation | 309 | N/A |
|
|
44
|
+
| [gobyexample](https://github.com/Project-Translation/gobyexample) | [mmcgrana/gobyexample](https://github.com/mmcgrana/gobyexample) | Go by Example | 7523 | N/A |
|
|
45
|
+
| [golang-website](https://github.com/Project-Translation/golang-website) | [golang/website](https://github.com/golang/website) | [mirror] Home of the go.dev and golang.org websites | 402 | N/A |
|
|
46
|
+
| [reference-en-us](https://github.com/Project-Translation/reference-en-us) | [Fechin/reference](https://github.com/Fechin/reference) | ⭕ Share quick reference cheat sheet for developers. | 7808 | [`awk`](https://github.com/topics/awk), [`bash`](https://github.com/topics/bash), [`chatgpt`](https://github.com/topics/chatgpt), [`cheatsheet`](https://github.com/topics/cheatsheet), [`cheatsheets`](https://github.com/topics/cheatsheets), [`css`](https://github.com/topics/css), [`golang`](https://github.com/topics/golang), [`grep`](https://github.com/topics/grep), [`markdown`](https://github.com/topics/markdown), [`python`](https://github.com/topics/python), [`reference`](https://github.com/topics/reference), [`sed`](https://github.com/topics/sed), [`snippets`](https://github.com/topics/snippets), [`vim`](https://github.com/topics/vim) |
|
|
47
|
+
| [styleguide](https://github.com/Project-Translation/styleguide) | [google/styleguide](https://github.com/google/styleguide) | Style guides for Google-originated open-source projects | 38055 | [`cpplint`](https://github.com/topics/cpplint), [`style-guide`](https://github.com/topics/style-guide), [`styleguide`](https://github.com/topics/styleguide) |
|
|
48
|
+
| [vscode-docs](https://github.com/Project-Translation/vscode-docs) | [microsoft/vscode-docs](https://github.com/microsoft/vscode-docs) | Public documentation for Visual Studio Code | 5914 | [`vscode`](https://github.com/topics/vscode) |
|
|
49
|
+
|
|
50
|
+
## Requesting Project Translation
|
|
51
|
+
|
|
52
|
+
If you want to contribute a translation or need a project to be translated:
|
|
53
|
+
|
|
54
|
+
1. Create an issue using the following template:
|
|
55
|
+
|
|
56
|
+
```md
|
|
57
|
+
**Project**: [project_url]
|
|
58
|
+
**Target Language**: [target_lang]
|
|
59
|
+
**Description**: Brief description of why this translation would be valuable
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
2. Workflow:
|
|
63
|
+
|
|
64
|
+
```mermaid
|
|
65
|
+
sequenceDiagram
|
|
66
|
+
Contributor->>Project Translator: Create translation issue
|
|
67
|
+
Project Translator->>Community: Review issue
|
|
68
|
+
Community-->>Contributor: Approve/Comment
|
|
69
|
+
Contributor->>New Project: Start translation
|
|
70
|
+
Contributor->>New Project: Submit to New Project
|
|
71
|
+
Contributor->>Project Translator: Create Pull Request, modify README.Samples
|
|
72
|
+
Project Translator-->>Project Translator: Review & Merge
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
3. After the PR is merged, the translation will be added to the Samples section.
|
|
76
|
+
|
|
77
|
+
Current translations in progress: [View Issues](https://github.com/Project-Translation/project_translator/issues)
|
|
78
|
+
|
|
79
|
+
## Features
|
|
80
|
+
|
|
81
|
+
- 📁 Folder-level Translation Support
|
|
82
|
+
- Translate entire project folders to multiple languages
|
|
83
|
+
- Maintain original folder structure and hierarchy
|
|
84
|
+
- Support for recursive translation of subfolders
|
|
85
|
+
- Automatic detection of translatable content
|
|
86
|
+
- Batch processing for efficient large-scale translations
|
|
87
|
+
- 📄 File-level Translation Support
|
|
88
|
+
- Translate individual files to multiple languages
|
|
89
|
+
- Preserve original file structure and formatting
|
|
90
|
+
- Support for both folder and file translation modes
|
|
91
|
+
- 💡 Smart Translation with AI
|
|
92
|
+
- Automatically maintains code structure integrity
|
|
93
|
+
- Only translates code comments, preserves code logic
|
|
94
|
+
- Maintains JSON/XML and other data structure formats
|
|
95
|
+
- Professional technical documentation translation quality
|
|
96
|
+
- ⚙️ Flexible Configuration
|
|
97
|
+
- Configure source folder and multiple target folders
|
|
98
|
+
- Support for custom file translation intervals
|
|
99
|
+
- Set specific file types to ignore
|
|
100
|
+
- Support for multiple AI model options
|
|
101
|
+
- 🚀 User-Friendly Operations
|
|
102
|
+
- Real-time translation progress display
|
|
103
|
+
- Support for pause/resume/stop translation
|
|
104
|
+
- Automatic maintenance of target folder structure
|
|
105
|
+
- Incremental translation to avoid duplicate work
|
|
106
|
+
- 🔄 Differential Translation (Experimental)
|
|
107
|
+
- Diff-apply mode for efficient updates of existing translations
|
|
108
|
+
- Reduces API usage by only translating changed content
|
|
109
|
+
- Preserves version history with minimal edits
|
|
110
|
+
- ⚠️ Experimental feature - see [Advanced Features](#differential-translation-diff-apply-mode) for details
|
|
111
|
+
|
|
112
|
+
## Configuration
|
|
113
|
+
|
|
114
|
+
The extension supports the following configuration options:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"projectTranslator.specifiedFolders": [
|
|
119
|
+
{
|
|
120
|
+
"sourceFolder": {
|
|
121
|
+
"path": "Source folder path",
|
|
122
|
+
"lang": "Source language code"
|
|
123
|
+
},
|
|
124
|
+
"targetFolders": [
|
|
125
|
+
{
|
|
126
|
+
"path": "Target folder path",
|
|
127
|
+
"lang": "Target language code"
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
"projectTranslator.specifiedFiles": [
|
|
133
|
+
{
|
|
134
|
+
"sourceFile": {
|
|
135
|
+
"path": "Source file path",
|
|
136
|
+
"lang": "Source language code"
|
|
137
|
+
},
|
|
138
|
+
"targetFiles": [
|
|
139
|
+
{
|
|
140
|
+
"path": "Target file path",
|
|
141
|
+
"lang": "Target language code"
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"projectTranslator.currentVendor": "openai",
|
|
147
|
+
"projectTranslator.vendors": [
|
|
148
|
+
{
|
|
149
|
+
"name": "openai",
|
|
150
|
+
"apiEndpoint": "API endpoint URL",
|
|
151
|
+
"apiKeyEnvVarName": "MY_OPENAI_API_KEY",
|
|
152
|
+
"model": "gpt-4o",
|
|
153
|
+
"rpm": "10",
|
|
154
|
+
"maxTokensPerSegment": 4096,
|
|
155
|
+
"timeout": 180,
|
|
156
|
+
"temperature": 0.1
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
"projectTranslator.userPrompts": [
|
|
160
|
+
"1. Should return no need translate if the markdown file has 'draft' set to 'true' in the front matter.",
|
|
161
|
+
"2. './readmes/' in the sentences should replace with './'",
|
|
162
|
+
],
|
|
163
|
+
"projectTranslator.ignore": {
|
|
164
|
+
"paths": [
|
|
165
|
+
"**/node_modules/**"
|
|
166
|
+
],
|
|
167
|
+
"extensions": [
|
|
168
|
+
".log"
|
|
169
|
+
]
|
|
170
|
+
},
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Key configuration details:
|
|
175
|
+
|
|
176
|
+
| Configuration Option | Description |
|
|
177
|
+
| ------------------------------------------- | ---------------------------------------------------------------------------------------------- |
|
|
178
|
+
| `projectTranslator.specifiedFolders` | Multiple source folders with their corresponding destination folders for translation |
|
|
179
|
+
| `projectTranslator.specifiedFiles` | Multiple source files with their corresponding destination files for translation |
|
|
180
|
+
| `projectTranslator.translationIntervalDays` | Translation interval in days (default 7 days) |
|
|
181
|
+
| `projectTranslator.copyOnly` | Files to copy but not translate (with `paths` and `extensions` arrays) |
|
|
182
|
+
| `projectTranslator.ignore` | Files to ignore completely (with `paths` and `extensions` arrays) |
|
|
183
|
+
| `projectTranslator.skipFrontMatterMarkers` | Skip files based on front matter markers (with `enabled` and `markers` arrays) |
|
|
184
|
+
| `projectTranslator.currentVendor` | Current API vendor in use |
|
|
185
|
+
| `projectTranslator.vendors` | API vendor configuration list (can use apiKey directly or apiKeyEnvVarName for environment variables) |
|
|
186
|
+
| `projectTranslator.systemPromptLanguage` | Language used for built-in system prompts (default: en). Affects how the model is instructed, not the UI language |
|
|
187
|
+
| `projectTranslator.systemPrompts` | System prompt array for guiding the translation process |
|
|
188
|
+
| `projectTranslator.userPrompts` | User-defined prompt array, these prompts will be added after system prompts during translation |
|
|
189
|
+
| `projectTranslator.segmentationMarkers` | Segmentation markers configured by file type, supports regular expressions |
|
|
190
|
+
| `projectTranslator.debug` | Enable debug mode to log all API requests and responses to output channel (default: false) |
|
|
191
|
+
| `projectTranslator.logFile` | Configuration for debug log files (see [Log File Feature](./docs/log-file-feature.md)) |
|
|
192
|
+
| `projectTranslator.diffApply.enabled` | Enable experimental differential translation mode (default: false) |
|
|
193
|
+
|
|
194
|
+
## Usage
|
|
195
|
+
|
|
196
|
+
1. Open command palette (Ctrl+Shift+P / Cmd+Shift+P)
|
|
197
|
+
2. Type "Translate Project" and select the command
|
|
198
|
+
3. If source folder is not configured, a folder selection dialog will appear
|
|
199
|
+
4. Wait for translation to complete
|
|
200
|
+
|
|
201
|
+
During translation:
|
|
202
|
+
|
|
203
|
+
- Can pause/resume translation via status bar buttons
|
|
204
|
+
- Can stop translation process at any time
|
|
205
|
+
- Translation progress shown in notification area
|
|
206
|
+
- Detailed logs displayed in output panel
|
|
207
|
+
|
|
208
|
+
## CLI Usage
|
|
209
|
+
|
|
210
|
+
The project now supports CLI execution in addition to the VS Code extension.
|
|
211
|
+
|
|
212
|
+
Build CLI output:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
npm run compile
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Run translation:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
npx project-translator translate project --workspace . --config project.translation.json
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Manage config:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
npx project-translator config list --workspace . --config project.translation.json --json
|
|
228
|
+
npx project-translator config set currentVendor deepseek --workspace . --config project.translation.json
|
|
229
|
+
npx project-translator config schema --workspace .
|
|
230
|
+
npx project-translator config validate --workspace . --config project.translation.json
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
`config schema` will export `project.translation.schema.json` by default.
|
|
234
|
+
`config validate` performs JSON Schema validation on the config file and returns a non-zero exit code when invalid.
|
|
235
|
+
|
|
236
|
+
## Development
|
|
237
|
+
|
|
238
|
+
### Build System
|
|
239
|
+
|
|
240
|
+
This extension uses esbuild for fast bundling and development:
|
|
241
|
+
|
|
242
|
+
#### Available Scripts
|
|
243
|
+
|
|
244
|
+
- `npm run build` - Production build with minification
|
|
245
|
+
- `npm run compile` - Development build
|
|
246
|
+
- `npm run watch` - Watch mode for development
|
|
247
|
+
- `npm test` - Run tests
|
|
248
|
+
|
|
249
|
+
#### VS Code Tasks
|
|
250
|
+
|
|
251
|
+
- **Build** (Ctrl+Shift+P → "Tasks: Run Task" → "build") - Bundles extension for production
|
|
252
|
+
- **Watch** (Ctrl+Shift+P → "Tasks: Run Task" → "watch") - Development mode with auto-rebuild
|
|
253
|
+
|
|
254
|
+
### Development Setup
|
|
255
|
+
|
|
256
|
+
1. Clone the repository
|
|
257
|
+
2. Run `npm install` to install dependencies
|
|
258
|
+
3. Press `F5` to start debugging or run the "watch" task for development
|
|
259
|
+
|
|
260
|
+
The esbuild configuration:
|
|
261
|
+
|
|
262
|
+
- Bundles all TypeScript files into a single `out/extension.js`
|
|
263
|
+
- Excludes VS Code API (marked as external)
|
|
264
|
+
|
|
265
|
+
## Advanced Features
|
|
266
|
+
|
|
267
|
+
### Using Environment Variables for API Keys
|
|
268
|
+
|
|
269
|
+
Project Translator supports using environment variables for API keys, which is a more secure approach than storing API keys directly in configuration files:
|
|
270
|
+
|
|
271
|
+
1. Configure your vendor with an `apiKeyEnvVarName` property:
|
|
272
|
+
|
|
273
|
+
```json
|
|
274
|
+
{
|
|
275
|
+
"projectTranslator.vendors": [
|
|
276
|
+
{
|
|
277
|
+
"name": "openai",
|
|
278
|
+
"apiEndpoint": "https://api.openai.com/v1",
|
|
279
|
+
"apiKeyEnvVarName": "OPENAI_API_KEY",
|
|
280
|
+
"model": "gpt-4"
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"name": "openrouter",
|
|
284
|
+
"apiEndpoint": "https://openrouter.ai/api/v1",
|
|
285
|
+
"apiKeyEnvVarName": "OPENROUTER_API_KEY",
|
|
286
|
+
"model": "anthropic/claude-3-opus"
|
|
287
|
+
}
|
|
288
|
+
]
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
2. Set the environment variable in your system:
|
|
293
|
+
- On Windows: `set OPENAI_API_KEY=your_api_key`
|
|
294
|
+
- On macOS/Linux: `export OPENAI_API_KEY=your_api_key`
|
|
295
|
+
|
|
296
|
+
3. When the extension runs, it will:
|
|
297
|
+
- First check if `apiKey` is provided directly in the configuration
|
|
298
|
+
- If not, it will look for the environment variable specified by `apiKeyEnvVarName`
|
|
299
|
+
|
|
300
|
+
This approach keeps your API keys out of configuration files and version control systems.
|
|
301
|
+
|
|
302
|
+
### Skip Translation Based on Front Matter
|
|
303
|
+
|
|
304
|
+
Project Translator can skip translation of Markdown files based on their front matter metadata. This is useful for draft documents or files marked as not requiring translation.
|
|
305
|
+
|
|
306
|
+
To enable this feature, configure the `projectTranslator.skipFrontMatterMarkers` option:
|
|
307
|
+
|
|
308
|
+
```json
|
|
309
|
+
{
|
|
310
|
+
"projectTranslator.skipFrontMatterMarkers": {
|
|
311
|
+
"enabled": true,
|
|
312
|
+
"markers": [
|
|
313
|
+
{
|
|
314
|
+
"key": "draft",
|
|
315
|
+
"value": "true"
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
"key": "translate",
|
|
319
|
+
"value": "false"
|
|
320
|
+
}
|
|
321
|
+
]
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
With this configuration, any Markdown file with front matter containing `draft: true` or `translate: false` will be skipped during translation and directly copied to the target location.
|
|
327
|
+
|
|
328
|
+
Example Markdown file that would be skipped:
|
|
329
|
+
```
|
|
330
|
+
---
|
|
331
|
+
draft: true
|
|
332
|
+
title: "Draft Document"
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
This document is a draft and should not be translated.
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Differential Translation (Diff-Apply) Mode
|
|
339
|
+
|
|
340
|
+
> **⚠️ Experimental Feature Warning**: Differential translation mode is currently an experimental feature and may have stability and compatibility issues. It is recommended to use it with caution in production environments and always backup important files.
|
|
341
|
+
|
|
342
|
+
The extension supports an optional differential translation mode (diff-apply). When enabled, the extension sends both the source content and the existing translated target file to the model. The model should return one or more SEARCH/REPLACE blocks (plain text, no code fences). The extension applies these blocks locally to minimize changes, reduce API usage, and better preserve version history.
|
|
343
|
+
|
|
344
|
+
- **Toggle**: Configure `projectTranslator.diffApply.enabled` in VS Code settings or `project.translation.json` (default: `false`).
|
|
345
|
+
- **Options**:
|
|
346
|
+
- `validationLevel`: `normal` or `strict` (default: `normal`). In `strict` mode, invalid markers or matching failures will cause an error and the extension will fall back to the standard translation flow.
|
|
347
|
+
- `autoBackup`: If true, create a `.bak` backup of the target file before applying edits (default: `true`).
|
|
348
|
+
- `maxOperationsPerFile`: (retained for compatibility) not used by the new strategy.
|
|
349
|
+
|
|
350
|
+
Workflow:
|
|
351
|
+
1. If `diffApply.enabled` is `true` and the target file exists, the extension reads both source and target contents.
|
|
352
|
+
2. It calls the model with a differential prompt and requires returning plain-text SEARCH/REPLACE blocks.
|
|
353
|
+
3. Locally, the extension parses and applies the SEARCH/REPLACE blocks. If application fails, it falls back to the normal full translation and overwrites the target file.
|
|
354
|
+
|
|
355
|
+
Example SEARCH/REPLACE (multiple blocks allowed):
|
|
356
|
+
|
|
357
|
+
```
|
|
358
|
+
<<<<<<< SEARCH
|
|
359
|
+
:start_line: 10
|
|
360
|
+
-------
|
|
361
|
+
const label = "Old"
|
|
362
|
+
=======
|
|
363
|
+
const label = "New"
|
|
364
|
+
>>>>>>> REPLACE
|
|
365
|
+
|
|
366
|
+
<<<<<<< SEARCH
|
|
367
|
+
:start_line: 25
|
|
368
|
+
-------
|
|
369
|
+
function foo() {
|
|
370
|
+
return 1
|
|
371
|
+
}
|
|
372
|
+
=======
|
|
373
|
+
function foo() {
|
|
374
|
+
return 2
|
|
375
|
+
}
|
|
376
|
+
>>>>>>> REPLACE
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
Notes:
|
|
380
|
+
- Use exact content including indentation and whitespace in SEARCH sections. If unsure, use the latest file content.
|
|
381
|
+
- Keep a single line of `=======` between SEARCH and REPLACE.
|
|
382
|
+
- If no change is needed, the model should return an empty string.
|
|
383
|
+
|
|
384
|
+
Why differential translation currently performs poorly (explanation)
|
|
385
|
+
|
|
386
|
+
- **Cross-language alignment and comparison challenges**: Differential translation requires sending both the original source document and the existing translated document to the model, and the model must compare them across languages to decide which parts of the translation need to be changed. This is a fundamentally harder task than modifying a single document in-place because the model must accurately align segments in different languages and judge semantic differences.
|
|
387
|
+
|
|
388
|
+
- **Complexity of format and boundary preservation**: Many documents contain code blocks, tables, frontend markers, or special placeholders. A reliable diff workflow must preserve these structures while making textual edits. If the model cannot consistently produce results that strictly follow the SEARCH/REPLACE format, applying edits automatically may introduce formatting regressions or structural errors.
|
|
389
|
+
|
|
390
|
+
- **Context and terminology consistency issues**: Small, localized edits often depend on broader context and an existing terminology/style glossary. When asked to produce minimal edits, the model may neglect global consistency (terminology, style, comments, variable names), resulting in inconsistent or semantically shifted translations.
|
|
391
|
+
|
|
392
|
+
- **Model stability and cost trade-offs**: Achieving a dependable differential translation requires models with strong comparative reasoning and stable, predictable output formats. Current mainstream models do not reliably provide both robust cross-language alignment and strictly formatted outputs at reasonable cost, so systems often fall back to a full retranslation to ensure correctness.
|
|
393
|
+
|
|
394
|
+
Therefore, while differential translation can theoretically reduce expensive output tokens and better preserve version history, it is currently limited by models' cross-language comparison capabilities and output stability. This feature remains experimental; recommended mitigations include keeping automatic backups (`autoBackup: true`), using a tolerant validation level (`validationLevel: "normal"`), and falling back to full retranslation when matching or formatting fails. In the future, specialized bilingual alignment post-processors or custom smaller models may improve the stability of the diff approach.
|
|
395
|
+
|
|
396
|
+
Cost savings and why it helps
|
|
397
|
+
|
|
398
|
+
- **Input vs Output token cost**: Large-model APIs commonly charge differently for input (prompt) and output (completion) tokens. Often, output tokens are significantly more expensive because the model generates longer text. Diff-apply helps because we send the **updated source (input)** and the **existing translated file (input)** to the model and ask for a compact JSON of edits. The model's response is a small JSON (few output tokens) rather than a full retranslated file (many output tokens), so you pay much less for the expensive output portion.
|
|
399
|
+
|
|
400
|
+
- **Only send what's changed**: Instead of re-translating the entire file whenever small changes occur, diff-apply instructs the model to compute the minimal edit operations to update the existing translation. This is particularly effective for files that were previously translated and only receive incremental edits.
|
|
401
|
+
|
|
402
|
+
- **Best for formatted files**: Files with strict formatting (JSON, XML, Markdown with code blocks) benefit greatly because diff-apply preserves structure and only changes textual parts that need translation. That reduces the chance of format-related regressions and extra output tokens caused by model reformatting.
|
|
403
|
+
|
|
404
|
+
- **Line-oriented base unit, smarter aggregation**: The tool treats the basic translation unit as a "line", and the SEARCH/REPLACE strategy applies exact or fuzzy matching near `:start_line:`. Use `validationLevel: "normal"` for tolerant behavior and `"strict"` when you need conservative, exact edits.
|
|
405
|
+
|
|
406
|
+
When to use diff-apply:
|
|
407
|
+
|
|
408
|
+
- Use when the target file already exists and was previously translated.
|
|
409
|
+
- Use for large, formatted documents where re-translating the whole file would be expensive.
|
|
410
|
+
- Avoid for brand-new files without any previous translation, or when you want a fresh retranslation.
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
### Design Documentation
|
|
415
|
+
|
|
416
|
+
- Generates source maps for development builds
|
|
417
|
+
- Minifies code for production builds
|
|
418
|
+
- Provides problem matcher integration for VS Code
|
|
419
|
+
|
|
420
|
+
## Notes
|
|
421
|
+
|
|
422
|
+
- Ensure sufficient API usage quota
|
|
423
|
+
- Recommended to test with small projects first
|
|
424
|
+
- Use dedicated API keys and remove them after completion
|
|
425
|
+
|
|
426
|
+
## License
|
|
427
|
+
|
|
428
|
+
[License](LICENSE)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
{
|
|
3
|
+
"extension.activated": "إضافة مترجم المشروع نشطة الآن!",
|
|
4
|
+
"status.translation.paused": "تم إيقاف الترجمة مؤقتًا",
|
|
5
|
+
"status.translation.resumed": "تم استئناف الترجمة",
|
|
6
|
+
"status.translation.cancelled": "تم إلغاء الترجمة",
|
|
7
|
+
"status.translation.inProgress": "جارٍ الترجمة...",
|
|
8
|
+
"status.translation.pause": "إيقاف الترجمة مؤقتًا",
|
|
9
|
+
"status.translation.resume": "استئناف الترجمة",
|
|
10
|
+
"status.translation.cancel": "إلغاء الترجمة",
|
|
11
|
+
"autoTranslate.common.noWorkspace": "يرجى فتح مساحة عمل أولاً",
|
|
12
|
+
"autoTranslate.enable.parseTasksJsonError": "⚠️ فشل في تحليل tasks.json الموجود، سيتم إنشاء هيكل أساسي مع المهمة الجديدة. الخطأ:",
|
|
13
|
+
"autoTranslate.enable.successLog": "✅ تمت كتابة مهمة الترجمة التلقائية إلى",
|
|
14
|
+
"autoTranslate.enable.reloadPrompt": "تم تفعيل الترجمة التلقائية عند فتح المجلد. هل تريد إعادة تحميل النافذة الآن لتفعيل التغييرات؟",
|
|
15
|
+
"autoTranslate.enable.reloadNow": "إعادة تحميل النافذة",
|
|
16
|
+
"autoTranslate.enable.reloadLater": "لاحقًا",
|
|
17
|
+
"autoTranslate.enable.error": "فشل في تفعيل مهمة الترجمة التلقائية:",
|
|
18
|
+
"autoTranslate.disable.noTasks": "لم يتم العثور على ملف tasks.json؛ يبدو أن الترجمة التلقائية عند فتح المجلد غير مفعلة.",
|
|
19
|
+
"autoTranslate.disable.parseErrorMessage": "فشل في تحليل ملف tasks.json؛ سيتم تخطي التغييرات لتجنب إتلاف الملف.",
|
|
20
|
+
"autoTranslate.disable.parseErrorLog": "فشل في تحليل ملف tasks.json:",
|
|
21
|
+
"autoTranslate.disable.alreadyDisabled": "يبدو أن الترجمة التلقائية عند فتح المجلد معطلة بالفعل.",
|
|
22
|
+
"autoTranslate.disable.alreadyDisabledLog": "لم يتم العثور على إعداد runOn لتعطيله؛ قد يكون معطلاً بالفعل.",
|
|
23
|
+
"autoTranslate.disable.successLog": "✅ تم تعطيل مهمة الترجمة التلقائية (تمت إزالة runOn) في",
|
|
24
|
+
"autoTranslate.disable.successInfo": "تم تعطيل الترجمة التلقائية عند فتح المجلد.",
|
|
25
|
+
"autoTranslate.disable.error": "فشل في تعطيل مهمة الترجمة التلقائية:"
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
{
|
|
3
|
+
"extension.activated": "Project Translator-Erweiterung ist jetzt aktiv!",
|
|
4
|
+
"status.translation.paused": "Übersetzung pausiert",
|
|
5
|
+
"status.translation.resumed": "Übersetzung fortgesetzt",
|
|
6
|
+
"status.translation.cancelled": "Übersetzung abgebrochen",
|
|
7
|
+
"status.translation.inProgress": "Übersetzung läuft...",
|
|
8
|
+
"status.translation.pause": "Übersetzung pausieren",
|
|
9
|
+
"status.translation.resume": "Übersetzung fortsetzen",
|
|
10
|
+
"status.translation.cancel": "Übersetzung abbrechen",
|
|
11
|
+
"autoTranslate.common.noWorkspace": "Bitte öffnen Sie zuerst einen Arbeitsbereich",
|
|
12
|
+
"autoTranslate.enable.parseTasksJsonError": "⚠️ Fehler beim Parsen der vorhandenen tasks.json, es wird eine minimale Struktur mit der neuen Aufgabe erstellt. Fehler:",
|
|
13
|
+
"autoTranslate.enable.successLog": "✅ Auto-Übersetzungs-Aufgabe wurde geschrieben in",
|
|
14
|
+
"autoTranslate.enable.reloadPrompt": "Auto-Übersetzung beim Öffnen eines Ordners wurde aktiviert. Fenster jetzt neu laden, damit die Änderungen wirksam werden?",
|
|
15
|
+
"autoTranslate.enable.reloadNow": "Fenster neu laden",
|
|
16
|
+
"autoTranslate.enable.reloadLater": "Später",
|
|
17
|
+
"autoTranslate.enable.error": "Fehler beim Aktivieren der Auto-Übersetzungs-Aufgabe:",
|
|
18
|
+
"autoTranslate.disable.noTasks": "Keine tasks.json gefunden; die Auto-Übersetzung beim Öffnen eines Ordners scheint nicht aktiviert zu sein.",
|
|
19
|
+
"autoTranslate.disable.parseErrorMessage": "Fehler beim Parsen der tasks.json; Änderungen werden übersprungen, um eine Beschädigung der Datei zu vermeiden.",
|
|
20
|
+
"autoTranslate.disable.parseErrorLog": "Fehler beim Parsen der tasks.json:",
|
|
21
|
+
"autoTranslate.disable.alreadyDisabled": "Die Auto-Übersetzung beim Öffnen eines Ordners scheint bereits deaktiviert zu sein.",
|
|
22
|
+
"autoTranslate.disable.alreadyDisabledLog": "Keine runOn-Einstellung zum Deaktivieren gefunden; sie ist möglicherweise bereits deaktiviert.",
|
|
23
|
+
"autoTranslate.disable.successLog": "✅ Auto-Übersetzungs-Aufgabe deaktiviert (runOn entfernt) in",
|
|
24
|
+
"autoTranslate.disable.successInfo": "Die Auto-Übersetzung beim Öffnen eines Ordners wurde deaktiviert.",
|
|
25
|
+
"autoTranslate.disable.error": "Fehler beim Deaktivieren der Auto-Übersetzungs-Aufgabe:"
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
{
|
|
3
|
+
"extension.activated": "¡La extensión Project Translator ahora está activa!",
|
|
4
|
+
"status.translation.paused": "Traducción en pausa",
|
|
5
|
+
"status.translation.resumed": "Traducción reanudada",
|
|
6
|
+
"status.translation.cancelled": "Traducción cancelada",
|
|
7
|
+
"status.translation.inProgress": "Traduciendo...",
|
|
8
|
+
"status.translation.pause": "Pausar traducción",
|
|
9
|
+
"status.translation.resume": "Reanudar traducción",
|
|
10
|
+
"status.translation.cancel": "Cancelar traducción",
|
|
11
|
+
"autoTranslate.common.noWorkspace": "Por favor, abra un espacio de trabajo primero",
|
|
12
|
+
"autoTranslate.enable.parseTasksJsonError": "⚠️ Error al analizar el tasks.json existente, se creará una estructura mínima con la nueva tarea. Error:",
|
|
13
|
+
"autoTranslate.enable.successLog": "✅ La tarea de traducción automática se ha escrito en",
|
|
14
|
+
"autoTranslate.enable.reloadPrompt": "Se ha habilitado la traducción automática al abrir la carpeta. ¿Recargar la ventana ahora para que surta efecto?",
|
|
15
|
+
"autoTranslate.enable.reloadNow": "Recargar ventana",
|
|
16
|
+
"autoTranslate.enable.reloadLater": "Más tarde",
|
|
17
|
+
"autoTranslate.enable.error": "Error al habilitar la tarea de traducción automática:",
|
|
18
|
+
"autoTranslate.disable.noTasks": "No se encontró tasks.json; la traducción automática al abrir la carpeta no parece estar habilitada.",
|
|
19
|
+
"autoTranslate.disable.parseErrorMessage": "Error al analizar tasks.json; omitiendo cambios para evitar corromper el archivo.",
|
|
20
|
+
"autoTranslate.disable.parseErrorLog": "Error al analizar tasks.json:",
|
|
21
|
+
"autoTranslate.disable.alreadyDisabled": "La traducción automática al abrir la carpeta ya parece estar deshabilitada.",
|
|
22
|
+
"autoTranslate.disable.alreadyDisabledLog": "No se encontró la configuración runOn para deshabilitar; ya puede estar deshabilitada.",
|
|
23
|
+
"autoTranslate.disable.successLog": "✅ Tarea de traducción automática deshabilitada (runOn eliminado) en",
|
|
24
|
+
"autoTranslate.disable.successInfo": "Se ha deshabilitado la traducción automática al abrir la carpeta.",
|
|
25
|
+
"autoTranslate.disable.error": "Error al deshabilitar la tarea de traducción automática:"
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
{
|
|
3
|
+
"extension.activated": "L'extension Project Translator est maintenant active !",
|
|
4
|
+
"status.translation.paused": "Traduction en pause",
|
|
5
|
+
"status.translation.resumed": "Traduction reprise",
|
|
6
|
+
"status.translation.cancelled": "Traduction annulée",
|
|
7
|
+
"status.translation.inProgress": "Traduction en cours...",
|
|
8
|
+
"status.translation.pause": "Mettre la traduction en pause",
|
|
9
|
+
"status.translation.resume": "Reprendre la traduction",
|
|
10
|
+
"status.translation.cancel": "Annuler la traduction",
|
|
11
|
+
"autoTranslate.common.noWorkspace": "Veuillez d'abord ouvrir un espace de travail",
|
|
12
|
+
"autoTranslate.enable.parseTasksJsonError": "⚠️ Échec de l'analyse du fichier tasks.json existant, une structure minimale sera créée avec la nouvelle tâche. Erreur :",
|
|
13
|
+
"autoTranslate.enable.successLog": "✅ La tâche de traduction automatique a été écrite dans",
|
|
14
|
+
"autoTranslate.enable.reloadPrompt": "La traduction automatique à l'ouverture du dossier a été activée. Recharger la fenêtre maintenant pour prendre effet ?",
|
|
15
|
+
"autoTranslate.enable.reloadNow": "Recharger la fenêtre",
|
|
16
|
+
"autoTranslate.enable.reloadLater": "Plus tard",
|
|
17
|
+
"autoTranslate.enable.error": "Échec de l'activation de la tâche de traduction automatique :",
|
|
18
|
+
"autoTranslate.disable.noTasks": "Fichier tasks.json introuvable ; la traduction automatique à l'ouverture du dossier ne semble pas être activée.",
|
|
19
|
+
"autoTranslate.disable.parseErrorMessage": "Échec de l'analyse de tasks.json ; modifications ignorées pour éviter de corrompre le fichier.",
|
|
20
|
+
"autoTranslate.disable.parseErrorLog": "Échec de l'analyse de tasks.json :",
|
|
21
|
+
"autoTranslate.disable.alreadyDisabled": "La traduction automatique à l'ouverture du dossier semble déjà être désactivée.",
|
|
22
|
+
"autoTranslate.disable.alreadyDisabledLog": "Aucun paramètre runOn trouvé à désactiver ; il est peut-être déjà désactivé.",
|
|
23
|
+
"autoTranslate.disable.successLog": "✅ Tâche de traduction automatique désactivée (runOn supprimé) dans",
|
|
24
|
+
"autoTranslate.disable.successInfo": "La traduction automatique à l'ouverture du dossier a été désactivée.",
|
|
25
|
+
"autoTranslate.disable.error": "Échec de la désactivation de la tâche de traduction automatique :"
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
{
|
|
3
|
+
"extension.activated": "プロジェクト翻訳拡張機能がアクティブになりました!",
|
|
4
|
+
"status.translation.paused": "翻訳が一時停止されました",
|
|
5
|
+
"status.translation.resumed": "翻訳が再開されました",
|
|
6
|
+
"status.translation.cancelled": "翻訳がキャンセルされました",
|
|
7
|
+
"status.translation.inProgress": "翻訳中...",
|
|
8
|
+
"status.translation.pause": "翻訳を一時停止",
|
|
9
|
+
"status.translation.resume": "翻訳を再開",
|
|
10
|
+
"status.translation.cancel": "翻訳をキャンセル",
|
|
11
|
+
"autoTranslate.common.noWorkspace": "まずワークスペースを開いてください",
|
|
12
|
+
"autoTranslate.enable.parseTasksJsonError": "⚠️ 既存のtasks.jsonの解析に失敗しました。新しいタスクで最小限の構造を作成します。エラー:",
|
|
13
|
+
"autoTranslate.enable.successLog": "✅ 自動翻訳タスクが書き込まれました:",
|
|
14
|
+
"autoTranslate.enable.reloadPrompt": "フォルダー開時の自動翻訳が有効になりました。今すぐウィンドウをリロードして有効にしますか?",
|
|
15
|
+
"autoTranslate.enable.reloadNow": "ウィンドウをリロード",
|
|
16
|
+
"autoTranslate.enable.reloadLater": "後で",
|
|
17
|
+
"autoTranslate.enable.error": "自動翻訳タスクの有効化に失敗しました:",
|
|
18
|
+
"autoTranslate.disable.noTasks": "tasks.jsonが見つかりません。フォルダー開時の自動翻訳は有効になっていないようです。",
|
|
19
|
+
"autoTranslate.disable.parseErrorMessage": "tasks.jsonの解析に失敗しました。ファイル破損を避けるため、変更をスキップします。",
|
|
20
|
+
"autoTranslate.disable.parseErrorLog": "tasks.jsonの解析に失敗しました:",
|
|
21
|
+
"autoTranslate.disable.alreadyDisabled": "フォルダー開時の自動翻訳はすでに無効になっているようです。",
|
|
22
|
+
"autoTranslate.disable.alreadyDisabledLog": "無効にするrunOn設定が見つかりません。すでに無効になっている可能性があります。",
|
|
23
|
+
"autoTranslate.disable.successLog": "✅ 自動翻訳タスクを無効にしました(runOnを削除):",
|
|
24
|
+
"autoTranslate.disable.successInfo": "フォルダー開時の自動翻訳が無効になりました。",
|
|
25
|
+
"autoTranslate.disable.error": "自動翻訳タスクの無効化に失敗しました:"
|
|
26
|
+
}
|