推荐VSCode注释翻译插件,方便快速阅读源码
发布于 10 个月前 作者 intellism 4021 次浏览 最后一次编辑是 4 个月前 来自 分享

VSCode 注释翻译

简介

【源码】 【安装】

许多优秀的项目,都有丰富的注释,使用者可以快速理解代码意图。但是如果使用者并不熟习注释的语言,会带来理解困难。本插件使用 Google Translate API 翻译 VSCode 的编程语言的注释。

功能

  1. 识别代码中注释部分,不干扰阅读。支持不同语言,单行、多行注释 Introduction

  2. 支持用户字符串与变量翻译,支持驼峰拆分 Introduction

  3. 选中最后一次翻译区域命令 Introduction

  4. 选择区域翻译 Introduction

配置项

多国语言支持

状态栏快速配置目标语言 Multi-language

Display Language Locale
English (US) en
Simplified Chinese zh-CN
Traditional Chinese zh-TW
French fr
German de
Italian it
Spanish es
Japanese ja
Korean ko
Russian ru
Bulgarian bg
Hungarian hu
Portuguese (Brazil) pt-br
Turkish tr

合并多行注释 (源语言只支持英语)

Multi-line-merge

23 回复

这个插件厉害了

[Error - 下午3:58:24] Request textDocument/hover failed. Message: Request textDocument/hover failed with message: Cannot destructure property commentLines of ‘undefined’ or ‘null’. Code: -32603 \

装了你这插件 控制台输出一直报错

同报错

[Error - 4:30:35 PM] Request textDocument/hover failed.
  Message: Request textDocument/hover failed with message: Cannot destructure property `commentLines` of 'undefined' or 'null'.
  Code: -32603 

@siyue543241338 不好意思,测试不够完整。 请问你就电脑和vscode版本提供下

@CaiPeng1989 翻译功能正常吗?

@intellism 没法使用

(node:19940) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: \\?\c:\Users\CaiPeng\.vscode\extensions\intellsmi.comment-translate-0.0.3\server\node_modules\oniguruma\build\Release\onig_scanner.node is not a valid Win32 application\\?\c:\Users\CaiPeng\.vscode\extensions\intellsmi.comment-translate-0.0.3\server\node_modules\oniguruma\build\Release\onig_scanner.node
(node:19940) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:19940) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: \\?\c:\Users\CaiPeng\.vscode\extensions\intellsmi.comment-translate-0.0.3\server\node_modules\oniguruma\build\Release\onig_scanner.node is not a valid Win32 application\\?\c:\Users\CaiPeng\.vscode\extensions\intellsmi.comment-translate-0.0.3\server\node_modules\oniguruma\build\Release\onig_scanner.node
(node:19940) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): Error: \\?\c:\Users\CaiPeng\.vscode\extensions\intellsmi.comment-translate-0.0.3\server\node_modules\oniguruma\build\Release\onig_scanner.node is not a valid Win32 application\\?\c:\Users\CaiPeng\.vscode\extensions\intellsmi.comment-translate-0.0.3\server\node_modules\oniguruma\build\Release\onig_scanner.node
(node:19940) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): Error: \\?\c:\Users\CaiPeng\.vscode\extensions\intellsmi.comment-translate-0.0.3\server\node_modules\oniguruma\build\Release\onig_scanner.node is not a valid Win32 application\\?\c:\Users\CaiPeng\.vscode\extensions\intellsmi.comment-translate-0.0.3\server\node_modules\oniguruma\build\Release\onig_scanner.node
(node:19940) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 5): Error: \\?\c:\Users\CaiPeng\.vscode\extensions\intellsmi.comment-translate-0.0.3\server\node_modules\oniguruma\build\Release\onig_scanner.node is not a valid Win32 application\\?\c:\Users\CaiPeng\.vscode\extensions\intellsmi.comment-translate-0.0.3\server\node_modules\oniguruma\build\Release\onig_scanner.node
(node:19940) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 6): Error: \\?\c:\Users\CaiPeng\.vscode\extensions\intellsmi.comment-translate-0.0.3\server\node_modules\oniguruma\build\Release\onig_scanner.node is not a valid Win32 application\\?\c:\Users\CaiPeng\.vscode\extensions\intellsmi.comment-translate-0.0.3\server\node_modules\oniguruma\build\Release\onig_scanner.node
(node:19940) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 7): Error: \\?\c:\Users\CaiPeng\.vscode\extensions\intellsmi.comment-translate-0.0.3\server\node_modules\oniguruma\build\Release\onig_scanner.node is not a valid Win32 application\\?\c:\Users\CaiPeng\.vscode\extensions\intellsmi.comment-translate-0.0.3\server\node_modules\oniguruma\build\Release\onig_scanner.node
(node:19940) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 8): Error: \\?\c:\Users\CaiPeng\.vscode\extensions\intellsmi.comment-translate-0.0.3\server\node_modules\oniguruma\build\Release\onig_scanner.node is not a valid Win32 application\\?\c:\Users\CaiPeng\.vscode\extensions\intellsmi.comment-translate-0.0.3\server\node_modules\oniguruma\build\Release\onig_scanner.node
[Error - 5:07:21 PM] Request textDocument/hover failed.
  Message: Request textDocument/hover failed with message: Cannot destructure property `commentLines` of 'undefined' or 'null'.
  Code: -32603

