This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import TranslateModule from '@google-cloud/translate'; | |
import fs from 'fs'; | |
import csv from 'fast-csv'; | |
import path from 'path'; | |
// Initialize Google Translate API Client | |
const translate = new TranslateModule.v2.Translate(); | |
const screenshotDir = 'output/screenshots/'; | |
process.env['GOOGLE_APPLICATION_CREDENTIALS'] = 'credentials.json'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const path = require('path'); | |
const https = require('https'); | |
const API_KEY = 'XXXX'; | |
function translateText(text, targetLanguage) { | |
return new Promise((resolve, reject) => { | |
const url = `https://translation.googleapis.com/language/translate/v2?key=${API_KEY}&q=${encodeURIComponent( | |
text |