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
class Translator { | |
private APIKEY: string = null; | |
private GOOGLEBASEURL: string = 'https://www.googleapis.com/language/translate/v2'; | |
constructor(APIKEY: string) { | |
this.APIKEY = APIKEY; | |
} | |
private async __request(params: any) { | |
const googleTranslateServerResult = await fetch(`${this.GOOGLEBASEURL}?key=${this.APIKEY}&source=${params.from}&target=${params.to}&q=${params.q}`); | |
return await googleTranslateServerResult.json(); |