All Projects → haya14busa → gtrans

haya14busa / gtrans

Licence: MIT license
Command-line translator using Google Translate

Programming Languages

go
31211 projects - #10 most used programming language

gtrans - Command-line translator using Google Translate

Installation

$ go get github.com/haya14busa/gtrans

Setup

1) Get Google Translation API key

2) Set Google Translation API key as an envitonment variable along with other options.

Setup example:

$ echo 'export GOOGLE_TRANSLATE_API_KEY=<Your API KEY>' >> ~/.gtrans.sh
$ echo 'export GOOGLE_TRANSLATE_LANG=ja' >> ~/.gtrans.sh
$ echo 'export GOOGLE_TRANSLATE_SECOND_LANG=en' >> ~/.gtrans.sh

Bash

$ echo '[ -f ~/.gtrans.sh ] && source ~/.gtrans.sh' >> ~/.bashrc

Zsh

$ echo '[ -f ~/.gtrans.sh ] && source ~/.gtrans.sh' >> ~/.zshrc

Be careful not to expose your API key! Please use it at your own risk.

Usage

Usage:  gtrans [flags] [input text]
        gtrans translates input text specified by argument or STDIN using Google Translate.
        Source language will be automatically detected.

        export GOOGLE_TRANSLATE_API_KEY=<Your Google Translate API Key>

        [optional]
        export GOOGLE_TRANSLATE_LANG=<default target language (e.g. en, ja, ...)>
        export GOOGLE_TRANSLATE_SECOND_LANG=<second language (e.g. en, ja, ...)>

        If you set both GOOGLE_TRANSLATE_LANG and GOOGLE_TRANSLATE_SECOND_LANG,
        gtrans automatically switches target langage.

        Example:
                $ gtrans "Golang is awesome"
                Golangは素晴らしいです
                $ gtrans "Golangは素晴らしいです"
                Golang is great
                $ gtrans "Golangは素晴らしいです" | gtrans | gtrans | gtrans ...

Flags:
  -to string
        target language

Related projects

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].