翻译用另一种口语编写的代码注释
我刚刚从一位德国程序员那里继承了一些 C 代码,所有注释自然都是德语的。由于我已经忘记了大部分高中德语,所以这是一个小问题。
有谁知道有代码感知的翻译工具吗?这意味着它只会翻译评论中的语言?该项目有很多文件,能够同时对所有文件进行操作也很棒。
我目前正在复制并粘贴到谷歌翻译中,虽然这不太理想,但它至少可以给我一些答案。
I've just inherited some C code from a German programmer, and all of the comments are, naturally, in German. As I've forgotten most of my high school German, this is a slight problem.
Does anyone know of any translation tools that are code-aware; meaning it will only translate language within comments? The project has many files, being able to operate on all of them at once would also be fantastic.
I'm currently copying-and-pasting into Google Translate, and while this is less than ideal, it can at least get me some answers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我只知道如何在 java 中执行此操作,但我确信在 C 中也有一种方法可以执行此操作,因为工具存在:
I would only know exactly how to do this in java, but I am sure there is a way to do this in C as well, as the tools exist:
从广义上讲,这应该可以使用 Google 翻译的 Ajax API 和一个可以处理回调的正则表达式函数 - 我不认为 JS 的内置正则表达式函数能够胜任这项任务,但我确信那里有库。您必须构建一个正则表达式来隔离注释,将每个块发送到 API,并在回调函数中返回翻译结果。
Very broadly, this should be possible to do using Google translation's Ajax API and a regex function that can deal with callbacks - I don't think JS's built-in regex functions are up to the task but I'm sure there are libraries out there. You would have to build a regular expression that can isolate the comments, send each chunk to the API, and return the translated result in the callback function.