Automatically convert comments in source code to English.
Python
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
transource

README.md

Utility to automatically convert C++-style comments (//) in source code from any language to English.

Limitations

It's pretty dumb at the moment, it will not translate multiline (/* */) comments, and it will translate consecutive comments line by line, not as a single whole.

Prerequisites

  1. sudo pip install microsofttranslator

  2. Get your Client ID and Client Secret from Microsoft, read instructions at microsofttranslator's lib page ("Registering your application" part)

(Optional) Configure

Create ~/.transource.cfg with contents like this (it's in JSON format):

{
	"clientId": "your client id",
	"clientSecret": "your client secret"
}

Running

If you've configured your ~/.transource.cfg at previous step, then just run:

transource <sourcefile> > <outputFile>

Or if not, pass your secret values as command-line options:

transource --cid <yourClientId> --secret <yourClientSecret> <sourcefile> > <outputFile>

Mass-processing

For mass-translating of lots of files I use this (make sure you have backups of your files before running, of course):

find . -name '*.[hc]' -exec sh -c 'transource {} > {}.tmp && mv {}.tmp {}' \;