AI translation means that after selecting a text, you can translate its content. As shown in the figure below:
If we need to configure the default translation language, the configuration code is as follows:
new LinwitDocEditor({
element: "#aiEditor",
ai: {
translate: {
prompt: (lang, selectedText) => {
return `Please help me translate the following content into: ${lang}, and return the translation result. The content you need to translate is:\n${selectedText}`
},
translateMenuItems: [
{title: 'English', language:'English'},
{title: 'Chinese'},
],
}
},
})
lang passed to the prompt() method. When not configured, the value of title is used by default.