Skip to content

Commit 84c2721

Browse files
JustinBeckwithAce Nassri
authored and
Ace Nassri
committed
doc: use new import syntax in samples (#100)
1 parent 18518d4 commit 84c2721

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

translate/quickstart.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
// [START translate_quickstart]
1919
// Imports the Google Cloud client library
20-
const Translate = require('@google-cloud/translate');
20+
const {Translate} = require('@google-cloud/translate');
2121

2222
// Your Google Cloud Platform project ID
2323
const projectId = 'YOUR_PROJECT_ID';

translate/system-test/quickstart.test.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const proxyquire = require(`proxyquire`).noPreserveCache();
1919
const sinon = require(`sinon`);
2020
const test = require(`ava`);
2121
const tools = require(`@google-cloud/nodejs-repo-tools`);
22-
const translate = proxyquire(`@google-cloud/translate`, {})();
22+
const {Translate} = proxyquire(`@google-cloud/translate`, {});
23+
const translate = new Translate();
2324

2425
test.before(tools.checkCredentials);
2526
test.before(tools.stubConsole);
@@ -58,6 +59,8 @@ test.cb(`should translate a string`, t => {
5859
};
5960

6061
proxyquire(`../quickstart`, {
61-
'@google-cloud/translate': sinon.stub().returns(translateMock),
62+
'@google-cloud/translate': {
63+
Translate: sinon.stub().returns(translateMock),
64+
},
6265
});
6366
});

translate/system-test/translate.test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
const path = require(`path`);
1919
const test = require(`ava`);
2020
const tools = require(`@google-cloud/nodejs-repo-tools`);
21-
const translate = require(`@google-cloud/translate`)();
21+
const {Translate} = require(`@google-cloud/translate`);
22+
const translate = new Translate();
2223

2324
const cwd = path.join(__dirname, `..`);
2425
const cmd = `node translate.js`;

translate/translate.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
function detectLanguage(text) {
1919
// [START translate_detect_language]
2020
// Imports the Google Cloud client library
21-
const Translate = require('@google-cloud/translate');
21+
const {Translate} = require('@google-cloud/translate');
2222

2323
// Creates a client
2424
const translate = new Translate();
@@ -51,7 +51,7 @@ function detectLanguage(text) {
5151
function listLanguages() {
5252
// [START translate_list_codes]
5353
// Imports the Google Cloud client library
54-
const Translate = require('@google-cloud/translate');
54+
const {Translate} = require('@google-cloud/translate');
5555

5656
// Creates a client
5757
const translate = new Translate();
@@ -74,7 +74,7 @@ function listLanguages() {
7474
function listLanguagesWithTarget(target) {
7575
// [START translate_list_language_names]
7676
// Imports the Google Cloud client library
77-
const Translate = require('@google-cloud/translate');
77+
const {Translate} = require('@google-cloud/translate');
7878

7979
// Creates a client
8080
const translate = new Translate();
@@ -102,7 +102,7 @@ function listLanguagesWithTarget(target) {
102102
function translateText(text, target) {
103103
// [START translate_translate_text]
104104
// Imports the Google Cloud client library
105-
const Translate = require('@google-cloud/translate');
105+
const {Translate} = require('@google-cloud/translate');
106106

107107
// Creates a client
108108
const translate = new Translate();
@@ -138,7 +138,7 @@ function translateText(text, target) {
138138
function translateTextWithModel(text, target, model) {
139139
// [START translate_text_with_model]
140140
// Imports the Google Cloud client library
141-
const Translate = require('@google-cloud/translate');
141+
const {Translate} = require('@google-cloud/translate');
142142

143143
// Creates a client
144144
const translate = new Translate();

0 commit comments

Comments
 (0)