diff --git a/src/components/TranslatedMessage.svelte b/src/components/TranslatedMessage.svelte
index 193789af..a467ebf5 100644
--- a/src/components/TranslatedMessage.svelte
+++ b/src/components/TranslatedMessage.svelte
@@ -1,5 +1,5 @@
+
+
+
+
{#if $enabled}
diff --git a/src/ts/storage.ts b/src/ts/storage.ts
index 1578e43d..8941bae4 100644
--- a/src/ts/storage.ts
+++ b/src/ts/storage.ts
@@ -4,11 +4,14 @@ import type { Writable } from 'svelte/store';
import { getClient, AvailableLanguages } from 'iframe-translator';
import type { IframeTranslatorClient, AvailableLanguageCodes } from 'iframe-translator';
import { ChatReportUserOptions, Theme, YoutubeEmojiRenderMode } from './chat-constants';
+import { SugoiTranslatorOffline } from './sugoi-translator-offline';
export const stores = webExtStores();
export const hcEnabled = stores.addSyncStore('hc.enabled', true);
export const translateTargetLanguage = stores.addSyncStore('hc.translateTargetLanguage', '' as '' | AvailableLanguageCodes);
+export const sugoiTranslatorOfflineClient = readable(new SugoiTranslatorOffline());
+export const sugoiTranslatorOfflineEnabled = stores.addSyncStore('sugoiTranslatorOffline.enabled', false);
export const translatorClient = readable(null as (null | IframeTranslatorClient), (set) => {
let client: IframeTranslatorClient | null = null;
const destroyIf = (): void => {
diff --git a/src/ts/sugoi-translator-offline.ts b/src/ts/sugoi-translator-offline.ts
new file mode 100644
index 00000000..baaa65c8
--- /dev/null
+++ b/src/ts/sugoi-translator-offline.ts
@@ -0,0 +1,27 @@
+/**
+ * Only translates from JP to EN. For it to work, you need to install and run Sugoi Translator server on your local machine
+ */
+export class SugoiTranslatorOffline {
+ translate(text: string) : Promise {
+ const SugoiHost = '127.0.0.1'
+ const SugoiPort = 14366
+ const SugoiPath = ''
+
+ return fetch(`http://${SugoiHost}:${SugoiPort}/${SugoiPath}`, {
+ method: 'POST',
+ headers: {
+ 'content-type': 'application/json'
+ },
+ body: JSON.stringify({
+ message: 'translate sentences',
+ content: text
+ })
+ }).then(response => {
+ if (!response.ok) {
+ throw new Error(`Error: ${response.status}`);
+ }
+
+ return response.json() as Promise;
+ });
+ }
+}