# MT
This interface, from the plug-in 1.1.8 Start Support
Two-way Chinese-English translation, input a Chinese to English translation, or input a English to Chinese translation
# to initialize
Plugin version number in the document, only for example reference, the latest version of the plugin,Subject to this
{
"pages": [
"pages/index/index"
],
"plugins": {
"chatbot": {
"version": "1.2.23",
"provider": "wx8c631f7e9f2465e1"
}
},
"requiredBackgroundModes": [
"audio"
],
"sitemapLocation": "sitemap.json"
}
var plugin = requirePlugin("chatbot")
App({
onLaunch: function () {
plugin.init({
appid: "P5Ot9PHJDechCYqDFAW1AiK6OtG3Ja", //Mini Program sample account, for learning and reference only
openid: "", //User's openid required
success: () => {}, //Not required
fail: (error) => {}, //Not required
})
},
})
# Calling machine translation interface
- Chinese to English
const txt = " What's the weather like in Beijing? "
plugin.api.nlp("translate_cn2en, { q: txt }).then((nothing) => {
console.log("translate_cn2en result : ", nothing)
})
- English to Chinese
const txt = "what are you doing?"
plugin.api.nlp("translate_en2cn, { q: txt }).then((nothing) => {
console.log("translate_en2cn result : ", nothing)
})
# Request parameters
field | type | describe |
---|---|---|
q | string | Input Text, UTF-8 Encoding, with a maximum length of 1024 The word |
# Return Result Sample
- Chinese to English
{
"result": "What about the weather in Beijing?"
}
- English to Chinese
{
"result": "What are you doing?"
}