From 6759f514f3242483b01ecc6d34dfda794bafab92 Mon Sep 17 00:00:00 2001 From: Mingyu Date: Mon, 24 Nov 2025 22:38:56 +0800 Subject: [PATCH] pc all done --- settings.html | 4 +- src/i18n/en.json | 51 +++++++++++++++++- src/i18n/zh-tw.json | 51 +++++++++++++++++- src/systems/rendering/infoBox.js | 9 ++-- src/systems/rendering/inventory.js | 84 +++++++++++++++--------------- src/systems/rendering/quests.js | 45 ++++++++-------- src/systems/ui/desktop.js | 9 ++-- 7 files changed, 178 insertions(+), 75 deletions(-) diff --git a/settings.html b/settings.html index cb15e22..98fb41b 100644 --- a/settings.html +++ b/settings.html @@ -7,7 +7,7 @@
@@ -18,7 +18,7 @@
- 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/i18n/en.json b/src/i18n/en.json index 5fc32df..4143543 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -2,6 +2,8 @@ "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:", @@ -110,5 +112,52 @@ "template.mainPanel.refreshRpgInfo": "Refresh RPG Info", "template.mainPanel.editTrackersButton": "Edit Trackers", "template.mainPanel.settingsButton": "Settings", - "global.none": "None" + "global.none": "None", + "global.add": "Add", + "global.cancel": "Cancel", + "global.listView": "List view", + "global.gridView": "Grid view", + "global.save": "Save", + "desktop.tab.status":"Status", + "desktop.tab.inventory":"Inventory", + "desktop.tab.quests":"Quests", + "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 index 2ef4d2d..cd415b9 100644 --- a/src/i18n/zh-tw.json +++ b/src/i18n/zh-tw.json @@ -2,6 +2,8 @@ "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": "可選主題:", @@ -110,5 +112,52 @@ "template.mainPanel.refreshRpgInfo": "刷新資訊", "template.mainPanel.editTrackersButton": "追蹤器編輯", "template.mainPanel.settingsButton": "設定", - "global.none": "None" + "global.none": "None", + "global.add": "添加", + "global.cancel": "取消", + "global.save": "保存", + "global.listView": "清單檢視", + "global.gridView": "格子檢視", + "desktop.tab.status": "狀態欄", + "desktop.tab.inventory": "物品欄", + "desktop.tab.quests": "任務", + "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/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..fa08743 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() {