INNER CODE UNIT · JavaScript
translate
guobao2333/DeepLX-Serverless · src/translate.js:83
async function translate(text, sourceLang, targetLang, dlSession, tagHandling, printResult) {
try {
if (!text) {
throw new Error('No text to translate');
}
// 分割文本
const splitResult = await splitText(text, tagHandling === 'html' || tagHandling === 'xml', dlSession, printResult);
// console.warn(splitResult);
if (splitResult.code === 429) {
return {
code: splitResult.code,
message: splitResult.message
}
}
// 获取检测到的语言