Permalink
Browse files

📝 add LICENSE and README

  • Loading branch information...
1 parent b2b1378 commit 4162a0affad57dba5ef91b7bc8e7c8d5ff7354f0 @haya14busa committed Nov 12, 2016
Showing with 82 additions and 0 deletions.
  1. +21 −0 LICENSE
  2. +61 −0 README.md
View
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2016 haya14busa
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
View
@@ -0,0 +1,61 @@
+## 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=<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
+```

0 comments on commit 4162a0a

Please sign in to comment.