![]() ![]() This time, however, we pass all messages through the Yandex Translate API, asking to translate to English if we get back a string different than the one we sent, it means the original language was not English, and we reply to the person with the translation (in this way the translation is linked to the original message). What are we doing here? First, we listen for messages from the chat, as we did before with ping/pong. We pass in the params object, and we listen for the promise to complete in the then() callback: const axios = require('axios') //. Using Axios (in Glitch, search for axios in the package.json “Add package”) we’ll perform a network request to the Yandex Translate API. In our case, we’ll just guess the origin language, and we’ll use en as this parameter value. Yandex.Translate dapat digunakan untuk menerjemahkan kata, teks, dan halaman web. For business Start typing or insert a link Report error Yandex. The lang in the query parameter can take the form - or just (in this case “from” will be guessed from the message). Yandex.Translate dictionary and online translation between English and over 90 other languages. The Yandex Translate API documentation ( ) tells us to build an API request in this way: ?key= &text= &lang= As this is just a private sample application, I won’t do it, but be aware of this. According to the Terms of Use for the Yandex.Translate service, the text “Powered by Yandex.Translate” must be shown above or below the translation result, with a clickable link to the page.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |