const translations = { ja: { inputQueryTitle: "入力クエリ", generateButtonText: "プロンプト生成", splitStrings: "分割送信", outputPromptTitle: "生成されたプロンプト", settingsTitle: "設定", apiKeyLabel: "APIキー", characterCountLabel: "文字数", languageSelectLabel: "言語", promptEnPlaceholder: "英語のプロンプトがここに表示されます", promptMyLanguagePlaceholder: "日本訳がここに表示されます", apiKeyPlaceholder: "APIキーを入力してください", characterCountPlaceholder: "生成するプロンプトの文字数を入力してください" }, en: { inputQueryTitle: "Input Query", generateButtonText: "Generate Prompt", splitStrings: "Split Strings", outputPromptTitle: "Generated Prompt", settingsTitle: "Settings", apiKeyLabel: "API Key", characterCountLabel: "Character Count", languageSelectLabel: "Language", promptEnPlaceholder: "English prompt will be displayed here", promptMyLanguagePlaceholder: "Translation will be displayed here", apiKeyPlaceholder: "Enter your API key", characterCountPlaceholder: "Enter the number of characters for the generated prompt" }, zh: { inputQueryTitle: "输入查询", generateButtonText: "生成提示", splitStrings: "分割字符串", outputPromptTitle: "生成的提示", settingsTitle: "设置", apiKeyLabel: "API密钥", characterCountLabel: "字符数", languageSelectLabel: "语言", promptEnPlaceholder: "英文提示将显示在这里", promptMyLanguagePlaceholder: "翻译将显示在这里", apiKeyPlaceholder: "请输入您的API密钥", characterCountPlaceholder: "请输入生成提示的字符数" }, ko: { inputQueryTitle: "입력 쿼리", generateButtonText: "프롬프트 생성", splitStrings: "문자열 분할", outputPromptTitle: "생성된 프롬프트", settingsTitle: "설정", apiKeyLabel: "API 키", characterCountLabel: "문자 수", languageSelectLabel: "언어", promptEnPlaceholder: "영어 프롬프트가 여기에 표시됩니다", promptMyLanguagePlaceholder: "번역이 여기에 표시됩니다", apiKeyPlaceholder: "API 키를 입력하세요", characterCountPlaceholder: "생성할 프롬프트의 문자 수를 입력하세요" }, fr: { inputQueryTitle: "Requête d'entrée", generateButtonText: "Générer le prompt", splitStrings: "Diviser les chaînes", outputPromptTitle: "Prompt généré", settingsTitle: "Paramètres", apiKeyLabel: "Clé API", characterCountLabel: "Nombre de caractères", languageSelectLabel: "Langue", promptEnPlaceholder: "Le prompt en anglais s'affichera ici", promptMyLanguagePlaceholder: "La traduction s'affichera ici", apiKeyPlaceholder: "Entrez votre clé API", characterCountPlaceholder: "Entrez le nombre de caractères pour le prompt généré" }, es: { inputQueryTitle: "Consulta de entrada", generateButtonText: "Generar prompt", splitStrings: "Dividir cadenas", outputPromptTitle: "Prompt generado", settingsTitle: "Configuración", apiKeyLabel: "Clave API", characterCountLabel: "Recuento de caracteres", languageSelectLabel: "Idioma", promptEnPlaceholder: "El prompt en inglés se mostrará aquí", promptMyLanguagePlaceholder: "La traducción se mostrará aquí", apiKeyPlaceholder: "Ingrese su clave API", characterCountPlaceholder: "Ingrese el número de caracteres para el prompt generado" }, de: { inputQueryTitle: "Eingabeabfrage", generateButtonText: "Prompt generieren", splitStrings: "Zeichenketten aufteilen", outputPromptTitle: "Generierter Prompt", settingsTitle: "Einstellungen", apiKeyLabel: "API-Schlüssel", characterCountLabel: "Zeichenanzahl", languageSelectLabel: "Sprache", promptEnPlaceholder: "Der englische Prompt wird hier angezeigt", promptMyLanguagePlaceholder: "Die Übersetzung wird hier angezeigt", apiKeyPlaceholder: "Geben Sie Ihren API-Schlüssel ein", characterCountPlaceholder: "Geben Sie die Anzahl der Zeichen für den generierten Prompt ein" }, it: { inputQueryTitle: "Query di input", generateButtonText: "Genera prompt", splitStrings: "Dividi stringhe", outputPromptTitle: "Prompt generato", settingsTitle: "Impostazioni", apiKeyLabel: "Chiave API", characterCountLabel: "Conteggio caratteri", languageSelectLabel: "Lingua", promptEnPlaceholder: "Il prompt in inglese verrà visualizzato qui", promptMyLanguagePlaceholder: "La traduzione verrà visualizzata qui", apiKeyPlaceholder: "Inserisci la tua chiave API", characterCountPlaceholder: "Inserisci il numero di caratteri per il prompt generato" } } const resources = { ja: { translation: translations.ja }, en: { translation: translations.en }, zh: { translation: translations.zh }, ko: { translation: translations.ko }, fr: { translation: translations.fr }, es: { translation: translations.es }, de: { translation: translations.de }, it: { translation: translations.it } } // 既存のスクリプトの前に追加 document.addEventListener('DOMContentLoaded', function () { i18next .use(i18nextBrowserLanguageDetector) .init({ fallbackLng: 'ja', // デフォルト言語 resources: resources }) .then(function (t) { document.getElementById('languageSelect').value = i18next.language; document.getElementById('languageSelect').dispatchEvent(new Event('change')); }); }); function updateContent() { // 各要素のテキストを更新 document.getElementById('inputQueryTitle').textContent = i18next.t('inputQueryTitle'); document.getElementById('generateButtonText').textContent = i18next.t('generateButtonText'); document.getElementById('splitStrings').textContent = i18next.t('splitStrings'); document.getElementById('outputPromptTitle').textContent = i18next.t('outputPromptTitle'); document.getElementById('settingsTitle').textContent = i18next.t('settingsTitle'); document.querySelector('#apiKeyLabel > a').textContent = i18next.t('apiKeyLabel'); document.getElementById('characterCountLabel').textContent = i18next.t('characterCountLabel'); document.getElementById('languageSelectLabel').textContent = i18next.t('languageSelectLabel'); // プレースホルダーを更新 document.getElementById('promptEn').placeholder = i18next.t('promptEnPlaceholder'); document.getElementById('promptMyLanguage').placeholder = i18next.t('promptMyLanguagePlaceholder'); document.getElementById('apiKey').placeholder = i18next.t('apiKeyPlaceholder'); document.getElementById('characterCount').placeholder = i18next.t('characterCountPlaceholder'); } // 言語切り替え関数 function changeLang(language) { i18next.changeLanguage(language, (err, t) => { if (err) return console.error('言語切り替えエラー', err); updateContent(); }); } document.getElementById('languageSelect').addEventListener('change', function () { changeLang(this.value); });