Skip to content

dhopsonlb/ctrans

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ctrans.py
---------

very crude source code comment translator. powered by google translate.

currently handles C-style and scripting-style (i.e. '#') comments; note that
comments formatted as '### comment' will still end up as '# comment', this
is a bug i don't care about fixing atm; i'm more concerned with just getting
this working.

INSTALLATION:

pip3 install -r requirements.txt

EXAMPLE USAGE:
./ctrans.py -O true -d /home/user/chinese_pseudomalware/src

USAGE:
    ctrans.py -s <filename>
    translates a single file

    ctrans.py -d <dir>
    translates all source files in a directory
    
    other flags:
        -e      set input file encoding
        -o      set output file encoding
        -t      set trace (debugging output)
        -O for overwrite (y/1/true), prevents creating e.g. mycode.c.en files.
        -N for no write (y/1/true), still prints translated code to stdout, but doesn't modify files.
        -L for language (e.g. zh-CN), default is auto for autodetect.

DECODE/ENCODE NOTES:
    the default encoding and decoding is utf-8. specifying 'auto' for the
    decoding will attempt to guess the file's encoding. this is at best a guess,
    and at worst completely wrong.
    
    encoding is not a trivial matter, and there are a million ways a file might
    be encoded. 

TODO:
    * add directory-translating mode
    * add support for multiline C comment
    * verify code is clean, was hacked together in a hurry
    

About

Updated Python3 version of comment translator from https://github.com/kisom/ctrans

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages