Skip to content

Commit 555e9aa

Browse files
jmdobryAce Nassri
authored and
Ace Nassri
committed
Change quickstart style. (#221)
* Change quickstart style. * Fix test.
1 parent ff88db1 commit 555e9aa

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

translate/quickstart.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,24 @@
1414
'use strict';
1515

1616
// [START translate_quickstart]
17-
// Imports and instantiates the Google Cloud client library
18-
const translate = require('@google-cloud/translate')({
19-
key: 'YOUR_API_KEY'
17+
// Imports the Google Cloud client library
18+
const Translate = require('@google-cloud/translate');
19+
20+
// Your Translate API key
21+
const apiKey = 'YOUR_API_KEY';
22+
23+
// Instantiates a client
24+
const translateClient = Translate({
25+
key: apiKey
2026
});
2127

28+
// The text to translate
29+
const text = 'Hello, world!';
30+
// The target language
31+
const target = 'ru';
32+
2233
// Translates some text into Russian
23-
translate.translate('Hello, world!', 'ru', (err, translation) => {
34+
translateClient.translate(text, target, (err, translation) => {
2435
if (!err) {
2536
// The text was translated successfully
2637
}

0 commit comments

Comments
 (0)