Google Translate API v3 requires us to pass the "parent" parameter.
It's everywhere on their sample code, such as :
/** * TODO(developer): Uncomment these variables before running the sample. */ // const projectId = 'YOUR_PROJECT_ID'; // const location = 'global'; // const text = 'text to translate'; // Imports the Google Cloud Translation library const {TranslationServiceClient} = require('@google-cloud/translate'); // Instantiates a client const translationClient = new TranslationServiceClient(); async function translateText() { // Construct request const request = { parent: `projects/${projectId}/locations/${location}`, // <-- HERE contents: [text], mimeType: 'text/plain', // mime types: text/plain, text/html sourceLanguageCode: 'en', targetLanguageCode: 'sr-Latn', }; // Run request const [response] = await translationClient.translateText(request); for (const translation of response.translations) { console.log(`Translation: ${translation.translatedText}`); } } translateText(); But I can not find the information anywhere about what is this "parent" parameter, how to fill it, where do I get it. Can anyone help me?
https://stackoverflow.com/questions/67030462/what-is-the-parent-parameter-in-google-cloud-translate-advanced-v3 April 10, 2021 at 11:13AM
没有评论:
发表评论