diff --git a/index.js b/index.js index 6d8b462..288a562 100644 --- a/index.js +++ b/index.js @@ -5,6 +5,7 @@ import { power_user } from '../../../power-user.js'; // Core modules import { extensionName, extensionFolderPath } from './src/core/config.js'; +import { i18n } from './src/core/i18n.js'; import { extensionSettings, lastGeneratedData, @@ -104,7 +105,8 @@ import { setupMobileTabs, removeMobileTabs, setupMobileKeyboardHandling, - setupContentEditableScrolling + setupContentEditableScrolling, + updateMobileTabLabels } from './src/systems/ui/mobile.js'; import { setupDesktopTabs, @@ -152,35 +154,30 @@ import { // (setupMobileToggle, constrainFabToViewport, setupMobileTabs, removeMobileTabs, // setupMobileKeyboardHandling, setupContentEditableScrolling) +/** + * Updates UI elements that are dynamically generated and not covered by data-i18n-key. + */ +function updateDynamicLabels() { + // Update "Refresh RPG Info" button, but only if it's not disabled + const refreshBtn = document.getElementById('rpg-manual-update'); + if (refreshBtn && !refreshBtn.disabled) { + const refreshText = i18n.getTranslation('template.mainPanel.refreshRpgInfo') || 'Refresh RPG Info'; + refreshBtn.innerHTML = ` ${refreshText}`; + } + + // Update "Last Roll" label + updateDiceDisplay(); + + // Update mobile tab labels + updateMobileTabLabels(); +} + /** * Adds the extension settings to the Extensions tab. */ -function addExtensionSettings() { - const settingsHtml = ` -
-
- RPG Companion -
-
-
- - Toggle to enable/disable the RPG Companion extension. Configure additional settings within the panel itself. - -
- - Discord - - - Support Creator - -
-
-
- `; - +async function addExtensionSettings() { + // Load the HTML template for the settings + const settingsHtml = await renderExtensionTemplateAsync(extensionName, 'settings'); $('#extensions_settings2').append(settingsHtml); // Set up the enable/disable toggle @@ -210,12 +207,27 @@ function addExtensionSettings() { // Update Memory Recollection button visibility updateMemoryRecollectionButton(); }); + + // Set up language selector + const langSelect = $('#rpg-companion-language-select'); + if (langSelect.length) { + langSelect.val(i18n.currentLanguage); + langSelect.on('change', async function() { + const selectedLanguage = $(this).val(); + await i18n.setLanguage(selectedLanguage); + // We need to re-apply translations to the settings panel specifically + i18n.applyTranslations(document.getElementById('extensions_settings2')); + }); + } } /** * Initializes the UI for the extension. */ async function initUI() { + // Initialize i18n + await i18n.init(); + // Only initialize UI if extension is enabled if (!extensionSettings.enabled) { console.log('[RPG Companion] Extension disabled - skipping UI initialization'); @@ -249,6 +261,9 @@ async function initUI() { setInventoryContainer($('#rpg-inventory')); setQuestsContainer($('#rpg-quests')); + // Re-apply translations to the entire body to catch all new elements from the template + i18n.applyTranslations(document.body); + // Set up event listeners (enable/disable is handled in Extensions tab) $('#rpg-toggle-auto-update').on('change', function() { extensionSettings.autoUpdate = $(this).prop('checked'); @@ -597,9 +612,15 @@ jQuery(async () => { console.error('[RPG Companion] Settings load failed, continuing with defaults:', error); } + // Initialize i18n early for the settings panel + await i18n.init(); + + // Set up a central listener for language changes to update dynamic UI parts + i18n.addEventListener('languageChanged', updateDynamicLabels); + // Add extension settings to Extensions tab try { - addExtensionSettings(); + await addExtensionSettings(); } catch (error) { console.error('[RPG Companion] Failed to add extension settings tab:', error); // Don't throw - extension can still work without settings tab diff --git a/settings.html b/settings.html index a6d40ea..98fb41b 100644 --- a/settings.html +++ b/settings.html @@ -7,9 +7,18 @@
- Toggle to enable/disable the RPG Companion extension. Configure additional settings within the panel itself. + +
+ + +
+ + Toggle to enable/disable the RPG Companion extension. Configure additional settings within the panel itself.
diff --git a/src/core/i18n.js b/src/core/i18n.js new file mode 100644 index 0000000..315b4e4 --- /dev/null +++ b/src/core/i18n.js @@ -0,0 +1,103 @@ +//- No-op in case this is running outside of SillyTavern +const { extension_settings } = typeof self.SillyTavern !== 'undefined' ? self.SillyTavern.getContext() : { extension_settings: {} }; + +class Internationalization { + constructor() { + this.currentLanguage = 'en'; + this.translations = {}; + this._listeners = {}; + } + + addEventListener(event, callback) { + if (!this._listeners[event]) { + this._listeners[event] = []; + } + this._listeners[event].push(callback); + } + + dispatchEvent(event, data) { + if (this._listeners[event]) { + this._listeners[event].forEach(callback => callback(data)); + } + } + + async init() { + const savedLanguage = localStorage.getItem('rpgCompanionLanguage') || 'en'; + this.currentLanguage = savedLanguage; + + await this.loadTranslations(this.currentLanguage); + this.applyTranslations(document.body); + + const langSelect = document.getElementById('rpg-companion-language-select'); + if (langSelect) { + langSelect.value = this.currentLanguage; + } + } + + async loadTranslations(lang) { + const fetchUrl = `/scripts/extensions/third-party/rpg-companion-sillytavern/src/i18n/${lang}.json`; + try { + const response = await fetch(fetchUrl); + if (!response.ok) { + console.error(`[RPG-Companion-i18n] Failed to load translation file for ${lang}. Status: ${response.status}`); + if (lang !== 'en') { + return this.loadTranslations('en'); + } + return; + } + this.translations = await response.json(); + } catch (error) { + console.error('[RPG-Companion-i18n] CRITICAL error loading translation file:', error); + } + } + + applyTranslations(rootElement) { + if (!rootElement) { + return; + } + + // 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) { + return this.translations[key] || null; + } + + async setLanguage(lang) { + this.currentLanguage = lang; + localStorage.setItem('rpgCompanionLanguage', lang); + await this.loadTranslations(lang); + this.applyTranslations(document.body); + this.dispatchEvent('languageChanged'); + } +} + +export const i18n = new Internationalization(); diff --git a/src/i18n/en.json b/src/i18n/en.json new file mode 100644 index 0000000..8e7f0fd --- /dev/null +++ b/src/i18n/en.json @@ -0,0 +1,165 @@ +{ + "settings.language.label": "Language", + "settings.language.option.en": "English", + "settings.language.option.zh-tw": "繁體中文", + "settings.extensionEnabled": "Enable RPG Companion", + "settings.note": "Toggle to enable/disable the RPG Companion extension. Configure additional settings within the panel itself.", + "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.", + "template.trackerEditorModal.title": "Edit Trackers", + "template.trackerEditorModal.tabs.userStats": "User Stats", + "template.trackerEditorModal.tabs.infoBox": "Info Box", + "template.trackerEditorModal.tabs.presentCharacters": "Present Characters", + "template.trackerEditorModal.buttons.reset": "Reset to Defaults", + "template.trackerEditorModal.buttons.cancel": "Cancel", + "template.trackerEditorModal.buttons.save": "Save & Apply", + "template.trackerEditorModal.userStatsTab.customStatsTitle": "Custom Stats", + "template.trackerEditorModal.userStatsTab.addCustomStatButton": "Add Custom Stat", + "template.trackerEditorModal.userStatsTab.rpgAttributesTitle": "RPG Attributes", + "template.trackerEditorModal.userStatsTab.enableRpgAttributes": "Enable RPG Attributes Section", + "template.trackerEditorModal.userStatsTab.alwaysIncludeAttributes": "Always Include Attributes in Prompt", + "template.trackerEditorModal.userStatsTab.alwaysIncludeAttributesNote": "If disabled, attributes are only sent when a dice roll is active.", + "template.trackerEditorModal.userStatsTab.addAttributeButton": "Add Attribute", + "template.trackerEditorModal.userStatsTab.statusSectionTitle": "Status Section", + "template.trackerEditorModal.userStatsTab.enableStatusSection": "Enable Status Section", + "template.trackerEditorModal.userStatsTab.showMoodEmoji": "Show Mood Emoji", + "template.trackerEditorModal.userStatsTab.statusFieldsLabel": "Status Fields (comma-separated):", + "template.trackerEditorModal.userStatsTab.skillsSectionTitle": "Skills Section", + "template.trackerEditorModal.userStatsTab.enableSkillsSection": "Enable Skills Section", + "template.trackerEditorModal.userStatsTab.skillsLabelLabel": "Skills Label:", + "template.trackerEditorModal.userStatsTab.skillsListLabel": "Skills List (comma-separated):", + "template.trackerEditorModal.infoBoxTab.widgetsTitle": "Widgets", + "template.trackerEditorModal.infoBoxTab.dateWidget": "Date", + "template.trackerEditorModal.infoBoxTab.weatherWidget": "Weather", + "template.trackerEditorModal.infoBoxTab.temperatureWidget": "Temperature", + "template.trackerEditorModal.infoBoxTab.timeWidget": "Time", + "template.trackerEditorModal.infoBoxTab.locationWidget": "Location", + "template.trackerEditorModal.infoBoxTab.recentEventsWidget": "Recent Events", + "template.trackerEditorModal.presentCharactersTab.relationshipStatusTitle": "Relationship Status Fields", + "template.trackerEditorModal.presentCharactersTab.relationshipStatusHint": "Define relationship types with corresponding emojis shown on character portraits", + "template.trackerEditorModal.presentCharactersTab.newRelationshipButton": "New Relationship", + "template.trackerEditorModal.presentCharactersTab.appearanceDemeanorTitle": "Appearance/Demeanor Fields", + "template.trackerEditorModal.presentCharactersTab.appearanceDemeanorHint": "Fields shown below character name, separated by |", + "template.trackerEditorModal.presentCharactersTab.addCustomFieldButton": "Add Custom Field", + "template.trackerEditorModal.presentCharactersTab.thoughtsConfigTitle": "Thoughts Configuration", + "template.trackerEditorModal.presentCharactersTab.enableCharacterThoughts": "Enable Character Thoughts", + "template.trackerEditorModal.presentCharactersTab.thoughtsLabelLabel": "Thoughts Label:", + "template.trackerEditorModal.presentCharactersTab.aiInstructionLabel": "AI Instruction:", + "template.trackerEditorModal.presentCharactersTab.characterStatsTitle": "Character Stats", + "template.trackerEditorModal.presentCharactersTab.trackCharacterStats": "Track Character Stats", + "template.trackerEditorModal.presentCharactersTab.characterStatsHint": "Create stats to track for each character (displayed as colored bars)", + "template.trackerEditorModal.presentCharactersTab.addCharacterStatButton": "Add Character Stat", + "template.mainPanel.title": "RPG Companion", + "template.mainPanel.lastRoll": "Last Roll:", + "template.mainPanel.clearLastRoll": "Clear last roll", + "template.mainPanel.enableImmersiveHtml": "Enable Immersive HTML", + "template.mainPanel.refreshRpgInfo": "Refresh RPG Info", + "template.mainPanel.updating": "Updating...", + "template.mainPanel.editTrackersButton": "Edit Trackers", + "template.mainPanel.settingsButton": "Settings", + "global.none": "None", + "global.add": "Add", + "global.cancel": "Cancel", + "global.listView": "List view", + "global.gridView": "Grid view", + "global.save": "Save", + "global.status":"Status", + "global.inventory":"Inventory", + "global.quests":"Quests", + "global.info":"Info", + "infobox.noData.title": "No data yet", + "infobox.noData.instruction": "Generate a new response in the roleplay or switch to \"Separate Generation\" in Settings to access and click the \"Refresh RPG Info\" button", + "infobox.recentEvents.title": "Recent Events", + "infobox.recentEvents.addEventPlaceholder": "Add event...", + "inventory.section.onPerson": "On Person", + "inventory.section.stored": "Stored", + "inventory.section.assets": "Assets", + "inventory.onPerson.empty": "No items carried", + "inventory.onPerson.title": "Items Currently Carried", + "inventory.onPerson.addItemButton": "Add Item", + "inventory.onPerson.addItemPlaceholder": "Enter item name...", + "inventory.stored.title": "Storage Locations", + "inventory.stored.addLocationButton": "Add Location", + "inventory.stored.addLocationPlaceholder": "Enter location name...", + "inventory.stored.saveButton": "Save", + "inventory.stored.empty": "No storage locations yet. Click \"Add Location\" to create one.", + "inventory.stored.noItems": "No items stored here", + "inventory.stored.addItemToLocationPlaceholder": "Enter item name...", + "inventory.stored.addItemButton": "Add Item", + "inventory.stored.confirmRemoveLocationMessage": "Remove \"${location}\"? This will delete all items stored there.", + "inventory.stored.confirmRemoveLocationConfirmButton": "Confirm", + "inventory.assets.empty": "No assets owned", + "inventory.assets.title": "Vehicles, Property & Major Possessions", + "inventory.assets.addAssetModalTitle": "Add Asset", + "inventory.assets.addAssetButton": "Add Asset", + "inventory.assets.addAssetPlaceholder": "Enter asset name...", + "inventory.assets.description": "Assets include vehicles (cars, motorcycles), property (homes, apartments), and major equipment (workshop tools, special items).", + "quests.section.main": "Main Quest", + "quests.section.optional": "Optional Quests", + "quests.main.title": "Main Quests", + "quests.main.addQuestButton": "Add Quest", + "quests.main.addQuestPlaceholder": "Enter main quest title...", + "quests.main.empty": "No active main quests", + "quests.main.hint": "The main quest represents your primary objective in the story.", + "quests.optional.title": "Optional Quests", + "quests.optional.addQuestButton": "Add Quest", + "quests.optional.addQuestPlaceholder": "Enter optional quest title...", + "quests.optional.empty": "No active optional quests", + "quests.optional.hint": "Optional quests are side objectives that complement your main story." +} \ No newline at end of file diff --git a/src/i18n/zh-tw.json b/src/i18n/zh-tw.json new file mode 100644 index 0000000..d197716 --- /dev/null +++ b/src/i18n/zh-tw.json @@ -0,0 +1,165 @@ +{ + "settings.language.label": "語言", + "settings.language.option.en": "English", + "settings.language.option.zh-tw": "繁體中文", + "settings.extensionEnabled": "啟用 RPG Companion", + "settings.note": "切換開關以啟用/停用 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": "將所有浮動操作按鈕(切換、刷新、調試)重置為預設的左上位置。如果按鈕在螢幕外,這會很有用。", + "template.trackerEditorModal.title": "追蹤器編輯", + "template.trackerEditorModal.tabs.userStats": "User 屬性", + "template.trackerEditorModal.tabs.infoBox": "資訊框", + "template.trackerEditorModal.tabs.presentCharacters": "在場角色", + "template.trackerEditorModal.buttons.reset": "重置為預設值", + "template.trackerEditorModal.buttons.cancel": "取消", + "template.trackerEditorModal.buttons.save": "保存並應用", + "template.trackerEditorModal.userStatsTab.customStatsTitle": "自訂屬性", + "template.trackerEditorModal.userStatsTab.addCustomStatButton": "添加自訂屬性", + "template.trackerEditorModal.userStatsTab.rpgAttributesTitle": "RPG 屬性", + "template.trackerEditorModal.userStatsTab.enableRpgAttributes": "啟用 RPG 屬性", + "template.trackerEditorModal.userStatsTab.alwaysIncludeAttributes": "始終發送屬性(prompt)", + "template.trackerEditorModal.userStatsTab.alwaysIncludeAttributesNote": "將 RPG 屬性始終包含在提示詞中,即使它們未顯示在面板上也一樣。", + "template.trackerEditorModal.userStatsTab.addAttributeButton": "添加屬性", + "template.trackerEditorModal.userStatsTab.statusSectionTitle": "狀態欄", + "template.trackerEditorModal.userStatsTab.enableStatusSection": "啟用狀態欄", + "template.trackerEditorModal.userStatsTab.showMoodEmoji": "顯示心情emoji", + "template.trackerEditorModal.userStatsTab.statusFieldsLabel": "狀態欄欄位(以逗號分隔):", + "template.trackerEditorModal.userStatsTab.skillsSectionTitle": "技能欄", + "template.trackerEditorModal.userStatsTab.enableSkillsSection": "啟用技能欄", + "template.trackerEditorModal.userStatsTab.skillsLabelLabel": "技能欄標籤:", + "template.trackerEditorModal.userStatsTab.skillsListLabel": " 技能列表(以逗號分隔):", + "template.trackerEditorModal.infoBoxTab.widgetsTitle": "小工具", + "template.trackerEditorModal.infoBoxTab.dateWidget": "日期", + "template.trackerEditorModal.infoBoxTab.weatherWidget": "天氣", + "template.trackerEditorModal.infoBoxTab.temperatureWidget": "溫度", + "template.trackerEditorModal.infoBoxTab.timeWidget": "時間", + "template.trackerEditorModal.infoBoxTab.locationWidget": "位置", + "template.trackerEditorModal.infoBoxTab.recentEventsWidget": "近期事件", + "template.trackerEditorModal.presentCharactersTab.relationshipStatusTitle": "關係狀態", + "template.trackerEditorModal.presentCharactersTab.relationshipStatusHint": "定義關係類型,並在角色頭像上顯示對應的表情符號", + "template.trackerEditorModal.presentCharactersTab.newRelationshipButton": "新增關係類型", + "template.trackerEditorModal.presentCharactersTab.appearanceDemeanorTitle": "外觀與當前行為舉止", + "template.trackerEditorModal.presentCharactersTab.appearanceDemeanorHint": "角色名稱下方顯示的字段,以 | 分隔。", + "template.trackerEditorModal.presentCharactersTab.addCustomFieldButton": "添加自訂字段", + "template.trackerEditorModal.presentCharactersTab.thoughtsConfigTitle": "內心話配置", + "template.trackerEditorModal.presentCharactersTab.enableCharacterThoughts": "啟用角色內心話", + "template.trackerEditorModal.presentCharactersTab.thoughtsLabelLabel": "內心話標籤:", + "template.trackerEditorModal.presentCharactersTab.aiInstructionLabel": "內心話提示詞:", + "template.trackerEditorModal.presentCharactersTab.characterStatsTitle": "角色屬性", + "template.trackerEditorModal.presentCharactersTab.trackCharacterStats": "啟用角色屬性", + "template.trackerEditorModal.presentCharactersTab.characterStatsHint": "建立統計資料以追蹤每個角色(以彩色長條圖顯示)", + "template.trackerEditorModal.presentCharactersTab.addCharacterStatButton": "添加角色屬性", + "template.mainPanel.title": "RPG Companion", + "template.mainPanel.lastRoll": "上次擲骰:", + "template.mainPanel.clearLastRoll": "清除上次擲骰", + "template.mainPanel.enableImmersiveHtml": "啟用沉浸式 HTML", + "template.mainPanel.refreshRpgInfo": "刷新資訊", + "template.mainPanel.updating": "更新中...", + "template.mainPanel.editTrackersButton": "追蹤器編輯", + "template.mainPanel.settingsButton": "設定", + "global.none": "None", + "global.add": "添加", + "global.cancel": "取消", + "global.save": "保存", + "global.listView": "清單檢視", + "global.gridView": "格子檢視", + "global.status": "狀態欄", + "global.inventory": "物品欄", + "global.quests": "任務", + "global.info":"資訊", + "infobox.noData.title": "無資訊可顯示", + "infobox.noData.instruction": "在RP中產生新的回复,或在設定中切換到“單獨生成”,然後點擊“刷新資訊”按鈕。", + "infobox.recentEvents.title": "近期事件", + "infobox.recentEvents.addEventPlaceholder": "添加事件...", + "inventory.section.onPerson": "隨身物品", + "inventory.section.stored": "倉庫物品", + "inventory.section.assets": "資產", + "inventory.onPerson.empty": "這裡什麼都沒有 (⚲□⚲)", + "inventory.onPerson.title": "攜帶的物品", + "inventory.onPerson.addItemButton": "添加物品", + "inventory.onPerson.addItemPlaceholder": "輸入物品名稱...", + "inventory.stored.title": "倉庫位置", + "inventory.stored.addLocationButton": "添加倉庫", + "inventory.stored.addLocationPlaceholder": "輸入倉庫名稱...", + "inventory.stored.saveButton": "保存", + "inventory.stored.empty": "沒有倉庫 (⚲□⚲), 點擊\"添加倉庫\"來新增一個倉庫", + "inventory.stored.noItems": "這個倉庫是空的 (⚲□⚲)", + "inventory.stored.addItemToLocationPlaceholder": "輸入物品名稱...", + "inventory.stored.addItemButton": "添加物品", + "inventory.stored.confirmRemoveLocationMessage": "確定要刪除這個倉庫嗎?這將移除所有其中的物品。", + "inventory.stored.confirmRemoveLocationConfirmButton": "刪除", + "inventory.assets.empty": "沒有資產 (⚲□⚲) 好窮", + "inventory.assets.title": "車輛、房產及主要財產", + "inventory.assets.addAssetModalTitle": "添加資產", + "inventory.assets.addAssetButton": "添加資產", + "inventory.assets.addAssetPlaceholder": "輸入資產名稱...", + "inventory.assets.description": "資產包括車輛(汽車、摩托車)、房產(房屋、公寓)和主要設備(車間工具、特殊物品)。", + "quests.section.main": "主線任務", + "quests.section.optional": "支線任務", + "quests.main.title": "主線任務", + "quests.main.addQuestButton": "添加主要任務", + "quests.main.addQuestPlaceholder": "輸入主線任務名稱...", + "quests.main.empty": "當前無主要任務 (ฅ˙Ⱉ˙ฅ)", + "quests.main.hint": "主線任務代表你在故事中的主要目標。", + "quests.optional.title": "支線任務", + "quests.optional.addQuestButton": "添加支線任務", + "quests.optional.addQuestPlaceholder": "輸入支線任務名稱...", + "quests.optional.empty": "當前無支線任務 (ʘ̆ʚʘ̆)", + "quests.optional.hint": "支線任務是補充主線劇情的支線目標。" +} \ No newline at end of file diff --git a/src/systems/features/dice.js b/src/systems/features/dice.js index 92e691b..fe5a0c4 100644 --- a/src/systems/features/dice.js +++ b/src/systems/features/dice.js @@ -9,6 +9,7 @@ import { setPendingDiceRoll } from '../../core/state.js'; import { saveSettings } from '../../core/persistence.js'; +import { i18n } from '../../core/i18n.js'; /** * Rolls the dice and displays result. @@ -85,10 +86,13 @@ export async function executeRollCommand(command) { */ export function updateDiceDisplay() { const lastRoll = extensionSettings.lastDiceRoll; + const label = i18n.getTranslation('template.mainPanel.lastRoll') || 'Last Roll: '; + const noneValue = i18n.getTranslation('global.none') || 'None'; + if (lastRoll) { - $('#rpg-last-roll-text').text(`Last Roll (${lastRoll.formula}): ${lastRoll.total}`); + $('#rpg-last-roll-text').text(`${label}(${lastRoll.formula}): ${lastRoll.total}`); } else { - $('#rpg-last-roll-text').text('Last Roll: None'); + $('#rpg-last-roll-text').text(label + noneValue); } } diff --git a/src/systems/generation/apiClient.js b/src/systems/generation/apiClient.js index a279983..fa155bd 100644 --- a/src/systems/generation/apiClient.js +++ b/src/systems/generation/apiClient.js @@ -22,6 +22,7 @@ import { renderInfoBox } from '../rendering/infoBox.js'; import { renderThoughts } from '../rendering/thoughts.js'; import { renderInventory } from '../rendering/inventory.js'; import { renderQuests } from '../rendering/quests.js'; +import { i18n } from '../../core/i18n.js'; // Store the original preset name to restore after tracker generation let originalPresetName = null; @@ -104,8 +105,8 @@ export async function updateRPGData(renderUserStats, renderInfoBox, renderThough // Update button to show "Updating..." state const $updateBtn = $('#rpg-manual-update'); - const originalHtml = $updateBtn.html(); - $updateBtn.html(' Updating...').prop('disabled', true); + const updatingText = i18n.getTranslation('template.mainPanel.updating') || 'Updating...'; + $updateBtn.html(` ${updatingText}`).prop('disabled', true); // Save current preset name before switching (if we're going to switch) if (extensionSettings.useSeparatePreset) { @@ -229,7 +230,8 @@ export async function updateRPGData(renderUserStats, renderInfoBox, renderThough // Restore button to original state const $updateBtn = $('#rpg-manual-update'); - $updateBtn.html(' Refresh RPG Info').prop('disabled', false); + const refreshText = i18n.getTranslation('template.mainPanel.refreshRpgInfo') || 'Refresh RPG Info'; + $updateBtn.html(` ${refreshText}`).prop('disabled', false); // Reset the flag after tracker generation completes // This ensures the flag persists through both main generation AND tracker generation diff --git a/src/systems/rendering/infoBox.js b/src/systems/rendering/infoBox.js index d223e84..e913f9f 100644 --- a/src/systems/rendering/infoBox.js +++ b/src/systems/rendering/infoBox.js @@ -11,6 +11,7 @@ import { $infoBoxContainer } from '../../core/state.js'; import { saveChatData } from '../../core/persistence.js'; +import { i18n } from '../../core/i18n.js'; /** * Helper to separate emoji from text in a string @@ -72,8 +73,8 @@ export function renderInfoBox() { const placeholderHtml = `
-
No data yet
-
Generate a new response in the roleplay or switch to "Separate Generation" in Settings to access and click the "Refresh RPG Info" button
+
${i18n.getTranslation('infobox.noData.title')}
+
${i18n.getTranslation('infobox.noData.instruction')}
`; @@ -447,7 +448,7 @@ export function renderInfoBox() {
-
Recent Events
+
${i18n.getTranslation('infobox.recentEvents.title')}
`; @@ -466,7 +467,7 @@ export function renderInfoBox() { html += `
+ - Add event... + ${i18n.getTranslation('infobox.recentEvents.addEventPlaceholder')}
`; } diff --git a/src/systems/rendering/inventory.js b/src/systems/rendering/inventory.js index 310261b..00b9e76 100644 --- a/src/systems/rendering/inventory.js +++ b/src/systems/rendering/inventory.js @@ -7,6 +7,7 @@ import { extensionSettings, $inventoryContainer } from '../../core/state.js'; import { getInventoryRenderOptions, restoreFormStates } from '../interaction/inventoryActions.js'; import { updateInventoryItem } from '../interaction/inventoryEdit.js'; import { parseItems } from '../../utils/itemParser.js'; +import { i18n } from '../../core/i18n.js'; // Type imports /** @typedef {import('../../types/inventory.js').InventoryV2} InventoryV2 */ @@ -30,14 +31,14 @@ export function getLocationId(locationName) { export function renderInventorySubTabs(activeTab = 'onPerson') { return `
- - -
`; @@ -54,7 +55,7 @@ export function renderOnPersonView(onPersonItems, viewMode = 'list') { let itemsHtml = ''; if (items.length === 0) { - itemsHtml = '
No items carried
'; + itemsHtml = `
${i18n.getTranslation('inventory.onPerson.empty')}
`; } else { if (viewMode === 'grid') { // Grid view: card-style items @@ -84,30 +85,30 @@ export function renderOnPersonView(onPersonItems, viewMode = 'list') { return `
-

