Change bergamotTranslator to dynamic import

This commit is contained in:
kwaroran
2025-03-17 16:08:11 +09:00
parent 30dce07c70
commit eea99c6ea2

View File

@@ -10,7 +10,6 @@ import { selectedCharID } from "../stores.svelte"
import { getModuleRegexScripts } from "../process/modules"
import { getNodetextToSentence, sleep } from "../util"
import { processScriptFull } from "../process/scripts"
import { bergamotTranslate } from "./bergamotTranslator"
import localforage from "localforage"
import sendSound from '../../etc/send.mp3'
@@ -19,6 +18,8 @@ let cache={
trans: ['']
}
let bergamotTranslate: (text: string, from: string, to: string, html?: boolean) => Promise<string>|null = null
export const LLMCacheStorage = localforage.createInstance({
name: "LLMTranslateCache"
})
@@ -167,6 +168,11 @@ async function translateMain(text:string, arg:{from:string, to:string, host:stri
return f.data.data;
}
if(db.translatorType == "bergamot") {
if(!bergamotTranslate){
const bergamotTranslator = await import('./bergamotTranslator')
bergamotTranslate = bergamotTranslator.bergamotTranslate
}
return bergamotTranslate(text, arg.from, arg.to, false);
}
if(db.useExperimentalGoogleTranslator){