Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function translateText(
text,
sourceLanguageCode,
targetLanguageCode,
projectId,
glossaryName
) {
// Instantiates a client
const translationClient = new translate.TranslationServiceClient();
const glossary = translationClient.glossaryPath(
projectId,
'us-central1',
glossaryName
);
const glossaryConfig = {
glossary: glossary,
};
// Construct request
const request = {
parent: translationClient.locationPath(projectId, 'us-central1'),
contents: [text],
mimeType: 'text/plain', // mime types: text/plain, text/html
sourceLanguageCode: sourceLanguageCode,
targetLanguageCode: targetLanguageCode,
glossaryConfig: glossaryConfig,
async function createGlossary(
languages,
projectId,
glossaryName,
glossaryUri
) {
// Instantiates a client
const translationClient = await new translate.TranslationServiceClient();
// Construct glossary
const glossary = {
languageCodesSet: {
languageCodes: languages,
},
inputConfig: {
gcsSource: {
inputUri: glossaryUri,
},
},
name: translationClient.glossaryPath(
projectId,
'us-central1',
glossaryName
),