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