【问题标题】:Is there any tool which can translate only comments in the code [closed]是否有任何工具可以只翻译代码中的注释[关闭]
【发布时间】:2012-06-05 07:00:29
【问题描述】:

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

有什么想法吗?

谢谢。

【问题讨论】:

  • 斜体有什么问题?它有点倾斜但很容易阅读:)
  • 您指的是意大利语吗?因为我从来没有听说过斜体。
  • 我想知道有多少意大利 C++ 程序员精通英语。我会说至少10,000。你只需要一个。
  • 对不起我原来的问题,我的意思是有很多意大利语言的 cmets。我想把这些 cmets 翻译成英文。我已经更新了我原来的问题。
  • 您必须编写一个小脚本来提取 cmets,翻译它们,然后搜索并替换原件。

标签: c++ comments translate


【解决方案1】:

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

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

【讨论】:

  • 我正在尝试从中文转换为英文 cmets,但在谷歌翻译中出现错误,抱歉,您请求的页面包含我们无法翻译的文件类型(应用程序/八位字节流)。
  • 我发现 github.com/riversun/JavaCommentTranslator 声称也可以处理 C
猜你喜欢
  • 1970-01-01
  • 2010-09-17
  • 2011-01-28
  • 1970-01-01
  • 2010-12-06
  • 1970-01-01
  • 2010-12-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多