fix translateTranslationChunks function

This commit is contained in:
kwaroran
2024-03-25 21:21:59 +09:00
parent dc6d39b754
commit 52c176234f

View File

@@ -237,10 +237,13 @@ export async function translateHTML(html: string, reverse:boolean, charArg:simpl
async function translateTranslationChunks(force:boolean = false, additionalChunkLength = 0){
if(translationChunks.length === 0 || !needSuperChunkedTranslate()){
return
}
const currentChunk = translationChunks[translationChunks.length-1]
const text: string = currentChunk.chunks.join('\n■\n')
console.log(text)
if(!force && text.length + additionalChunkLength < 5000){
return
}
@@ -250,6 +253,10 @@ export async function translateHTML(html: string, reverse:boolean, charArg:simpl
resolvers: []
})
if(!text){
return
}
const translated = await translate(text, reverse)
const split = translated.split('■')