Items Currently Carried

+

${i18n.getTranslation('inventory.onPerson.title')}

- -
@@ -132,30 +133,30 @@ export function renderStoredView(stored, collapsedLocations = [], viewMode = 'li let html = `
-

Storage Locations

+

${i18n.getTranslation('inventory.stored.title')}

- -
@@ -163,8 +164,8 @@ export function renderStoredView(stored, collapsedLocations = [], viewMode = 'li if (locations.length === 0) { html += ` -
- No storage locations yet. Click "Add Location" to create one. +
+ ${i18n.getTranslation('inventory.stored.empty')}
`; } else { @@ -176,7 +177,7 @@ export function renderStoredView(stored, collapsedLocations = [], viewMode = 'li let itemsHtml = ''; if (items.length === 0) { - itemsHtml = '
No items stored here
'; + itemsHtml = `
${i18n.getTranslation('inventory.stored.noItems')}
`; } else { if (viewMode === 'grid') { // Grid view: card-style items @@ -218,13 +219,13 @@ export function renderStoredView(stored, collapsedLocations = [], viewMode = 'li
@@ -233,18 +234,18 @@ export function renderStoredView(stored, collapsedLocations = [], viewMode = 'li
@@ -272,7 +273,7 @@ export function renderAssetsView(assets, viewMode = 'list') { let itemsHtml = ''; if (items.length === 0) { - itemsHtml = '
No assets owned
'; + itemsHtml = `
${i18n.getTranslation('inventory.assets.empty')}
`; } else { if (viewMode === 'grid') { // Grid view: card-style items @@ -289,7 +290,7 @@ export function renderAssetsView(assets, viewMode = 'list') { itemsHtml = items.map((item, index) => `
${escapeHtml(item)} -
@@ -302,30 +303,30 @@ export function renderAssetsView(assets, viewMode = 'list') { return `
-

Vehicles, Property & Major Possessions

+

${i18n.getTranslation('inventory.assets.title')}

- -
@@ -334,8 +335,7 @@ export function renderAssetsView(assets, viewMode = 'list') {
- Assets include vehicles (cars, motorcycles), property (homes, apartments), - and major equipment (workshop tools, special items). + ${i18n.getTranslation('inventory.assets.description')}
diff --git a/src/systems/rendering/quests.js b/src/systems/rendering/quests.js index efaa8da..d122835 100644 --- a/src/systems/rendering/quests.js +++ b/src/systems/rendering/quests.js @@ -5,6 +5,7 @@ import { extensionSettings, $questsContainer } from '../../core/state.js'; import { saveSettings } from '../../core/persistence.js'; +import { i18n } from '../../core/i18n.js'; /** * HTML escape helper @@ -25,11 +26,11 @@ function escapeHtml(text) { export function renderQuestsSubTabs(activeTab = 'main') { return `
- -
`; @@ -47,9 +48,9 @@ export function renderMainQuestView(mainQuest) { return `
-

Main Quests

- ${!hasQuest ? `` : ''}
@@ -58,10 +59,10 @@ export function renderMainQuestView(mainQuest) {
@@ -78,22 +79,22 @@ export function renderMainQuestView(mainQuest) {
` : ` -
No active main quests
+
${i18n.getTranslation('quests.main.empty')}
`}
- The main quests represent your primary objective in the story. + ${i18n.getTranslation('quests.main.hint')}
`; @@ -109,7 +110,7 @@ export function renderOptionalQuestsView(optionalQuests) { let questsHtml = ''; if (quests.length === 0) { - questsHtml = '
No active optional quests
'; + questsHtml = `
${i18n.getTranslation('quests.optional.empty')}
`; } else { questsHtml = quests.map((quest, index) => `
@@ -126,20 +127,20 @@ export function renderOptionalQuestsView(optionalQuests) { return `
-

Optional Quests

-
@@ -148,7 +149,7 @@ export function renderOptionalQuestsView(optionalQuests) {
- Optional quests are side objectives that complement your main story. + ${i18n.getTranslation('quests.optional.hint')}
diff --git a/src/systems/ui/desktop.js b/src/systems/ui/desktop.js index b7e07e2..fb35e4f 100644 --- a/src/systems/ui/desktop.js +++ b/src/systems/ui/desktop.js @@ -3,6 +3,8 @@ * Handles desktop-specific UI functionality: tab navigation */ +import { i18n } from '../../core/i18n.js'; + /** * Sets up desktop tab navigation for organizing content. * Only runs on desktop viewports (>1000px). @@ -34,15 +36,15 @@ export function setupDesktopTabs() {
`); @@ -86,6 +88,7 @@ export function setupDesktopTabs() { // Replace content box with tabs container $contentBox.html('').append($tabsContainer); + i18n.applyTranslations($tabsContainer[0]); // Handle tab switching $tabNav.find('.rpg-tab-btn').on('click', function() { diff --git a/src/systems/ui/layout.js b/src/systems/ui/layout.js index 38c995c..089cd71 100644 --- a/src/systems/ui/layout.js +++ b/src/systems/ui/layout.js @@ -11,6 +11,7 @@ import { $thoughtsContainer, $inventoryContainer } from '../../core/state.js'; +import { i18n } from '../../core/i18n.js'; /** * Toggles the visibility of plot buttons based on settings. @@ -92,6 +93,7 @@ export function updateCollapseToggleIcon() { */ export function setupCollapseToggle() { const $collapseToggle = $('#rpg-collapse-toggle'); + $collapseToggle.attr('title', i18n.getTranslation('template.mainPanel.collapseExpand')); const $panel = $('#rpg-companion-panel'); const $icon = $collapseToggle.find('i'); diff --git a/src/systems/ui/mobile.js b/src/systems/ui/mobile.js index e25b330..2a8be3b 100644 --- a/src/systems/ui/mobile.js +++ b/src/systems/ui/mobile.js @@ -7,6 +7,43 @@ import { extensionSettings } from '../../core/state.js'; import { saveSettings } from '../../core/persistence.js'; import { closeMobilePanelWithAnimation, updateCollapseToggleIcon } from './layout.js'; import { setupDesktopTabs, removeDesktopTabs } from './desktop.js'; +import { i18n } from '../../core/i18n.js'; + +/** + * Updates the text labels of the mobile navigation tabs based on the current language. + */ +export function updateMobileTabLabels() { + const $tabs = $('.rpg-mobile-tabs .rpg-mobile-tab'); + if ($tabs.length === 0) return; + + $tabs.each(function() { + const $tab = $(this); + const tabName = $tab.data('tab'); + let translationKey = ''; + + switch (tabName) { + case 'stats': + translationKey = 'global.status'; + break; + case 'info': + translationKey = 'global.info'; + break; + case 'inventory': + translationKey = 'global.inventory'; + break; + case 'quests': + translationKey = 'global.quests'; + break; + } + + if (translationKey) { + const translation = i18n.getTranslation(translationKey); + if (translation) { + $tab.find('span').text(translation); + } + } + }); +} /** * Sets up the mobile toggle button (FAB) with drag functionality. @@ -547,19 +584,19 @@ export function setupMobileTabs() { // Tab 1: Stats (User Stats only) if (hasStats) { - tabs.push(''); + tabs.push(''); } // Tab 2: Info (Info Box + Character Thoughts) if (hasInfo) { - tabs.push(''); + tabs.push(''); } // Tab 3: Inventory if (hasInventory) { - tabs.push(''); + tabs.push(''); } // Tab 4: Quests if (hasQuests) { - tabs.push(''); + tabs.push(''); } const $tabNav = $('
' + tabs.join('') + '
'); diff --git a/src/systems/ui/modals.js b/src/systems/ui/modals.js index 997bf7c..ced6514 100644 --- a/src/systems/ui/modals.js +++ b/src/systems/ui/modals.js @@ -23,6 +23,7 @@ import { updateDiceDisplay as updateDiceDisplayCore, addDiceQuickReply as addDiceQuickReplyCore } from '../features/dice.js'; +import { i18n } from '../../core/i18n.js'; /** * Modern DiceModal ES6 Class @@ -318,6 +319,7 @@ export function setupDiceRoller() { e.stopPropagation(); // Prevent opening the dice popup clearDiceRollCore(); }); + $('#rpg-clear-dice').attr('title', i18n.getTranslation('template.mainPanel.clearLastRoll')); return diceModal; } diff --git a/src/systems/ui/trackerEditor.js b/src/systems/ui/trackerEditor.js index 86192ec..0485c73 100644 --- a/src/systems/ui/trackerEditor.js +++ b/src/systems/ui/trackerEditor.js @@ -2,7 +2,7 @@ * Tracker Editor Module * Provides UI for customizing tracker configurations */ - +import { i18n } from '../../core/i18n.js'; import { extensionSettings } from '../../core/state.js'; import { saveSettings } from '../../core/persistence.js'; import { renderUserStats } from '../rendering/userStats.js'; @@ -205,7 +205,7 @@ function renderUserStatsTab() { let html = '
'; // Custom Stats section - html += '

Custom Stats

'; + html += `

${i18n.getTranslation('template.trackerEditorModal.userStatsTab.customStatsTitle')}

`; html += '
'; config.customStats.forEach((stat, index) => { @@ -219,25 +219,25 @@ function renderUserStatsTab() { }); html += '
'; - html += ''; + html += ``; // RPG Attributes section - html += '

RPG Attributes

'; + html += `

${i18n.getTranslation('template.trackerEditorModal.userStatsTab.rpgAttributesTitle')}

`; // Enable/disable toggle for entire RPG Attributes section const showRPGAttributes = config.showRPGAttributes !== undefined ? config.showRPGAttributes : true; html += '
'; html += ``; - html += ''; + html += ``; html += '
'; // Always send attributes toggle const alwaysSendAttributes = config.alwaysSendAttributes !== undefined ? config.alwaysSendAttributes : false; html += '
'; html += ``; - html += ''; + html += ``; html += '
'; - html += 'If disabled, attributes are only sent when a dice roll is active.'; + html += `${i18n.getTranslation('template.trackerEditorModal.userStatsTab.alwaysIncludeAttributesNote')}`; html += '
'; @@ -268,34 +268,34 @@ function renderUserStatsTab() { }); html += '
'; - html += ''; + html += ``; // Status Section - html += '

Status Section

'; + html += `

${i18n.getTranslation('template.trackerEditorModal.userStatsTab.statusSectionTitle')}

`; html += '
'; html += ``; - html += ''; + html += ``; html += '
'; html += '
'; html += ``; - html += ''; + html += ``; html += '
'; - html += ''; + html += ``; html += ``; // Skills Section - html += '

Skills Section

'; + html += `

${i18n.getTranslation('template.trackerEditorModal.userStatsTab.skillsSectionTitle')}

`; html += '
'; html += ``; - html += ''; + html += ``; html += '
'; - html += ''; + html += ``; html += ``; - html += ''; + html += ``; const skillFields = config.skillsSection.customFields || []; html += ``; @@ -436,12 +436,12 @@ function renderInfoBoxTab() { const config = extensionSettings.trackerConfig.infoBox; let html = '
'; - html += '

Widgets

'; + html += `

${i18n.getTranslation('template.trackerEditorModal.infoBoxTab.widgetsTitle')}

`; // Date widget html += '
'; html += ``; - html += ''; + html += ``; html += '`; - html += ''; + html += ``; html += '
'; // Temperature widget html += '
'; html += ``; - html += ''; + html += ``; html += '
'; html += ``; html += ``; @@ -469,19 +469,19 @@ function renderInfoBoxTab() { // Time widget html += '
'; html += ``; - html += ''; + html += ``; html += '
'; // Location widget html += '
'; html += ``; - html += ''; + html += ``; html += '
'; // Recent Events widget html += '
'; html += ``; - html += ''; + html += ``; html += '
'; html += '
'; @@ -537,8 +537,8 @@ function renderPresentCharactersTab() { let html = '
'; // Relationship Fields Section - html += '

Relationship Status Fields

'; - html += '

Define relationship types with corresponding emojis shown on character portraits

'; + html += `

${i18n.getTranslation('template.trackerEditorModal.presentCharactersTab.relationshipStatusTitle')}

`; + html += `

${i18n.getTranslation('template.trackerEditorModal.presentCharactersTab.relationshipStatusHint')}

`; html += '
'; // Show existing relationships as field → emoji pairs @@ -561,11 +561,11 @@ function renderPresentCharactersTab() { `; } html += '
'; - html += ''; + html += ``; // Custom Fields Section - html += '

Appearance/Demeanor Fields

'; - html += '

Fields shown below character name, separated by |

'; + html += `

${i18n.getTranslation('template.trackerEditorModal.presentCharactersTab.appearanceDemeanorTitle')}

`; + html += `

${i18n.getTranslation('template.trackerEditorModal.presentCharactersTab.appearanceDemeanorHint')}

`; html += '
'; @@ -585,34 +585,34 @@ function renderPresentCharactersTab() { }); html += '
'; - html += ''; + html += ``; // Thoughts Section - html += '

Thoughts Configuration

'; + html += `

${i18n.getTranslation('template.trackerEditorModal.presentCharactersTab.thoughtsConfigTitle')}

`; html += '
'; html += ``; - html += ''; + html += ``; html += '
'; html += '
'; html += '
'; - html += ''; + html += ``; html += ``; html += '
'; html += '
'; - html += ''; + html += ``; html += ``; html += '
'; html += '
'; // Character Stats - html += '

Character Stats

'; + html += `

${i18n.getTranslation('template.trackerEditorModal.presentCharactersTab.characterStatsTitle')}

`; html += '
'; html += ``; - html += ''; + html += ``; html += '
'; - html += '

Create stats to track for each character (displayed as colored bars)

'; + html += `

${i18n.getTranslation('template.trackerEditorModal.presentCharactersTab.characterStatsHint')}

`; html += '
'; const charStats = config.characterStats?.customStats || []; @@ -627,7 +627,7 @@ function renderPresentCharactersTab() { }); html += '
'; - html += ''; + html += ``; html += '
'; diff --git a/template.html b/template.html index ff8c8fa..76af63e 100644 --- a/template.html +++ b/template.html @@ -10,7 +10,7 @@

- RPG Companion + RPG Companion

@@ -18,8 +18,8 @@
- Last Roll: None - + +
@@ -64,22 +64,22 @@
@@ -92,184 +92,184 @@

- RPG Companion Settings + RPG Companion Settings

-

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.
@@ -375,7 +375,7 @@

- Edit Trackers + Edit Trackers

@@ -383,13 +383,13 @@
@@ -402,12 +402,12 @@