In this article, we will learn how to convert English words (Source Language) to other language (Target Language) using Google Translate API.
Let’s begin
sl – Source Language Code Like en, hi, ur etc.
tl – Target Language Code Like en, hi, ur etc.
{keys} – your word
Hindi – hi
Gujarati – gu
English – en
Marathi – mr
More Languages Code Here.
Google Translate API Using Jquery
Below code add in your jquery file and get word to your target language.
function SourceLanguageToTargetLanguage() { var sourceLanguage = "en"; var targetLanguage = "hi"; var word="Your Word"; var googleTranslateURL = "https://translate.googleapis.com/translate_a/single?client=gtx&sl=" + sourceLanguage + "&tl=" + targetLanguage + "&dt=t&q=" + word; var requestOptions = { method: 'GET', redirect: 'follow' }; fetch(googleTranslateURL) .then(res => res.json()) .then(res => { if (res && res[0] && res[0][0] && res[0][0][0]) { name = res[0][0][0]; } }); }
Output :
If you have any questions or issues about this article, please let me know.
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular
In this article, we have to show Create and Used PIPE in angular