c++ - 有没有什么工具可以只翻译代码中的注释

标签 c++ comments translate

<分区>

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

有什么想法吗?

谢谢。

最佳答案

如果 Google translate 翻译得足够好,这里有一个适用于 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

关于c++ - 有没有什么工具可以只翻译代码中的注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10826514/

相关文章:

text-to-speech - 在 python 中使用 gTTS 时出现 Unicode 解码错误

javascript - 如何将 jquery 转换为 javascript?

c++ - ACE 宏定义错误

latex - 在LaTeX中添加类似MS-Word的注释

c++ - 用于 Visual C++ 的类似 Javadoc 的信息框

syntax - Liquid 中如何注释掉?

amazon-web-services - 我想知道如何通过修改此 lambda 代码将数据导入应用程序

c++ - 我可以使用 Poco 从内存缓冲区创建多文件 zip 存档吗?

c++ - 在文本冒险中实现实时?

c++ - 子类到基类的转换问题