是否有任何工具只能翻译代码中的注释

oll*_*g23 4 c++ comments translate

我有一些c ++源文件,其中包含意大利语的注释,是否有任何工具只能将注释翻译成英语.我试过谷歌翻译,它将翻译整个文件,//也将被翻译.因此,从Google的翻译结果粘贴不会提供有效的c ++源文件.

有任何想法吗?

谢谢.

Bet*_*eta 5

如果谷歌翻译翻译得足够好,这里有一个适用于C++评论(// ...)的方法,粗略但有效:

Isolate the comments:
sed -e 's|.*//|//|' -e '/\/\//!s|.*||' sourcefile > comments

Remove the comments from the source:
sed 's|//.*||' sourcefile > barecode

Use Google translate on comments.

paste -d '\0' barecode comments > sourcefile
Run Code Online (Sandbox Code Playgroud)