windows 10 1809 17763.55 node v10.12.0 vscode

版本: 1.28.2 (system setup)
提交: 7f3ce96ff4729c91352ae6def877e59c561f4850
日期: 2018-10-17T00:23:51.859Z
Electron: 2.0.9
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
架构: x64

@CaiPeng1989 已复现,win 电脑解析ast错误了,马上修复。

@intellism deepin linux 系统 vs code 版本 code_1.28.2-1539735992_amd64

windows 还是gg

不管还是挺期待这个插件的

拜读了一下, 看不懂, 就找到了API接口, 有时间好好学习

@siyue543241338 已修复,辛苦验证下linux

@CaiPeng1989 已修复,window自测通过,重试看看

@intellism 有时候可以有时候不行。。

[Error - 上午8:55:29] Request textDocument/hover failed. Message: Request textDocument/hover failed with message: Cannot destructure property commentLines of ‘undefined’ or ‘null’. Code: -32603

///////////////////////////////

Overwriting grammar scope name to file mapping for scope source.python. Old grammar file: /usr/share/code/resources/app/extensions/python/syntaxes/MagicPython.tmLanguage.json. New grammar file: /home/siyue/.vscode/extensions/tht13.python-0.2.3/syntaxes/python.tmLanguage Overwriting grammar scope name to file mapping for scope source.regexp.python. Old grammar file: /usr/share/code/resources/app/extensions/python/syntaxes/MagicRegExp.tmLanguage.json. New grammar file: /home/siyue/.vscode/extensions/tht13.python-0.2.3/syntaxes/Regular Expressions (Python).tmLanguage

////////////////////////

/home/siyue/.vscode/extensions/intellsmi.comment-translate-1.0.0/server/out/util/request-promise.js:9 resolve(response.body); ^

TypeError: Cannot read property ‘body’ of undefined at Request.request [as _callback] (/home/siyue/.vscode/extensions/intellsmi.comment-translate-1.0.0/server/out/util/request-promise.js:9:30) at self.callback (/home/siyue/.vscode/extensions/intellsmi.comment-translate-1.0.0/server/node_modules/request/request.js:185:22) at emitOne (events.js:116:13) at Request.emit (events.js:211:7) at Request.onRequestError (/home/siyue/.vscode/extensions/intellsmi.comment-translate-1.0.0/server/node_modules/request/request.js:881:8) at emitOne (events.js:116:13) at ClientRequest.emit (events.js:211:7) at ClientRequest.onError (/home/siyue/.vscode/extensions/intellsmi.comment-translate-1.0.0/server/node_modules/tunnel-agent/index.js:179:21) at Object.onceWrapper (events.js:315:30) at emitOne (events.js:116:13) [Info - 上午8:54:42] Connection to server got closed. Server will restart. [Error - 上午8:54:42] Request textDocument/hover failed. Error: Connection got disposed. at Object.dispose (/home/siyue/.vscode/extensions/intellsmi.comment-translate-1.0.0/client/node_modules/vscode-jsonrpc/lib/main.js:825:25) at Object.dispose (/home/siyue/.vscode/extensions/intellsmi.comment-translate-1.0.0/client/node_modules/vscode-languageclient/lib/client.js:57:35) at LanguageClient.handleConnectionClosed (/home/siyue/.vscode/extensions/intellsmi.comment-translate-1.0.0/client/node_modules/vscode-languageclient/lib/client.js:1983:42) at LanguageClient.handleConnectionClosed (/home/siyue/.vscode/extensions/intellsmi.comment-translate-1.0.0/client/node_modules/vscode-languageclient/lib/main.js:126:15) at closeHandler (/home/siyue/.vscode/extensions/intellsmi.comment-translate-1.0.0/client/node_modules/vscode-languageclient/lib/client.js:1970:18) at CallbackList.invoke (/home/siyue/.vscode/extensions/intellsmi.comment-translate-1.0.0/client/node_modules/vscode-jsonrpc/lib/events.js:71:39) at Emitter.fire (/home/siyue/.vscode/extensions/intellsmi.comment-translate-1.0.0/client/node_modules/vscode-jsonrpc/lib/events.js:135:36) at closeHandler (/home/siyue/.vscode/extensions/intellsmi.comment-translate-1.0.0/client/node_modules/vscode-jsonrpc/lib/main.js:221:26) at CallbackList.invoke (/home/siyue/.vscode/extensions/intellsmi.comment-translate-1.0.0/client/node_modules/vscode-jsonrpc/lib/events.js:71:39) at Emitter.fire (/home/siyue/.vscode/extensions/intellsmi.comment-translate-1.0.0/client/node_modules/vscode-jsonrpc/lib/events.js:135:36) at IPCMessageReader.AbstractMessageReader.fireClose (/home/siyue/.vscode/extensions/intellsmi.comment-translate-1.0.0/client/node_modules/vscode-jsonrpc/lib/messageReader.js:135:27) at ChildProcess.<anonymous> (/home/siyue/.vscode/extensions/intellsmi.comment-translate-1.0.0/client/node_modules/vscode-jsonrpc/lib/messageReader.js:253:61) at emitTwo (events.js:131:20) at ChildProcess.emit (events.js:214:7) at maybeClose (internal/child_process.js:925:16) at Socket.stream.socket.on (internal/child_process.js:346:11) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at Pipe._handle.close [as _onclose] (net.js:554:12) Overwriting grammar scope name to file mapping for scope source.python. Old grammar file: /usr/share/code/resources/app/extensions/python/syntaxes/MagicPython.tmLanguage.json. New grammar file: /home/siyue/.vscode/extensions/tht13.python-0.2.3/syntaxes/python.tmLanguage Overwriting grammar scope name to file mapping for scope source.regexp.python. Old grammar file: /usr/share/code/resources/app/extensions/python/syntaxes/MagicRegExp.tmLanguage.json. New grammar file: /home/siyue/.vscode/extensions/tht13.python-0.2.3/syntaxes/Regular Expressions (Python).tmLanguage

@siyue543241338 linux我没环境测试,方便到github提个issue,在那边了沟通下详情情况

@intellism 又测试了下没问题了 是因为我一直开着vpn翻墙 不过能 切换 谷歌和有道api就好了

@siyue543241338 好的. 有道API很容易支持,测试过有道的翻译,这类场景效果不是特别理想。下个版本添加上,不作为默认选项。

更新:支持用户字符串与变量翻译

楼主,提个建议, 不要一报错就弹出输出面板。

一直弹,一直弹,很烦人的

@axetroy 好的。麻烦提供下报错信息,没有复现错误原因,日志没有关闭。

@axetroy 已修复。 如果还有问题或建议,请继续给提issue

挺好用的,赞

回到顶部