-
-
Save danzeeeman/48292fe10b92a7164720a073243f5dd1 to your computer and use it in GitHub Desktop.
Subscribe to the start of WW3
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
// 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