Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haya14busa/gtrans
Command-line translator using Google Translate
https://github.com/haya14busa/gtrans
Last synced: 29 days ago
JSON representation
Command-line translator using Google Translate
- Host: GitHub
- URL: https://github.com/haya14busa/gtrans
- Owner: haya14busa
- License: mit
- Created: 2016-11-12T11:20:37.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-24T06:25:37.000Z (almost 7 years ago)
- Last Synced: 2024-10-03T12:44:55.052Z (about 2 months ago)
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 30
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## gtrans - Command-line translator using Google Translate
## Installation
```
$ go get github.com/haya14busa/gtrans
```## Setup
### 1) Get Google Translation API key
- See: https://cloud.google.com/translate/v2/quickstart### 2) Set Google Translation API key as an envitonment variable along with other options.
Setup example:
```
$ echo 'export GOOGLE_TRANSLATE_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=
[optional]
export GOOGLE_TRANSLATE_LANG=
export GOOGLE_TRANSLATE_SECOND_LANG=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
- Vim plugin: https://github.com/haya14busa/vim-gtrans