Skip to content

Commit

Permalink
docs: update samples in the readme (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith authored Nov 8, 2019
1 parent 184c8bb commit e7e8d00
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
1 change: 0 additions & 1 deletion packages/google-cloud-translate/.nycrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"**/docs",
"**/samples",
"**/scripts",
"**/src/**/v*/**/*.js",
"**/protos",
"**/test",
".jsdoc.js",
Expand Down
27 changes: 18 additions & 9 deletions packages/google-cloud-translate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,31 @@ npm install @google-cloud/translate
### Using the client library

```javascript
/**
* TODO(developer): Uncomment the following line before running the sample.
*/
// const projectId = 'YOUR_PROJECT_ID';

// Imports the Google Cloud client library
const {Translate} = require('@google-cloud/translate');
const {Translate} = require('@google-cloud/translate').v2;

// Instantiates a client
const translate = new Translate({projectId});

// The text to translate
const text = 'Hello, world!';
async function quickStart() {
// The text to translate
const text = 'Hello, world!';

// The target language
const target = 'ru';

// The target language
const target = 'ru';
// Translates some text into Russian
const [translation] = await translate.translate(text, target);
console.log(`Text: ${text}`);
console.log(`Translation: ${translation}`);
}

// Translates some text into Russian
const [translation] = await translate.translate(text, target);
console.log(`Text: ${text}`);
console.log(`Translation: ${translation}`);
quickStart();

```

Expand Down

0 comments on commit e7e8d00

Please sign in to comment.