diff --git a/smart-chats/smart_thread.js b/smart-chats/smart_thread.js index 6b4238ea..0fb7708b 100644 --- a/smart-chats/smart_thread.js +++ b/smart-chats/smart_thread.js @@ -118,7 +118,8 @@ export class SmartThread extends SmartSource { }], context: {}, }; - const language = this.env.settings?.language || 'en'; + // const language = this.env.settings?.language || 'en'; + const language = this.settings.language; // INLINE PROCESSING // Handle internal embedded links (![[link]]) diff --git a/smart-chats/smart_threads.js b/smart-chats/smart_threads.js index 79b19cee..af8fd652 100644 --- a/smart-chats/smart_threads.js +++ b/smart-chats/smart_threads.js @@ -1,6 +1,6 @@ import { SmartSources } from "smart-sources"; import { render as chat_template } from "./components/threads.js"; - +import { get_language_options } from "./utils/self_referential_keywords.js"; /** * @class SmartThreads * @extends SmartSources @@ -118,6 +118,13 @@ export class SmartThreads extends SmartSources { */ get settings_config() { return { + "language": { + name: "Language", + type: "dropdown", + options_callback: 'get_language_options', + description: "The language to use for the chat.", + default: 'en' + }, "review_context": { name: "Review Context", type: "toggle", @@ -138,6 +145,9 @@ export class SmartThreads extends SmartSources { } }; } + get_language_options() { + return get_language_options(); + } /** * Gets the currently active thread based on the chat box data-thread-key diff --git a/smart-chats/utils/ScTranslations.json b/smart-chats/utils/ScTranslations.json index 6d066a2d..641c1d33 100644 --- a/smart-chats/utils/ScTranslations.json +++ b/smart-chats/utils/ScTranslations.json @@ -1,27 +1,68 @@ { "en": { + "name": "English", "pronouns": ["my", "I", "me", "mine", "our", "ours", "us", "we"], "prompt": "Based on your notes", "initial_message": "Hi, I'm ChatGPT with access to your notes via Smart Connections. Ask me a question about your notes and I'll try to answer it." }, "es": { + "name": "Español", "pronouns": ["mi", "yo", "mí", "tú", "mis"], "prompt": "Basándose en sus notas", "initial_message": "Hola, soy ChatGPT con acceso a tus apuntes a través de Smart Connections. Hazme una pregunta sobre tus apuntes e intentaré responderte." }, "fr": { + "name": "Français", "pronouns": ["me", "mon", "ma", "mes", "moi", "nous", "notre", "nos", "je", "j'", "m'"], "prompt": "D'après vos notes", "initial_message": "Bonjour, je suis ChatGPT et j'ai accès à vos notes via Smart Connections. Posez-moi une question sur vos notes et j'essaierai d'y répondre." }, "de": { + "name": "Deutsch", "pronouns": ["mein", "meine", "meinen", "meiner", "meines", "mir", "uns", "unser", "unseren", "unserer", "unseres"], "prompt": "Basierend auf Ihren Notizen", "initial_message": "Hallo, ich bin ChatGPT und habe über Smart Connections Zugang zu Ihren Notizen. Stellen Sie mir eine Frage zu Ihren Notizen und ich werde versuchen, sie zu beantworten." }, "it": { + "name": "Italiano", "pronouns": ["mio", "mia", "miei", "mie", "noi", "nostro", "nostri", "nostra", "nostre"], "prompt": "Sulla base degli appunti", "initial_message": "Ciao, sono ChatGPT e ho accesso ai tuoi appunti tramite Smart Connections. Fatemi una domanda sui vostri appunti e cercherò di rispondervi." + }, + "pt": { + "name": "Português", + "pronouns": ["meu", "eu", "mim", "minha", "nosso", "nosso", "nós", "nós"], + "prompt": "Com base em suas anotações", + "initial_message": "Olá, sou ChatGPT com acesso às suas notas via Smart Connections. Faça-me uma pergunta sobre suas anotações e tentarei respondê-la." + }, + "pt-br": { + "name": "Português (Brasil)", + "pronouns": ["eu", "me", "mim", "meu", "meus", "minha", "minhas", "nosso", "nossos", "nossa", "nossas", "nós", "nos", "a gente"], + "prompt": "Baseado no que li das suas notas", + "initial_message": "Olá, sou ChatGPT e posso acessar suas notas por meio do plugin Smart Connections. Pergunte-me algo sobre suas notas e tentarei responder." + }, + "ja": { + "name": "日本語", + "pronouns": ["私", "自分", "僕", "俺", "私達", "この"], + "prompt": "このノートに基づいて", + "initial_message": "こんにちは、スマートコネクションであなたのノートにアクセスできるChatGPTです。あなたのノートに関する質問を私に投げかけてください。" + }, + "zh": { + "name": "中文(简体)", + "pronouns": ["我", "我的", "我们", "我们的"], + "prompt": "根据你的笔记", + "initial_message": "你好,我是 ChatGPT,可以通过 Smart Connections 访问你的笔记。问我一个关于你笔记的问题,我会尽力回答。" + }, + "zh-TW": { + "name": "中文(繁体)", + "pronouns": ["我", "我的", "我們", "我們的"], + "prompt": "根據您的筆記", + "initial_message": "嗨,我是ChatGPT,可以透過Smart Connections來查看您的筆記喔。如果您有關於筆記的問題,隨時可以問我,我會盡力回答您。" + }, + "ru": { + "name": "Русский", + "pronouns": ["я", "моё", "мое", "мой", "мне", "моих", "мои", "моём", "моем", "наш", "наше", "нашем", "нашему", "нашим", "наши", "мы"], + "prompt": "На основе ваших записей", + "initial_message": "Привет, я ChatGPT, и у меня есть доступ к вашим записям с помощью Smart Connections. Задайте мне вопрос, и я попробую ответить на него." } } \ No newline at end of file diff --git a/smart-chats/utils/self_referential_keywords.js b/smart-chats/utils/self_referential_keywords.js index a00832d2..86f5d769 100644 --- a/smart-chats/utils/self_referential_keywords.js +++ b/smart-chats/utils/self_referential_keywords.js @@ -8,3 +8,7 @@ export function contains_self_referential_keywords(user_input, language) { if (check_str.match(new RegExp(`\\b(${language_settings.pronouns.join("|")})\\b`, "gi"))) return true; return false; } + +export function get_language_options(){ + return Object.entries(ScTranslations).map(([language, language_settings]) => ({ value: language, name: language_settings.name })); +} \ No newline at end of file