command line tool which communicates with google translation server.
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


MyGoogleDict is a command-line program which communicates with google translation server. With the consideration of my personal needs, MyGoogleDict should fulfill the requirements as follow:

  1. Communicate with for translation bussiness.
  2. Support translation of various languages.
  3. Support translation of both a single word and multi-words sentences. Moreover, the program should classify results of translation with respect to their part of speech.
  4. Record and display the search history of user.
  5. Human readable manual in command line interface.


##Depandancy and Resoureces

Depandancies of the program are as follows:

  • docopt v0.6.1 is adopt for parsing arguments.
  • google_translate_api v0.2 handles the communication with google translation server.

##Bussiness The bussiness logic is quite simple. As MyGoogleDict is a command line program, the bussiness logic is roughly determined by the arguments and options entered by user.

Here is the avaliable inputs:

Usage: mgd [-f <from_lang>] [-t <to_lang>]
           [-v|--reverse] [-s|--speak] <data>...
       mgd -r|--record

    -f <from_lang>  input language [default: en]
    -t <to_lang>    ouput language [default: zh-CN]
    -v --reverse    reverse -f and -t
    -r --record     display search record
    -s --speak      speak out the result

where the value of language arguments <from_lang> and <to_lang> could be found in a list of avaliable languages variable.


Code Files

Directory MyGoogleDict contains following files:

  • for the job of argument parsing.
  • for the translation logic.
  • for reading and writing search records.
  • for shared code.
  • for read/write records and configurations.

Release and To-Do List

To-Do List


  • Introduce more error dectection strategy, such as dectecting misspelling input.
  • Design record management strategy.
  • Design a well-formatted user report which displays user's searching history in a period(maybe a month).
  • Implement unit tests.
  • *nix standard IO support.
  • Detect the input language automatically.

Release List


  • Port for google_translate_api v0.3.
  • Improve code organization.


  • Fix bugs for python3.


  • Change dependency from goslate to google_translate_api.
  • Enable TTS service.


  • Implement basic functionality, such as display the result of translation, read and write records.
  • Packaged and uploaded the project, enable user to download it through 'pip install' command.


pip install mgd

##Data Storage and Configuration

Records and configuration file would be stored in ~/.mgd/:

  • ~/.mgd/config stroes the configuration of mgd. Currently, you can configure the default languages of the program.
  • ~/.mgd/cache.xml serves as a cache to record.xml.gz.
  • ~/.mgd/record.xml.gz stores records in xml.gz format.

#Usage Example of usage:

$ mgd -r
No Record.
$ mgd test
[verb] 检验, 试, 考, 测验, 验, 考查, 尝
[noun] 测试, 试验, 试, 实验, 考试, 考验, 测验
$ mgd -s test
[verb] 检验, 试, 考, 测验, 验, 考查, 尝
[noun] 测试, 试验, 试, 实验, 考试, 考验, 测验
$ mgd -t ja test
[verb] 試す, 試みる
[noun] テスト, 試験, 試し, 試練, 考査
$ mgd -f zh-CN -t en 测试
[noun] test, examination
$ mgd -v 测试
[noun] test, examination
$ mgd this is a sentence.
[sentence] 这是一个句子。
$ mgd -r
[this is a sentence.][这是一个句子。]