有没有工具可以只翻译代码中的注释

Is there any tool which can translate only comments in the code

本文关键字:代码 注释 翻译 工具 有没有      更新时间:2023-10-16

我有一些c ++源文件,其中包含意大利语的注释,是否有任何工具可以将注释仅翻译成英语。我尝试过谷歌翻译,它会翻译整个文件,并且//也会被翻译。因此,从谷歌的翻译结果粘贴不会给出有效的 c++ 源文件。

有什么想法吗?

谢谢。

如果谷歌翻译翻译得足够好,这里有一种方法可以适用于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 '' barecode comments > sourcefile