diff --git a/src/core/i18n.js b/src/core/i18n.js index 5325cf9..315b4e4 100644 --- a/src/core/i18n.js +++ b/src/core/i18n.js @@ -5,6 +5,20 @@ 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() { @@ -82,6 +96,7 @@ class Internationalization { localStorage.setItem('rpgCompanionLanguage', lang); await this.loadTranslations(lang); this.applyTranslations(document.body); + this.dispatchEvent('languageChanged'); } } diff --git a/src/i18n/en.json b/src/i18n/en.json index 4143543..10835b6 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -118,9 +118,10 @@ "global.listView": "List view", "global.gridView": "Grid view", "global.save": "Save", - "desktop.tab.status":"Status", - "desktop.tab.inventory":"Inventory", - "desktop.tab.quests":"Quests", + "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", diff --git a/src/i18n/zh-tw.json b/src/i18n/zh-tw.json index cd415b9..3714b09 100644 --- a/src/i18n/zh-tw.json +++ b/src/i18n/zh-tw.json @@ -118,9 +118,10 @@ "global.save": "保存", "global.listView": "清單檢視", "global.gridView": "格子檢視", - "desktop.tab.status": "狀態欄", - "desktop.tab.inventory": "物品欄", - "desktop.tab.quests": "任務", + "global.status": "狀態欄", + "global.inventory": "物品欄", + "global.quests": "任務", + "global.info":"資訊", "infobox.noData.title": "無資訊可顯示", "infobox.noData.instruction": "在RP中產生新的回复,或在設定中切換到“單獨生成”,然後點擊“刷新資訊”按鈕。", "infobox.recentEvents.title": "近期事件", diff --git a/src/systems/features/dice.js b/src/systems/features/dice.js index fe5a0c4..3e452d1 100644 --- a/src/systems/features/dice.js +++ b/src/systems/features/dice.js @@ -115,3 +115,6 @@ export function addDiceQuickReply() { // For now, the dice display in the sidebar serves as the button } } + +// Add event listener to update display on language change +i18n.addEventListener('languageChanged', updateDiceDisplay); diff --git a/src/systems/ui/desktop.js b/src/systems/ui/desktop.js index fa08743..fb35e4f 100644 --- a/src/systems/ui/desktop.js +++ b/src/systems/ui/desktop.js @@ -36,15 +36,15 @@ export function setupDesktopTabs() {