Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have some c++ source files, which contains comments in Italian language, is there any tool which can translate only comments to English language. I have tried Google translate, it will translate the whole file, and the // will be translated too. So, paste from the translation result from Google does not give a valid c++ source file.

Any ideas?

Thanks.

like image 847
ollydbg23 Avatar asked Oct 07 '22 16:10

ollydbg23


1 Answers

If Google translate translates well enough, here is a method that will work for C++ comments (// ...), crude but effective:

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
like image 161
Beta Avatar answered Oct 12 '22 11:10

Beta