fix: resolve hardcoded text in modals and auto-refresh issues
- Fix TTS modal hardcoded 'Speed:' and 'Play Text' buttons - Fix translation modal hardcoded tab text - Fix system prompt to respect user's selected language - Fix DOM auto-refresh by connecting both refresh functions - Add TTS and system prompt translation keys to 10 languages - Translation modal tabs and TTS controls now localize properly - Language switching works without hard refresh for data-i18n elements
This commit is contained in:
parent
65504b2d19
commit
64b91d69de
11 changed files with 240 additions and 0 deletions
90
src/languages/add-missing-keys.js
Normal file
90
src/languages/add-missing-keys.js
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Script to add missing translation keys to all language files
|
||||
*/
|
||||
|
||||
import { readFileSync, writeFileSync } from 'fs';
|
||||
import { translateText } from '../translation.js';
|
||||
|
||||
const newKeys = {
|
||||
translatePageTab: "📄 Translate Page",
|
||||
customTextTab: "✏️ Custom Text",
|
||||
systemPromptIntro: "You are Hermes AI, powered by Nous Research, embedded on a webpage. Your task is to generate a warm, welcoming 3-paragraph introduction that shows you understand the specific page the user is viewing.",
|
||||
systemPromptTask1: "1. Introduces yourself as Hermes AI and acknowledges the specific page/content",
|
||||
systemPromptTask2: "2. Mentions 2-3 specific, relevant details you notice from the page content",
|
||||
systemPromptTask3: "3. Offers to help with questions related to the page content",
|
||||
systemPromptInstructions: "Keep it conversational, helpful, and specific to what you see on this page. Write in"
|
||||
};
|
||||
|
||||
const languages = [
|
||||
{ code: 'zh', name: 'Chinese (Simplified)' },
|
||||
{ code: 'hi', name: 'Hindi' },
|
||||
{ code: 'es', name: 'Spanish' },
|
||||
{ code: 'fr', name: 'French' },
|
||||
{ code: 'ar', name: 'Arabic' },
|
||||
{ code: 'bn', name: 'Bengali' },
|
||||
{ code: 'ru', name: 'Russian' },
|
||||
{ code: 'pt', name: 'Portuguese' },
|
||||
{ code: 'ur', name: 'Urdu' },
|
||||
{ code: 'id', name: 'Indonesian' },
|
||||
{ code: 'ja', name: 'Japanese' },
|
||||
{ code: 'sw', name: 'Swahili' },
|
||||
{ code: 'mr', name: 'Marathi' },
|
||||
{ code: 'te', name: 'Telugu' },
|
||||
{ code: 'tr', name: 'Turkish' },
|
||||
{ code: 'zh-tw', name: 'Chinese Traditional' },
|
||||
{ code: 'ko', name: 'Korean' }
|
||||
];
|
||||
|
||||
async function addKeysToLanguage(langCode) {
|
||||
const filename = langCode === 'zh-tw' ? 'zh-tw.js' : `${langCode}.js`;
|
||||
const filePath = `./${filename}`;
|
||||
|
||||
try {
|
||||
let content = readFileSync(filePath, 'utf8');
|
||||
|
||||
// Find the insertion point (before "// More alerts and messages")
|
||||
const insertionPoint = content.indexOf(' // More alerts and messages');
|
||||
if (insertionPoint === -1) {
|
||||
console.log(`⚠️ Could not find insertion point in ${filename}`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Build the new keys section
|
||||
let newSection = '\n // Translation modal tabs\n';
|
||||
newSection += ` translatePageTab: "${await translateText(newKeys.translatePageTab, langCode)}",\n`;
|
||||
newSection += ` customTextTab: "${await translateText(newKeys.customTextTab, langCode)}",\n\n`;
|
||||
|
||||
newSection += ' // System prompt components\n';
|
||||
newSection += ` systemPromptIntro: "${await translateText(newKeys.systemPromptIntro, langCode)}",\n`;
|
||||
newSection += ` systemPromptTask1: "${await translateText(newKeys.systemPromptTask1, langCode)}",\n`;
|
||||
newSection += ` systemPromptTask2: "${await translateText(newKeys.systemPromptTask2, langCode)}",\n`;
|
||||
newSection += ` systemPromptTask3: "${await translateText(newKeys.systemPromptTask3, langCode)}",\n`;
|
||||
newSection += ` systemPromptInstructions: "${await translateText(newKeys.systemPromptInstructions, langCode)}",\n\n`;
|
||||
|
||||
// Insert the new section
|
||||
const newContent = content.slice(0, insertionPoint) + newSection + content.slice(insertionPoint);
|
||||
|
||||
writeFileSync(filePath, newContent, 'utf8');
|
||||
console.log(`✅ Updated ${filename}`);
|
||||
|
||||
} catch (error) {
|
||||
console.log(`❌ Error updating ${filename}: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
console.log('🔄 Adding missing translation keys to all language files...\n');
|
||||
|
||||
for (const lang of languages) {
|
||||
console.log(`Processing ${lang.name} (${lang.code})...`);
|
||||
await addKeysToLanguage(lang.code);
|
||||
// Small delay to avoid overwhelming the translation API
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
}
|
||||
|
||||
console.log('\n🎉 Finished adding keys to all languages!');
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
|
|
@ -66,6 +66,21 @@ export const de = {
|
|||
"Text zu Sprache: Schreiben Sie eine beliebige Nachricht und lassen Sie die künstliche Intelligenz sie sprechen!",
|
||||
translatePlaceholder: "Geben Sie beliebigen Text zum Übersetzen ein...",
|
||||
|
||||
// Translation modal tabs
|
||||
translatePageTab: "📄 Seite Übersetzen",
|
||||
customTextTab: "✏️ Eigener Text",
|
||||
|
||||
// TTS modal components
|
||||
speedLabel: "Geschwindigkeit:",
|
||||
playText: "Text Abspielen",
|
||||
|
||||
// System prompt components
|
||||
systemPromptIntro: "Sie sind Hermes AI, unterstützt von Nous Research, eingebettet auf einer Webseite. Ihre Aufgabe ist es, eine warme, einladende 3-Absatz-Einführung zu generieren, die zeigt, dass Sie die spezifische Seite verstehen, die der Benutzer betrachtet.",
|
||||
systemPromptTask1: "1. Stellen Sie sich als Hermes AI vor und erkennen Sie die spezifische Seite/den Inhalt an",
|
||||
systemPromptTask2: "2. Erwähnen Sie 2-3 spezifische, relevante Details, die Sie vom Seiteninhalt bemerken",
|
||||
systemPromptTask3: "3. Bieten Sie Hilfe bei Fragen zum Seiteninhalt an",
|
||||
systemPromptInstructions: "Halten Sie es gesprächig, hilfreich und spezifisch zu dem, was Sie auf dieser Seite sehen. Schreiben Sie auf",
|
||||
|
||||
// More alerts and messages
|
||||
pleaseEnterText: "Bitte geben Sie zuerst Text ein!",
|
||||
pleaseSelectFile: "Bitte wählen Sie zuerst eine Datei aus!",
|
||||
|
|
|
|||
|
|
@ -66,6 +66,21 @@ export const en = {
|
|||
"text-to-speech: write any message & have the artificial intelligence speak it!",
|
||||
translatePlaceholder: "Enter any text to translate...",
|
||||
|
||||
// Translation modal tabs
|
||||
translatePageTab: "📄 Translate Page",
|
||||
customTextTab: "✏️ Custom Text",
|
||||
|
||||
// TTS modal components
|
||||
speedLabel: "Speed:",
|
||||
playText: "Play Text",
|
||||
|
||||
// System prompt components
|
||||
systemPromptIntro: "You are Hermes AI, powered by Nous Research, embedded on a webpage. Your task is to generate a warm, welcoming 3-paragraph introduction that shows you understand the specific page the user is viewing.",
|
||||
systemPromptTask1: "1. Introduces yourself as Hermes AI and acknowledges the specific page/content",
|
||||
systemPromptTask2: "2. Mentions 2-3 specific, relevant details you notice from the page content",
|
||||
systemPromptTask3: "3. Offers to help with questions related to the page content",
|
||||
systemPromptInstructions: "Keep it conversational, helpful, and specific to what you see on this page. Write in",
|
||||
|
||||
// More alerts and messages
|
||||
pleaseEnterText: "Please enter some text first!",
|
||||
pleaseSelectFile: "Please select a file first!",
|
||||
|
|
|
|||
|
|
@ -66,6 +66,21 @@ export const es = {
|
|||
"texto a voz: ¡escribe cualquier mensaje y haz que la inteligencia artificial lo hable!",
|
||||
translatePlaceholder: "Ingresa cualquier texto para traducir...",
|
||||
|
||||
// Translation modal tabs
|
||||
translatePageTab: "📄 Traducir Página",
|
||||
customTextTab: "✏️ Texto Personalizado",
|
||||
|
||||
// TTS modal components
|
||||
speedLabel: "Velocidad:",
|
||||
playText: "Reproducir Texto",
|
||||
|
||||
// System prompt components
|
||||
systemPromptIntro: "Eres Hermes AI, impulsado por Nous Research, integrado en una página web. Tu tarea es generar una introducción cálida y acogedora de 3 párrafos que muestre que entiendes la página específica que el usuario está viendo.",
|
||||
systemPromptTask1: "1. Te presentas como Hermes AI y reconoces la página/contenido específico",
|
||||
systemPromptTask2: "2. Mencionas 2-3 detalles específicos y relevantes que notas del contenido de la página",
|
||||
systemPromptTask3: "3. Ofreces ayuda con preguntas relacionadas con el contenido de la página",
|
||||
systemPromptInstructions: "Manténlo conversacional, útil y específico a lo que ves en esta página. Escribe en",
|
||||
|
||||
// More alerts and messages
|
||||
pleaseEnterText: "¡Por favor ingresa algo de texto primero!",
|
||||
pleaseSelectFile: "¡Por favor selecciona un archivo primero!",
|
||||
|
|
|
|||
|
|
@ -66,6 +66,21 @@ export const fr = {
|
|||
"texte vers parole : écrivez n'importe quel message et faites-le parler par l'intelligence artificielle !",
|
||||
translatePlaceholder: "Entrez n'importe quel texte à traduire...",
|
||||
|
||||
// Translation modal tabs
|
||||
translatePageTab: "📄 Traduire la Page",
|
||||
customTextTab: "✏️ Texte Personnalisé",
|
||||
|
||||
// TTS modal components
|
||||
speedLabel: "Vitesse:",
|
||||
playText: "Lire le Texte",
|
||||
|
||||
// System prompt components
|
||||
systemPromptIntro: "Vous êtes Hermes AI, alimenté par Nous Research, intégré sur une page web. Votre tâche est de générer une introduction chaleureuse et accueillante de 3 paragraphes qui montre que vous comprenez la page spécifique que l'utilisateur consulte.",
|
||||
systemPromptTask1: "1. Vous vous présentez comme Hermes AI et reconnaissez la page/contenu spécifique",
|
||||
systemPromptTask2: "2. Vous mentionnez 2-3 détails spécifiques et pertinents que vous remarquez du contenu de la page",
|
||||
systemPromptTask3: "3. Vous offrez de l'aide avec des questions liées au contenu de la page",
|
||||
systemPromptInstructions: "Gardez-le conversationnel, utile et spécifique à ce que vous voyez sur cette page. Écrivez en",
|
||||
|
||||
// More alerts and messages
|
||||
pleaseEnterText: "Veuillez d'abord entrer du texte !",
|
||||
pleaseSelectFile: "Veuillez d'abord sélectionner un fichier !",
|
||||
|
|
|
|||
|
|
@ -65,6 +65,21 @@ export const hi = {
|
|||
ttsPlaceholder: "टेक्स्ट-टू-स्पीच: कोई भी संदेश लिखें और कृत्रिम बुद्धि इसे बोलने दें!",
|
||||
translatePlaceholder: "अनुवाद के लिए कोई भी टेक्स्ट दर्ज करें...",
|
||||
|
||||
// Translation modal tabs
|
||||
translatePageTab: "📄 पृष्ठ अनुवाद",
|
||||
customTextTab: "✏️ कस्टम टेक्स्ट",
|
||||
|
||||
// TTS modal components
|
||||
speedLabel: "गति:",
|
||||
playText: "टेक्स्ट चलाएं",
|
||||
|
||||
// System prompt components
|
||||
systemPromptIntro: "आप Hermes AI हैं, Nous Research द्वारा संचालित, एक वेबपेज में एम्बेडेड। आपका कार्य एक गर्म, स्वागत करने वाला 3-पैराग्राफ परिचय तैयार करना है जो दिखाता है कि आप उस विशिष्ट पृष्ठ को समझते हैं जिसे उपयोगकर्ता देख रहा है।",
|
||||
systemPromptTask1: "1. अपना परिचय Hermes AI के रूप में दें और विशिष्ट पृष्ठ/सामग्री को स्वीकार करें",
|
||||
systemPromptTask2: "2. पृष्ठ सामग्री से 2-3 विशिष्ट, प्रासंगिक विवरणों का उल्लेख करें जो आप देखते हैं",
|
||||
systemPromptTask3: "3. पृष्ठ सामग्री से संबंधित प्रश्नों में सहायता प्रदान करें",
|
||||
systemPromptInstructions: "इसे बातचीत के रूप में, सहायक और इस पृष्ठ पर आप जो देखते हैं उसके लिए विशिष्ट रखें। में लिखें",
|
||||
|
||||
// More alerts and messages
|
||||
pleaseEnterText: "कृपया पहले कुछ टेक्स्ट दर्ज करें!",
|
||||
pleaseSelectFile: "कृपया पहले एक फ़ाइल चुनें!",
|
||||
|
|
|
|||
|
|
@ -66,6 +66,21 @@ export const ja = {
|
|||
"テキスト読み上げ: 任意のメッセージを書いて、人工知能に話させましょう!",
|
||||
translatePlaceholder: "翻訳する任意のテキストを入力...",
|
||||
|
||||
// Translation modal tabs
|
||||
translatePageTab: "📄 ページを翻訳",
|
||||
customTextTab: "✏️ カスタムテキスト",
|
||||
|
||||
// TTS modal components
|
||||
speedLabel: "速度:",
|
||||
playText: "テキストを再生",
|
||||
|
||||
// System prompt components
|
||||
systemPromptIntro: "あなたはHermes AIです。Nous Researchによって提供され、ウェブページに組み込まれています。あなたの役割は、ユーザーが閲覧している特定のページを理解していることを示す、温かく歓迎的な3段落の紹介を生成することです。",
|
||||
systemPromptTask1: "1. Hermes AIとして自己紹介し、特定のページ/コンテンツを認識する",
|
||||
systemPromptTask2: "2. ページコンテンツから気づいた2-3つの具体的で関連性のある詳細を言及する",
|
||||
systemPromptTask3: "3. ページコンテンツに関連する質問のサポートを提供する",
|
||||
systemPromptInstructions: "会話的で役立ち、このページで見えるものに特化してください。以下の言語で書いてください",
|
||||
|
||||
// More alerts and messages
|
||||
pleaseEnterText: "まずテキストを入力してください!",
|
||||
pleaseSelectFile: "まずファイルを選択してください!",
|
||||
|
|
|
|||
|
|
@ -66,6 +66,21 @@ export const ko = {
|
|||
"텍스트 음성 변환: 아무 메시지나 작성하고 인공지능이 말하게 하세요!",
|
||||
translatePlaceholder: "번역할 텍스트를 입력하세요...",
|
||||
|
||||
// Translation modal tabs
|
||||
translatePageTab: "📄 페이지 번역",
|
||||
customTextTab: "✏️ 사용자 정의 텍스트",
|
||||
|
||||
// TTS modal components
|
||||
speedLabel: "속도:",
|
||||
playText: "텍스트 재생",
|
||||
|
||||
// System prompt components
|
||||
systemPromptIntro: "당신은 Nous Research에서 제공하는 Hermes AI로, 웹페이지에 임베드되어 있습니다. 당신의 임무는 사용자가 보고 있는 특정 페이지를 이해하고 있음을 보여주는 따뜻하고 환영하는 3단락 소개를 생성하는 것입니다.",
|
||||
systemPromptTask1: "1. Hermes AI로 자신을 소개하고 특정 페이지/콘텐츠를 인정합니다",
|
||||
systemPromptTask2: "2. 페이지 콘텐츠에서 주목한 2-3개의 구체적이고 관련성 있는 세부사항을 언급합니다",
|
||||
systemPromptTask3: "3. 페이지 콘텐츠와 관련된 질문에 대한 도움을 제공합니다",
|
||||
systemPromptInstructions: "대화적이고 도움이 되며 이 페이지에서 보는 것에 구체적으로 유지하세요. 다음 언어로 작성하세요",
|
||||
|
||||
// More alerts and messages
|
||||
pleaseEnterText: "먼저 텍스트를 입력하세요!",
|
||||
pleaseSelectFile: "먼저 파일을 선택하세요!",
|
||||
|
|
|
|||
|
|
@ -66,6 +66,21 @@ export const pt = {
|
|||
"texto para fala: escreva qualquer mensagem e faça a inteligência artificial falar isso!",
|
||||
translatePlaceholder: "Digite qualquer texto para traduzir...",
|
||||
|
||||
// Translation modal tabs
|
||||
translatePageTab: "📄 Traduzir Página",
|
||||
customTextTab: "✏️ Texto Personalizado",
|
||||
|
||||
// TTS modal components
|
||||
speedLabel: "Velocidade:",
|
||||
playText: "Reproduzir Texto",
|
||||
|
||||
// System prompt components
|
||||
systemPromptIntro: "Você é Hermes AI, alimentado por Nous Research, incorporado em uma página web. Sua tarefa é gerar uma introdução calorosa e acolhedora de 3 parágrafos que mostre que você entende a página específica que o usuário está visualizando.",
|
||||
systemPromptTask1: "1. Apresente-se como Hermes AI e reconheça a página/conteúdo específico",
|
||||
systemPromptTask2: "2. Mencione 2-3 detalhes específicos e relevantes que você nota do conteúdo da página",
|
||||
systemPromptTask3: "3. Ofereça ajuda com perguntas relacionadas ao conteúdo da página",
|
||||
systemPromptInstructions: "Mantenha conversacional, útil e específico para o que você vê nesta página. Escreva em",
|
||||
|
||||
// More alerts and messages
|
||||
pleaseEnterText: "Por favor, digite algum texto primeiro!",
|
||||
pleaseSelectFile: "Por favor, selecione um arquivo primeiro!",
|
||||
|
|
|
|||
|
|
@ -66,6 +66,21 @@ export const ru = {
|
|||
"текст в речь: напишите любое сообщение и заставьте искусственный интеллект говорить это!",
|
||||
translatePlaceholder: "Введите любой текст для перевода...",
|
||||
|
||||
// Translation modal tabs
|
||||
translatePageTab: "📄 Перевести Страницу",
|
||||
customTextTab: "✏️ Пользовательский Текст",
|
||||
|
||||
// TTS modal components
|
||||
speedLabel: "Скорость:",
|
||||
playText: "Воспроизвести Текст",
|
||||
|
||||
// System prompt components
|
||||
systemPromptIntro: "Вы - Hermes AI, работающий на основе Nous Research, встроенный в веб-страницу. Ваша задача - создать теплое, приветливое введение из 3 абзацев, которое показывает, что вы понимаете конкретную страницу, которую просматривает пользователь.",
|
||||
systemPromptTask1: "1. Представьтесь как Hermes AI и признайте конкретную страницу/контент",
|
||||
systemPromptTask2: "2. Упомяните 2-3 конкретных, релевантных детали, которые вы замечаете из содержимого страницы",
|
||||
systemPromptTask3: "3. Предложите помощь с вопросами, связанными с содержимым страницы",
|
||||
systemPromptInstructions: "Сделайте это разговорным, полезным и конкретным для того, что вы видите на этой странице. Пишите на",
|
||||
|
||||
// More alerts and messages
|
||||
pleaseEnterText: "Пожалуйста, сначала введите текст!",
|
||||
pleaseSelectFile: "Пожалуйста, сначала выберите файл!",
|
||||
|
|
|
|||
|
|
@ -64,6 +64,21 @@ export const zh = {
|
|||
ttsPlaceholder: "文本转语音:写任何消息,让人工智能朗读出来!",
|
||||
translatePlaceholder: "输入任何要翻译的文本...",
|
||||
|
||||
// Translation modal tabs
|
||||
translatePageTab: "📄 翻译页面",
|
||||
customTextTab: "✏️ 自定义文本",
|
||||
|
||||
// TTS modal components
|
||||
speedLabel: "速度:",
|
||||
playText: "播放文本",
|
||||
|
||||
// System prompt components
|
||||
systemPromptIntro: "您是Hermes AI,由Nous Research提供支持,嵌入在网页中。您的任务是生成一个温暖、欢迎的3段介绍,展示您理解用户正在查看的特定页面。",
|
||||
systemPromptTask1: "1. 介绍自己为Hermes AI并确认特定页面/内容",
|
||||
systemPromptTask2: "2. 提及您从页面内容中注意到的2-3个具体、相关的细节",
|
||||
systemPromptTask3: "3. 提供与页面内容相关的问题帮助",
|
||||
systemPromptInstructions: "保持对话性、有用性,并针对您在此页面上看到的内容。用",
|
||||
|
||||
// More alerts and messages
|
||||
pleaseEnterText: "请先输入一些文本!",
|
||||
pleaseSelectFile: "请先选择一个文件!",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue