From 5d15d75b517e6bf5b219d3f0e4bb77dcec2c1ff7 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Mon, 3 Jun 2024 17:37:03 +0900 Subject: [PATCH] refactor: Update translator.ts to include LLM translation for Tauri and Capacitor platforms --- src/ts/translator/translator.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ts/translator/translator.ts b/src/ts/translator/translator.ts index 187ad48c..e66c8a81 100644 --- a/src/ts/translator/translator.ts +++ b/src/ts/translator/translator.ts @@ -1,7 +1,7 @@ import { get } from "svelte/store" import { translatorPlugin } from "../plugins/plugins" import { DataBase, type character, type customscript, type groupChat } from "../storage/database" -import { globalFetch } from "../storage/globalApi" +import { globalFetch, isTauri } from "../storage/globalApi" import { alertError } from "../alert" import { requestChatData } from "../process/request" import { doingChat } from "../process" @@ -10,6 +10,7 @@ import { selectedCharID } from "../stores" import { getModuleRegexScripts } from "../process/modules" import { getNodetextToSentence, sleep, applyMarkdownToNode } from "../util" import { processScriptFull } from "../process/scripts" +import { Capacitor } from "@capacitor/core" let cache={ origin: [''], @@ -238,7 +239,10 @@ export async function translateHTML(html: string, reverse:boolean, charArg:simpl return html } } - + if(db.translatorType === 'llm' && (isTauri || Capacitor.isNativePlatform())){ + const tr = db.translator || 'en' + return translateLLM(html, {to: tr}) + } const dom = new DOMParser().parseFromString(html, 'text/html'); console.log(html)