From 0262821429ab0106160c0b3dd3aacaaac7c3ebe7 Mon Sep 17 00:00:00 2001
From: Jason Dobry <jmdobry@users.noreply.github.com>
Date: Sat, 20 Aug 2016 18:10:57 -0700
Subject: [PATCH] Add Translate API samples. Fixes #176. (#184)

* Add Translate API samples. Fixes #176.

* Fix build.

* Add comment.

* Address comments
---
 .../google-cloud-translate/samples/README.md  | 57 +++++++++++++++++++
 .../samples/package.json                      | 19 +++++++
 2 files changed, 76 insertions(+)
 create mode 100644 packages/google-cloud-translate/samples/README.md
 create mode 100644 packages/google-cloud-translate/samples/package.json

diff --git a/packages/google-cloud-translate/samples/README.md b/packages/google-cloud-translate/samples/README.md
new file mode 100644
index 00000000000..173ff49046b
--- /dev/null
+++ b/packages/google-cloud-translate/samples/README.md
@@ -0,0 +1,57 @@
+<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>
+
+# Google Translate API Node.js Samples
+
+With the [Google Translate API][translate_docs], you can dynamically translate
+text between thousands of language pairs.
+
+[translate_docs]: https://cloud.google.com/translate/docs/
+
+## Table of Contents
+
+* [Setup](#setup)
+* [Samples](#samples)
+  * [Translate](#translate)
+
+## Setup
+
+1. Read [Prerequisites][prereq] and [How to run a sample][run] first.
+1. Install dependencies:
+
+        npm install
+
+[prereq]: ../README.md#prerequisities
+[run]: ../README.md#how-to-run-a-sample
+
+## Samples
+
+### Translate
+
+View the [documentation][translate_docs] or the [source code][translate_code].
+
+__Usage:__ `node translate --help`
+
+```
+Commands:
+  detect <text>     Detect the language of the provided text
+  list              List available translation languages.
+  translate <text>  Translate the provided text to the target language.
+
+Options:
+  --apiKey, -k  Your Translate API key. Defaults to the value of the TRANSLATE_API_KEY environment
+                variable.                                                                   [string]
+  --help        Show help                                                                  [boolean]
+
+Examples:
+  node translate detect -k your-key "Hello world!"    Detect the language of "Hello world!".
+  node translate list -k your-key                     List available translation languages.
+  node translate translate -k your-key --to ru "Good  Translate "Good morning!" to Russian,
+  morning!"                                           auto-detecting English.
+  node translate translate -k your-key --to ru        Translate "Good morning!" to Russian from
+  --from en "Good morning!"                           English.
+
+For more information, see https://cloud.google.com/translate/docs
+```
+
+[translate_docs]: https://cloud.google.com/translate/docs
+[translate_code]: translate.js
diff --git a/packages/google-cloud-translate/samples/package.json b/packages/google-cloud-translate/samples/package.json
new file mode 100644
index 00000000000..79251cdc1e7
--- /dev/null
+++ b/packages/google-cloud-translate/samples/package.json
@@ -0,0 +1,19 @@
+{
+  "name": "nodejs-docs-samples-translate",
+  "version": "0.0.1",
+  "private": true,
+  "license": "Apache Version 2.0",
+  "author": "Google Inc.",
+  "scripts": {
+    "test": "mocha -R spec -t 120000 --require intelli-espower-loader ../test/_setup.js test/*.test.js",
+    "system-test": "mocha -R spec -t 120000 --require intelli-espower-loader ../system-test/_setup.js system-test/*.test.js"
+  },
+  "dependencies": {
+    "@google-cloud/translate": "^0.1.1",
+    "iso-639-1": "^1.2.1",
+    "yargs": "^5.0.0"
+  },
+  "devDependencies": {
+    "mocha": "^3.0.2"
+  }
+}