Skip to content

Instantly share code, notes, and snippets.

@danzeeeman
Created February 21, 2022 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danzeeeman/48292fe10b92a7164720a073243f5dd1 to your computer and use it in GitHub Desktop.
Save danzeeeman/48292fe10b92a7164720a073243f5dd1 to your computer and use it in GitHub Desktop.
Subscribe to the start of WW3
// Creates a client
const translate = new Translate({projectId});
async function translateText(text, target) {
// Translates the text into the target language. "text" can be a string for
// translating a single piece of text, or an array of strings for translating
// multiple texts.
let [translations] = await translate.translate(text, target);
translations = Array.isArray(translations) ? translations : [translations];
console.log('Translations:');
translations.forEach((translation, i) => {
console.log(`${translation}`);
});
}
var location = '29.652601,45.753720,36.337648,54.381852'
var stream = client.stream('statuses/filter', {locations:location});
stream.on('data', function(event) {
console.log(event.user.screen_name+", "+event.text+", "+event.timestamp_ms)
translateText(event.text, 'en')
});
stream.on('error', function(error) {
console.log(error)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment