diff --git a/src/core/i18n.js b/src/core/i18n.js index cb6a57d..5325cf9 100644 --- a/src/core/i18n.js +++ b/src/core/i18n.js @@ -41,14 +41,36 @@ class Internationalization { if (!rootElement) { return; } - const elements = rootElement.querySelectorAll('[data-i18n-key]'); - elements.forEach(element => { + + // 1. Translate textContent + const textElements = rootElement.querySelectorAll('[data-i18n-key]'); + textElements.forEach(element => { const key = element.dataset.i18nKey; const translation = this.getTranslation(key); if (translation) { element.textContent = translation; } }); + + // 2. Translate title attribute + const titleElements = rootElement.querySelectorAll('[data-i18n-title]'); + titleElements.forEach(element => { + const key = element.dataset.i18nTitle; + const translation = this.getTranslation(key); + if (translation) { + element.setAttribute('title', translation); + } + }); + + // 3. Translate aria-label attribute + const ariaLabelElements = rootElement.querySelectorAll('[data-i18n-aria-label]'); + ariaLabelElements.forEach(element => { + const key = element.dataset.i18nAriaLabel; + const translation = this.getTranslation(key); + if (translation) { + element.setAttribute('aria-label', translation); + } + }); } getTranslation(key) { diff --git a/src/i18n/en.json b/src/i18n/en.json index d315746..6b47e8d 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -2,5 +2,62 @@ "settings.language.label": "Language", "settings.language.option.en": "English", "settings.language.option.zh-tw": "繁體中文", - "template.settingsTitle": "RPG Companion Settings" -} + "template.settingsTitle": "RPG Companion Settings", + "template.settingsModal.themeTitle": "Theme", + "template.settingsModal.themeLabel": "Visual Theme:", + "template.settingsModal.themeOptions.default": "Default", + "template.settingsModal.themeOptions.sciFi": "Sci-Fi (Synthwave)", + "template.settingsModal.themeOptions.fantasy": "Fantasy (Rustic Parchment)", + "template.settingsModal.themeOptions.cyberpunk": "Cyberpunk (Neon Grid)", + "template.settingsModal.themeOptions.custom": "Custom", + "template.settingsModal.themeOptions.custom.background": "Background:", + "template.settingsModal.themeOptions.custom.accent": "Accent:", + "template.settingsModal.themeOptions.custom.text": "Text:", + "template.settingsModal.themeOptions.custom.highlight": "Highlight:", + "template.settingsModal.theme.statBarLow": "Stat Bar Color (Low):", + "template.settingsModal.theme.statBarLowNote": "Color when stats are at 0%", + "template.settingsModal.theme.statBarHigh": "Stat Bar Color (High):", + "template.settingsModal.theme.statBarHighNote": "Color when stats are at 100%", + "template.settingsModal.displayTitle": "Display Options", + "template.settingsModal.displayNote": "Use the Extensions tab to enable/disable the RPG Companion extension.", + "template.settingsModal.display.panelPosition": "Panel Position:", + "template.settingsModal.display.panelPositionOptions.right": "Right Sidebar", + "template.settingsModal.display.panelPositionOptions.left": "Left Sidebar", + "template.settingsModal.display.toggleAutoUpdate": "Auto-update after messages", + "template.settingsModal.display.showUserStats": "Show User Stats", + "template.settingsModal.display.showInfoBox": "Show Info Box", + "template.settingsModal.display.showPresentCharacters": "Show Present Characters", + "template.settingsModal.display.showInventory": "Show Inventory", + "template.settingsModal.display.showThoughtsInChat": "Show Thoughts in Chat", + "template.settingsModal.display.showThoughtsInChatNote": "Display character thoughts as overlay bubbles next to their messages", + "template.settingsModal.display.alwaysShowThoughtBubble": "Always Show Thought Bubble", + "template.settingsModal.display.alwaysShowThoughtBubbleNote": "Auto-expand thought bubble without clicking the icon first", + "template.settingsModal.display.enableAnimations": "Enable Animations", + "template.settingsModal.display.enableAnimationsNote": "Smooth transitions for stats, content updates, and dice rolls", + "template.settingsModal.display.showPlotProgressionButtons": "Show Plot Progression Buttons", + "template.settingsModal.display.showPlotProgressionButtonsNote": "Display buttons above chat input for plot progression prompts", + "template.settingsModal.display.enableDebugMode": "Enable Debug Mode", + "template.settingsModal.display.enableDebugModeNote": "Shows parser logs in a mobile-friendly UI panel. Useful for troubleshooting. Look for the red bug button.", + "template.settingsModal.advancedTitle": "Advanced", + "template.settingsModal.advanced.generationMode": "Generation Mode:", + "template.settingsModal.advanced.generationModeOptions.together": "Together with Main Generation", + "template.settingsModal.advanced.generationModeOptions.separate": "Separate Generation", + "template.settingsModal.advanced.generationModeNote": "Together: Adds RPG tracking to main roleplay. Separate: Generates RPG data separately (manual or auto).", + "template.settingsModal.advanced.contextMessages": "Context Messages:", + "template.settingsModal.advanced.contextMessagesNote": "Number of recent messages to include (Separate mode only)", + "template.settingsModal.advanced.memoryBatchSize": "Memory Batch Size:", + "template.settingsModal.advanced.memoryBatchSizeNote": "Number of messages to process per batch in Memory Recollection", + "template.settingsModal.advanced.useSeparatePreset": "Use model connected to RPG Companion Trackers preset", + "template.settingsModal.advanced.useSeparatePresetNote": "Separate mode only. When enabled, tracker generation will use the model from the \"RPG Companion Trackers\" preset instead of your main API model. The preset will be switched automatically during generation and restored afterward. Select the desired model in that preset and make sure the \"Bind presets to API connections\" toggle is on (next to the import/export preset buttons).", + "template.settingsModal.advanced.skipInjections": "Skip Injections during Guided Generations:", + "template.settingsModal.advanced.skipInjectionsOptions.none": "Never skip", + "template.settingsModal.advanced.skipInjectionsOptions.impersonation": "Only on impersonation requests", + "template.settingsModal.advanced.skipInjectionsOptions.guided": "Always for guided or quiet prompts", + "template.settingsModal.advanced.skipInjectionsNote": "When set, the extension will not inject tracker prompts, examples, or HTML instructions according to the selected mode when a guided generation (via `instruct` or `quiet_prompt`) is detected. Useful when using GuidedGenerations or similar extensions.", + "template.settingsModal.advanced.customHtmlPromptTitle": "Custom HTML Prompt:", + "template.settingsModal.advanced.restoreDefaultHtmlPrompt": "Restore Default", + "template.settingsModal.advanced.customHtmlPromptNote": "Customize the HTML prompt injected when \"Enable Immersive HTML\" is enabled. The default prompt is shown above - you can edit it directly or replace it entirely. Click \"Restore Default\" to reset. This affects all generation modes (together, separate, and plot progression).", + "template.settingsModal.advanced.clearCache": "Clear Extension Cache", + "template.settingsModal.advanced.resetFabPositions": "Reset Button Positions", + "template.settingsModal.advanced.resetFabPositionsNote": "Resets all floating action buttons (toggle, refresh, debug) to default top-left positions. Useful if buttons are off-screen." +} \ No newline at end of file diff --git a/src/i18n/zh-tw.json b/src/i18n/zh-tw.json index 82cbe19..c300d1b 100644 --- a/src/i18n/zh-tw.json +++ b/src/i18n/zh-tw.json @@ -2,5 +2,62 @@ "settings.language.label": "語言", "settings.language.option.en": "English", "settings.language.option.zh-tw": "繁體中文", - "template.settingsTitle": "RPG Companion 設定" + "template.settingsTitle": "RPG Companion 設定", + "template.settingsModal.themeTitle": "主題", + "template.settingsModal.themeLabel": "可選主題:", + "template.settingsModal.themeOptions.default": "預設", + "template.settingsModal.themeOptions.sciFi": "科幻 (合成波)", + "template.settingsModal.themeOptions.fantasy": "奇幻 (古樸羊皮紙)", + "template.settingsModal.themeOptions.cyberpunk": "賽博朋克 (霓虹網格)", + "template.settingsModal.themeOptions.custom": "自訂", + "template.settingsModal.themeOptions.custom.background": "背景:", + "template.settingsModal.themeOptions.custom.accent": "強調色:", + "template.settingsModal.themeOptions.custom.text": "文字:", + "template.settingsModal.themeOptions.custom.highlight": "高亮:", + "template.settingsModal.theme.statBarLow": "屬性條顏色 (低):", + "template.settingsModal.theme.statBarLowNote": "屬性在 0% 時的顏色", + "template.settingsModal.theme.statBarHigh": "屬性條顏色 (高):", + "template.settingsModal.theme.statBarHighNote": "屬性在 100% 時的顏色", + "template.settingsModal.displayTitle": "顯示設定", + "template.settingsModal.displayNote": "使用擴充功能標籤來啟用/停用 RPG Companion 擴充功能。", + "template.settingsModal.display.panelPosition": "面板位置:", + "template.settingsModal.display.panelPositionOptions.right": "右側邊欄", + "template.settingsModal.display.panelPositionOptions.left": "左側邊欄", + "template.settingsModal.display.toggleAutoUpdate": "訊息後自動更新", + "template.settingsModal.display.showUserStats": "顯示 user 屬性", + "template.settingsModal.display.showInfoBox": "顯示資訊框", + "template.settingsModal.display.showPresentCharacters": "顯示在場角色", + "template.settingsModal.display.showInventory": "顯示物品欄", + "template.settingsModal.display.showThoughtsInChat": "在聊天中顯示想法", + "template.settingsModal.display.showThoughtsInChatNote": "將角色想法顯示為其訊息旁的泡泡", + "template.settingsModal.display.alwaysShowThoughtBubble": "始終顯示想法泡泡", + "template.settingsModal.display.alwaysShowThoughtBubbleNote": "自動展開想法泡泡", + "template.settingsModal.display.enableAnimations": "啟用動畫", + "template.settingsModal.display.enableAnimationsNote": "屬性、內容更新和擲骰的動畫效果", + "template.settingsModal.display.showPlotProgressionButtons": "顯示劇情推進按鈕(QR)", + "template.settingsModal.display.showPlotProgressionButtonsNote": "在聊天輸入框上方顯示劇情推進提示按鈕(QR)", + "template.settingsModal.display.enableDebugMode": "Debug Mode", + "template.settingsModal.display.enableDebugModeNote": "UI 面板中顯示日誌,對於故障排除很有用。", + "template.settingsModal.advancedTitle": "進階", + "template.settingsModal.advanced.generationMode": "生成模式:", + "template.settingsModal.advanced.generationModeOptions.together": "同時生成", + "template.settingsModal.advanced.generationModeOptions.separate": "單獨生成", + "template.settingsModal.advanced.generationModeNote": "同時生成:將 RPG 追蹤添加到主要提示詞中一同生成。單獨生成:分開生成 RPG 數據。(就是手動或自動的差別)。", + "template.settingsModal.advanced.contextMessages": "上下文訊息:", + "template.settingsModal.advanced.contextMessagesNote": "包含的最近訊息數量(僅限單獨生成模式)", + "template.settingsModal.advanced.memoryBatchSize": "記憶批次大小:", + "template.settingsModal.advanced.memoryBatchSizeNote": "在記憶回憶中每批處理的訊息數量", + "template.settingsModal.advanced.useSeparatePreset": "使用 RPG Companion 追蹤預設模型(設置次要模型)", + "template.settingsModal.advanced.useSeparatePresetNote": "僅限單獨生成模式。啟用後將使用“RPG Companion Trackers”預設中綁定的模型,而不是您的主要 API 模型。生成期間會自動切換預設,之後會恢復原使用預設。請在“RPG Companion Trackers”預設中選擇次要模型,並確保“將預設綁定到 API 連接”切換已開啟(在導入/導出預設按鈕旁邊)。", + "template.settingsModal.advanced.skipInjections": "在引導生成期間跳過注入:", + "template.settingsModal.advanced.skipInjectionsOptions.none": "從不跳過", + "template.settingsModal.advanced.skipInjectionsOptions.impersonation": "僅在模擬請求時跳過", + "template.settingsModal.advanced.skipInjectionsOptions.guided": "始終跳過引導", + "template.settingsModal.advanced.skipInjectionsNote": "當設置後,擴充功能在檢測到引導生成(通過 `instruct` 或 `quiet_prompt`)時,將根據所選模式不注入追蹤提示詞、範例或 HTML 指令。當與 GuidedGenerations 或類似擴充功能一起使用時非常有用。", + "template.settingsModal.advanced.customHtmlPromptTitle": "自訂 HTML 提示詞:", + "template.settingsModal.advanced.restoreDefaultHtmlPrompt": "恢復預設", + "template.settingsModal.advanced.customHtmlPromptNote": "自訂啟用“啟用沉浸式 HTML”時注入的 HTML 提示詞。上方顯示預設提示詞 - 您可以直接編輯或完全替換它。點擊“恢復預設”以重置。這會影響所有生成模式(同時、單獨和劇情推進)。", + "template.settingsModal.advanced.clearCache": "清除擴充功能快取", + "template.settingsModal.advanced.resetFabPositions": "重置按鈕位置", + "template.settingsModal.advanced.resetFabPositionsNote": "將所有浮動操作按鈕(切換、刷新、調試)重置為預設的左上位置。如果按鈕在螢幕外,這會很有用。" } diff --git a/template.html b/template.html index 50c9d3a..bfe3a9c 100644 --- a/template.html +++ b/template.html @@ -98,178 +98,178 @@
-

Theme

+

Theme

- +
- + - Color when stats are at 0% + Color when stats are at 0%
- + - Color when stats are at 100% + Color when stats are at 100%
-

Display Options

- +

Display Options

+ Use the Extensions tab to enable/disable the RPG Companion extension.
- +
- + Display character thoughts as overlay bubbles next to their messages - + Auto-expand thought bubble without clicking the icon first - + Smooth transitions for stats, content updates, and dice rolls - + Display buttons above chat input for plot progression prompts - + Shows parser logs in a mobile-friendly UI panel. Useful for troubleshooting. Look for the red bug button.
-

Advanced

+

Advanced

- + - Together: Adds RPG tracking to main roleplay. Separate: Generates RPG data separately (manual or auto). + Together: Adds RPG tracking to main roleplay. Separate: Generates RPG data separately (manual or auto).
- + - Number of recent messages to include (Separate mode only) + Number of recent messages to include (Separate mode only)
- + - Number of messages to process per batch in Memory Recollection + Number of messages to process per batch in Memory Recollection
- + Separate mode only. When enabled, tracker generation will use the model from the "RPG Companion Trackers" preset instead of your main API model. The preset will be switched automatically during generation and restored afterward. Select the desired model in that preset and make sure the "Bind presets to API connections" toggle is on (next to the import/export preset buttons).
- +
- + When set, the extension will not inject tracker prompts, examples, or HTML instructions according to the selected mode when a guided generation (via `instruct` or `quiet_prompt`) is detected. Useful when using GuidedGenerations or similar extensions.
-
@@ -292,16 +292,16 @@
- + Resets all floating action buttons (toggle, refresh, debug) to default top-left positions. Useful if buttons are off-screen.