Reputation: 6071
I'm currently trying to implement the Google Translate API in my nodejs app. After a some trial and error (and googling) I finally figured out how to properly instantiate a new Translate object by passing in an object with a projectId
and credentials
.
However, my figuring out how to do this was mostly luck. Where would I actually find the documentation from google about what should go in this constructor? The closest I've found is this documentation that shows that the constructor takes a TranslateConfig
but doesn't actually explain what the config is.
const GOOGLE_CREDENTIAL = JSON.parse(process.env.GOOGLE_APPLICATION_CREDENTIAL);
async function translateText() {
const translate = new Translate({projectId: GOOGLE_CREDENTIAL.project_id, credentials: GOOGLE_CREDENTIAL});
let myTranslate = await translate.translate('who are you', 'es');
console.log(myTranslate);
}
TLDR: Where do I find documentation that explains the valid arguments for this constructor?
Upvotes: 0
Views: 202
Reputation: 1638
You can use search input at the top of the page you've referenced to gain access to the specification of what TranslateConfig is:
https://cloud.google.com/nodejs/docs/reference/translate/latest/translate/v2.translateconfig?hl=en
You can see there that by itself it exposes only apiEndpoint
, autoRetry
, key
and maxRetries
properties, but inherits a bunch of properties of the GoogleAuthOptions
interface.
You can also check the the official Git repository - maybe it will be of more use to you:
https://github.com/googleapis/nodejs-translate
Upvotes: 1