'use strict';

(function exposeI18n(root, factory) {
  const api = factory();
  if (typeof module === 'object' && module.exports) module.exports = api;
  if (root) root.TokenMonitorI18n = api;
})(typeof window !== 'undefined' ? window : null, function createI18nApi() {
  const LANGUAGE_OPTIONS = [
    { value: 'auto', labelKey: 'settings.language.auto' },
    { value: 'en', labelKey: 'settings.language.english' },
    { value: 'zh-TW', labelKey: 'settings.language.zhTW' },
    { value: 'zh-CN', labelKey: 'settings.language.zhCN' }
  ];

  const MESSAGES = {
    en: {
      'settings.language.title': 'Language',
      'settings.language.label': 'Interface language',
      'settings.language.auto': 'Auto (system)',
      'settings.language.english': 'English',
      'settings.language.zhTW': '繁體中文',
      'settings.language.zhCN': '简体中文',
      'settings.sync.title': 'Multi-device Sync',
      'settings.sync.localOnly': 'Local only',
      'settings.sync.localOnlyDesc': 'This device only.',
      'settings.sync.connectHub': 'Connect to a hub',
      'settings.sync.connectHubDesc': "Send this device's usage to a hub elsewhere.",
      'settings.sync.hostHub': 'Host hub on this device',
      'settings.sync.hostHubDesc': 'Open a hub here so other devices can connect.',
      'settings.sync.hubUrl': 'Hub URL',
      'settings.sync.secret': 'Secret',
      'settings.sync.secretPlaceholder': 'optional shared secret',
      'settings.sync.port': 'Port',
      'settings.sync.sharedSecret': 'Shared Secret',
      'settings.sync.copySecret': 'Copy secret',
      'settings.sync.regenerateSecret': 'Regenerate',
      'settings.sync.hostNote': 'Other devices connect using one of the URLs above with the shared secret. macOS / Windows may prompt to allow incoming connections the first time. For cross-network use, run Tailscale or ZeroTier on both sides - the virtual IP works the same.',
      'settings.sync.hostWarning': 'The hub runs while Token Monitor is running. Quitting (not just closing the window) stops the hub for all connected devices.',
      'settings.sync.deviceId': 'Device ID',
      'settings.sync.deviceIdPlaceholder': 'auto (hostname)',
      'settings.sync.starting': 'Starting...',
      'settings.sync.portInUse': 'Port {port} already in use',
      'settings.sync.hubStopped': 'Hub stopped',
      'settings.sync.listening': 'Listening on port {port}',
      'settings.sync.noLanAddress': 'No LAN address detected. Other devices on this machine can use http://127.0.0.1:{port}.',
      'settings.sync.connectWith': 'Other devices connect with:',
      'settings.sync.copyUrl': 'Copy {url}',
      'settings.common.save': 'Save',
      'settings.common.refresh': 'Refresh',
      'settings.common.logout': 'Logout',
      'settings.common.checking': 'Checking...',
      'settings.common.checkingEllipsis': 'Checking...',
      'settings.common.notChecked': 'Not checked',
      'settings.common.notFound': 'Not found',
      'settings.common.current': 'current',
      'settings.common.error': 'Error',
      'settings.sections.accounts': 'Accounts',
      'settings.sections.general': 'General',
      'settings.sections.main': 'Main',
      'settings.sections.window': 'Window',
      'settings.sections.collection': 'Collection',
      'settings.summary.tools': '{tracked} tracked · {visible} visible · {pinned} pinned',
      'settings.summary.accounts': '{linked}/{total} linked',
      'settings.summary.limits': '{enabled} enabled · {refresh}',
      'settings.summary.views': '{visible}/{total} views',
      'settings.summary.general': 'login {startup} · updates',
      'settings.summary.appearance': '{theme} · {vendors} custom',
      'settings.summary.on': 'on',
      'settings.summary.off': 'off',
      'settings.summary.unavailable': 'unavailable',
      'settings.summary.minutes': '{minutes} min',
      'settings.tools.title': 'Tools',
      'settings.tools.note': 'Track controls collection. Show controls the main Tools list.',
      'settings.tools.track': 'Track',
      'settings.tools.show': 'Show',
      'settings.tools.trackClient': 'Track {name}',
      'settings.tools.showClient': 'Show {name} in the Tools list',
      'settings.tools.hideClient': 'Hide {name} from the Tools list',
      'settings.tools.pinClient': 'Pin {name} to top',
      'settings.tools.unpinClient': 'Unpin {name}',
      'settings.tools.reorderClient': 'Drag to reorder {name}. Use Up/Down keys to move.',
      'settings.tools.resetOrder': 'Reset order',
      'settings.tools.showAll': 'Show all',
      'settings.tools.status.active': 'Detecting',
      'settings.tools.status.waiting': 'Waiting for data',
      'settings.tools.status.missing': 'Not installed',
      'settings.tools.status.signIn': 'Sign in needed',
      'settings.tools.status.openApp': 'Open the app',
      'settings.views.title': 'Main Screen',
      'settings.views.note': 'Choose which main views appear and the order of the mode button.',
      'settings.views.showView': 'Show {name}',
      'settings.views.hideView': 'Hide {name}',
      'settings.views.reorderView': 'Drag to reorder {name}. Use Up/Down keys to move.',
      'settings.views.resetOrder': 'Reset order',
      'settings.views.showAll': 'Show all',
      'settings.views.configureTrend': 'Configure {name}',
      'settings.views.enableTrend': 'Enable Trends',
      'views.tool': 'Tools',
      'views.status': 'Status',
      'views.device': 'Devices',
      'views.model': 'Models',
      'views.session': 'Sessions',
      'views.limits': 'Limits',
      'views.trends': 'Trends',
      'trends.empty': 'No usage history yet',
      'trends.open': 'Open dashboard',
      'trends.range.week': 'Last 7 days',
      'trends.range.month': 'This month',
      'trends.range.year': 'By month',
      'trends.activeDays': 'Active days',
      'trends.currentStreak': 'Current streak',
      'trends.longestStreak': 'Longest streak',
      'trends.peakDay': 'Peak day',
      'dashboard.title': 'Usage Dashboard',
      'dashboard.heatmap.title': 'Token Activity',
      'dashboard.tab.trends': 'Trends',
      'dashboard.tab.activity': 'Overview',
      'dashboard.stack.client': 'By tool',
      'dashboard.stack.model': 'By model',
      'dashboard.mode.bars': 'Bars',
      'dashboard.mode.kline': 'K-line',
      'dashboard.range.7': '7 days',
      'dashboard.range.30': '30 days',
      'dashboard.range.90': '90 days',
      'dashboard.range.365': '1 year',
      'dashboard.range.all': 'All',
      'dashboard.empty': 'No usage history yet',
      'dashboard.stat.totalTokens': 'Total tokens',
      'dashboard.stat.totalCost': 'Total cost',
      'dashboard.stat.favoriteModel': 'Top model',
      'dashboard.stat.messages': 'Messages',
      'dashboard.tooltip.inputCacheHit': 'Input (Cache Hit)',
      'dashboard.tooltip.inputCacheMiss': 'Input (Cache Miss)',
      'dashboard.tooltip.output': 'Output',
      'serviceStatus.ok': 'Operational',
      'serviceStatus.degraded': 'Degraded',
      'serviceStatus.outage': 'Outage',
      'serviceStatus.unknown': 'Unknown',
      'serviceStatus.loading': 'Checking status...',
      'serviceStatus.notChecked': 'Not checked',
      'serviceStatus.noIssues': 'No active issues',
      'serviceStatus.listSeparator': ', ',
      'serviceStatus.components': 'Affected: {count}',
      'serviceStatus.incidents': 'Incidents: {count}',
      'serviceStatus.maintenance': 'Maintenance: {count}',
      'serviceStatus.checkedAt': 'Checked {time}',
      'serviceStatus.openPage': 'Open {name} status page',
      'serviceStatus.checkFailed': 'Status check failed',
      'serviceStatus.providersNote': 'Choose which services appear on the Status view and their order.',
      'serviceStatus.allHidden': 'All services hidden',
      'serviceStatus.expandProviders': 'Expand {name} service list',
      'serviceStatus.configureProviders': 'Configure {name} services',
      'serviceStatus.reorderProvider': 'Drag to reorder {name}',
      'serviceStatus.hideProvider': 'Hide {name}',
      'serviceStatus.showProvider': 'Show {name}',
      'serviceStatus.agoSeconds': '{n}s ago',
      'serviceStatus.agoMinutes': '{n}m ago',
      'serviceStatus.agoHours': '{n}h ago',
      'serviceStatus.refreshEvery': 'Re-check',
      'serviceStatus.refreshManual': 'Manual',
      'serviceStatus.refreshMinutes': '{n}m',
      'settings.clientDisplay.title': 'CLI List',
      'settings.clientDisplay.note': 'Hide or reorder tools in the main list. Tracking settings above still control collection.',
      'settings.clientDisplay.moveUp': 'Move {name} up in the CLI list',
      'settings.clientDisplay.moveDown': 'Move {name} down in the CLI list',
      'settings.cursor.title': 'Cursor Account',
      'settings.cursor.openBrowser': 'Open cursor.com in browser',
      'settings.cursor.step1Before': 'Open',
      'settings.cursor.step1After': 'in your browser (button above).',
      'settings.cursor.step2Before': 'Open DevTools (F12 or Cmd+Opt+I) -> Application/Storage -> Cookies ->',
      'settings.cursor.step3Before': 'Copy the',
      'settings.cursor.step3After': 'value.',
      'settings.cursor.step4': 'Paste it below and click Save.',
      'settings.cursor.manualPlaceholder': 'WorkosCursorSessionToken=...',
      'settings.cursor.saveToken': 'Save token',
      'settings.cursor.loggedIn': 'Logged in',
      'settings.cursor.notLoggedIn': 'Not logged in',
      'settings.cursor.expired': 'Session expired - please log in again',
      'settings.cursor.billingResets': 'Billing resets {date}',
      'settings.cursor.statusCheckFailed': 'Status check failed: {message}',
      'settings.cursor.loginRequired': 'Login required to enable Cursor',
      'settings.cursor.loginFailed': 'Login failed: {message}',
      'settings.opencode.title': 'OpenCode Account',
      'settings.opencode.openBrowser': 'Open OpenCode auth in browser',
      'settings.opencode.step1Before': 'Open',
      'settings.opencode.step1After': 'in your browser (button above) and sign in.',
      'settings.opencode.step2': 'Open DevTools (F12 or Cmd+Opt+I) -> Application/Storage -> Cookies -> opencode.ai.',
      'settings.opencode.step3Before': 'Copy the',
      'settings.opencode.step3After': 'value.',
      'settings.opencode.step4': 'Paste it below and click Save.',
      'settings.opencode.cookiePlaceholder': 'auth=...',
      'settings.opencode.saveCookie': 'Save cookie',
      'settings.opencode.statusSet': 'Configured',
      'settings.opencode.statusNotSet': 'Not configured',
      'settings.opencode.statusLinked': 'Linked',
      'settings.opencode.tagZenBalance': 'Zen balance',
      'settings.opencode.expired': 'Cookie expired, please reconnect',
      'settings.opencode.statusCheckFailed': 'Status check failed: {message}',
      'settings.opencode.saveFailed': 'Connection failed: {message}',
      'settings.deepseek.title': 'DeepSeek Account',
      'settings.deepseek.openBrowser': 'Open DeepSeek API keys in browser',
      'settings.deepseek.note': 'Paste a DeepSeek API key. It stays on this device and is used only for the balance API.',
      'settings.deepseek.apiKeyPlaceholder': 'sk-...',
      'settings.deepseek.saveApiKey': 'Save API key',
      'settings.deepseek.clearApiKey': 'Clear key',
      'settings.deepseek.statusSet': 'Configured',
      'settings.deepseek.statusEnv': 'From .env',
      'settings.deepseek.statusNotSet': 'Not configured',
      'settings.deepseek.statusInvalid': 'API key invalid',
      'settings.deepseek.saveFailed': 'Save failed: {message}',
      'settings.limits.title': 'AI Tool Limits',
      'settings.limits.refresh': 'Refresh',
      'settings.limits.showSource': 'Show Source',
      'settings.limits.moveUp': 'Move {name} up',
      'settings.limits.moveDown': 'Move {name} down',
      'settings.limits.reorderProvider': 'Drag to reorder {name}. Use Up/Down keys to move.',
      'settings.limits.capability.auto': 'Auto',
      'settings.limits.capability.oauthCli': 'OAuth/CLI',
      'settings.limits.capability.cliRpc': 'CLI RPC',
      'settings.limits.capability.appCliRpc': 'App/CLI RPC',
      'settings.limits.capability.manualLogin': 'Manual login',
      'settings.limits.capability.web': 'Web',
      'settings.limits.capability.appMustBeOpen': 'App/CLI must be open',
      'settings.limits.capability.rpc': 'RPC',
      'settings.limits.capability.localZen': 'Local/Zen',
      'settings.limits.status.live': 'Live',
      'settings.limits.status.linked': 'Linked',
      'settings.limits.status.signIn': 'Sign in',
      'settings.limits.status.openApp': 'Open app or CLI',
      'settings.limits.status.noSyncedData': 'No synced data',
      'settings.limits.status.stale': 'Stale',
      'settings.limits.status.disabled': 'Disabled',
      'settings.limits.status.signInAgain': 'Sign in again',
      'settings.limits.status.limited': 'Limited',
      'settings.limits.status.usageApiLimited': 'Usage API limited',
      'settings.limits.status.unavailable': 'Unavailable',
      'settings.limits.status.notSetUp': 'Not set up',
      'settings.limits.capability.payg': 'Pay-as-you-go',
      'settings.limits.capability.apiKey': 'API key',
      'settings.limits.status.addApiKey': 'Add API key',
      'settings.limits.status.updateApiKey': 'Update API key',
      'settings.limits.status.error': 'Error',
      'settings.limits.device.local': 'Local',
      'settings.limits.device.from': 'From {device}',
      'settings.limits.device.localAndSynced': 'Local + {count} synced',
      'settings.limits.device.localAlso': 'Local also',
      'settings.display.title': 'Display Mode',
      'settings.display.windowTitle': 'Window',
      'settings.display.presenceTitle': 'Floating & Tray',
      'settings.display.windowBehavior': 'Display mode',
      'settings.currency.label': 'Currency',
      'settings.currency.usd': 'USD - US Dollar',
      'settings.currency.twd': 'TWD - New Taiwan Dollar',
      'settings.currency.hkd': 'HKD - Hong Kong Dollar',
      'settings.currency.cny': 'CNY - Chinese Yuan',
      'settings.display.windowBehaviorNote': 'Desktop pinned keeps the widget below other apps and locks drag/resize while staying clickable.',
      'settings.windowBehavior.floating': 'Floating above apps',
      'settings.windowBehavior.normal': 'Normal window',
      'settings.windowBehavior.desktop': 'Desktop pinned',
      'settings.windowBehavior.buttonTitle': '{current}; click for {next}',
      'settings.display.floatingBubble': 'Floating Bubble',
      'settings.display.floatingBubbleNote': 'Collapse the widget into a slim draggable mini-window; click it to reopen.',
      'settings.display.floatingBubbleTrigger': 'Open on',
      'settings.display.floatingBubbleContent': 'Bubble display',
      'settings.floatingBubbleTrigger.click': 'Click',
      'settings.floatingBubbleTrigger.hover': 'Hover (preview)',
      'settings.display.showTrayIcon': 'Show tray/menu bar icon',
      'settings.display.trayMode': 'Tray-only mode',
      'settings.display.trayNote': 'Hide the main window; show a popover from the macOS menu bar or Windows system tray.',
      'settings.display.trayText': 'Tray text',
      'settings.display.windowShortcut': 'Shortcut',
      'settings.display.windowShortcutNote': 'Record a global shortcut to show or hide the window.',
      'settings.display.windowShortcutListening': 'Press a shortcut. Esc cancels.',
      'settings.display.windowShortcutInvalid': 'Use Ctrl, Cmd, or Alt with a key.',
      'settings.display.windowShortcutRegistered': '{shortcut} is active.',
      'settings.display.windowShortcutConflict': 'Could not register {shortcut}. It may conflict with another app.',
      'settings.shortcut.off': 'Off',
      'settings.shortcut.record': 'Record',
      'settings.shortcut.recording': 'Recording...',
      'settings.shortcut.clear': 'Clear',
      'settings.tray.tokensToday': 'Tokens Today (1.2M)',
      'settings.tray.costToday': 'Cost Today ($1.23)',
      'settings.tray.bothToday': 'Tokens + Cost Today (1.2M - $1.23)',
      'settings.tray.tokensTotal': 'Tokens Total (1.36B)',
      'settings.tray.costTotal': 'Cost Total ($8.28)',
      'settings.tray.bothTotal': 'Tokens + Cost Total (1.36B - $8.28)',
      'settings.tray.barsSession': 'Limit bars: lowest session remaining',
      'settings.tray.barsWeekly': 'Limit bars: lowest weekly remaining',
      'settings.tray.barsAllSessions': 'Limit bars: first two session limits',
      'settings.tray.barsWindow': 'Limit bars: lowest remaining limit',
      'settings.tray.iconOnly': 'Icon only',
      'settings.startup.title': 'Startup',
      'settings.startup.startAtLogin': 'Start at login',
      'settings.startup.available': 'Available in packaged macOS and Windows builds.',
      'settings.startup.launchAtSignIn': 'Launch Token Monitor when you sign in.',
      'settings.appearance.title': 'Appearance',
      'settings.appearance.systemGlass': 'System Glass',
      'settings.appearance.liveIndicator': 'Live Indicator',
      'settings.appearance.toolIcons': 'Tool Icons',
      'settings.appearance.titleIcon': 'Use Title Icon',
      'settings.appearance.settingsInTitlebar': 'Settings button in title bar',
      'settings.appearance.glass': 'Glass',
      'settings.appearance.depth': 'Depth',
      'settings.appearance.zoom': 'Zoom',
      'settings.appearance.resetGlass': 'Reset glass',
      'settings.appearance.resetDepth': 'Reset depth',
      'settings.appearance.resetZoom': 'Reset zoom',
      'settings.appearance.themeTitle': 'Interface Theme',
      'settings.appearance.vendorTitle': 'Vendor Colors',
      'settings.appearance.vendorNote': 'Override the chart and list colour for each tool. Reset returns it to the brand colour.',
      'settings.appearance.vendorDefault': 'Other tools',
      'settings.appearance.resetAll': 'Reset all',
      'settings.appearance.resetBrand': 'Reset to brand',
      'settings.appearance.resetColor': 'Reset colour',
      'settings.appearance.custom': 'Custom',
      'settings.appearance.preset.default': 'Default',
      'settings.appearance.preset.obsidian': 'Obsidian',
      'settings.appearance.preset.porcelain': 'Porcelain',
      'settings.appearance.color.accent': 'Accent',
      'settings.appearance.color.bg': 'Background',
      'settings.appearance.color.text': 'Text',
      'settings.appearance.color.muted': 'Muted text',
      'settings.integrations.title': 'Integrations',
      'settings.integrations.discord': 'Discord Rich Presence',
      'settings.appUpdate.title': 'App Updates',
      'settings.appUpdate.source': 'GitHub releases',
      'settings.appUpdate.installed': 'Installed',
      'settings.appUpdate.latest': 'Latest',
      'settings.appUpdate.check': 'Check for updates',
      'settings.appUpdate.viewRelease': 'View release',
      'settings.appUpdate.upToDate': 'Up to date',
      'settings.appUpdate.upToDateShort': 'up to date',
      'settings.appUpdate.latestWithStatus': 'v{version} ({status})',
      'settings.appUpdate.checking': 'Checking...',
      'settings.appUpdate.githubError': "Couldn't reach GitHub",
      'settings.appUpdate.dismiss': 'Dismiss this version',
      'settings.tokscale.title': 'Tokscale',
      'settings.tokscale.source': 'CLI dependency from npm',
      'settings.tokscale.installed': 'Installed',
      'settings.tokscale.bundled': 'Bundled',
      'settings.tokscale.npm': 'On npm',
      'settings.tokscale.latestTag': '(latest tag)',
      'settings.tokscale.noteBefore': 'Token Monitor uses tokscale (MIT, open-source) to read token data.',
      'settings.tokscale.learnMore': 'Learn more',
      'settings.tokscale.checkNpm': 'Check npm',
      'settings.tokscale.downloadNpm': 'Download from npm',
      'settings.tokscale.resetBundled': 'Reset to bundled',
      'settings.tokscale.downloadedSource': 'downloaded from npm',
      'settings.tokscale.downloadedSourceWithAge': 'downloaded from npm, {age}',
      'settings.tokscale.bundledSource': 'bundled with this app',
      'settings.tokscale.currentSuffix': 'current',
      'settings.tokscale.checkingNpm': 'Checking npm...',
      'settings.tokscale.newerOnNpm': 'Newer tokscale is on npm.',
      'settings.tokscale.bundledCurrent': 'Bundled tokscale is current.',
      'settings.tokscale.downloading': 'Downloading from npm...',
      'settings.tokscale.downloaded': 'Downloaded {version} from npm.',
      'settings.tokscale.resetting': 'Resetting...',
      'settings.tokscale.usingBundled': 'Using bundled tokscale.',
      'settings.age.justNow': 'just now',
      'settings.age.minutesAgo': '{minutes}m ago',
      'settings.age.hoursAgo': '{hours}h ago',
      'settings.age.daysAgo': '{days}d ago',
      'settings.advanced.title': 'Advanced',
      'settings.advanced.note': 'Additional options are available in',
      'settings.advanced.openConfig': 'Open Config',
      'floatingBubble.expand': 'Show Token Monitor',
      'detailLoading': 'Loading…',
      'detailNotFound': 'Transcript not found on this machine.',
      'detailEmpty': 'No activity in this period.',
      'roleYou': 'You',
      'sortNewest': '↕ Newest',
      'sortMostTokens': '↕ Most tokens'
    },
    'zh-TW': {
      'settings.language.title': '語言',
      'settings.language.label': '介面語言',
      'settings.language.auto': '自動（跟隨系統）',
      'settings.language.english': 'English',
      'settings.language.zhTW': '繁體中文',
      'settings.language.zhCN': '简体中文',
      'settings.sync.title': '多裝置同步',
      'settings.sync.localOnly': '僅限本機',
      'settings.sync.localOnlyDesc': '只顯示這台裝置。',
      'settings.sync.connectHub': '連接到 Hub',
      'settings.sync.connectHubDesc': '把這台裝置的用量傳送到其他地方的 Hub。',
      'settings.sync.hostHub': '在這台裝置架設 Hub',
      'settings.sync.hostHubDesc': '在本機開啟 Hub，讓其他裝置連線。',
      'settings.sync.hubUrl': 'Hub URL',
      'settings.sync.secret': '密鑰',
      'settings.sync.secretPlaceholder': '選填的共享密鑰',
      'settings.sync.port': '連接埠',
      'settings.sync.sharedSecret': '共享密鑰',
      'settings.sync.copySecret': '複製密鑰',
      'settings.sync.regenerateSecret': '重新產生',
      'settings.sync.hostNote': '其他裝置可使用上方任一 URL 搭配共享密鑰連線。macOS / Windows 第一次可能會詢問是否允許連入。跨網路使用時，兩邊都執行 Tailscale 或 ZeroTier，虛擬 IP 的用法相同。',
      'settings.sync.hostWarning': 'Hub 只會在 Token Monitor 執行時運作。結束程式（不只是關閉視窗）會讓所有連線裝置的 Hub 停止。',
      'settings.sync.deviceId': '裝置 ID',
      'settings.sync.deviceIdPlaceholder': '自動（主機名稱）',
      'settings.sync.starting': '啟動中...',
      'settings.sync.portInUse': '連接埠 {port} 已被使用',
      'settings.sync.hubStopped': 'Hub 已停止',
      'settings.sync.listening': '正在監聽連接埠 {port}',
      'settings.sync.noLanAddress': '沒有偵測到 LAN 位址。這台機器上的其他裝置可使用 http://127.0.0.1:{port}。',
      'settings.sync.connectWith': '其他裝置使用以下位址連線：',
      'settings.sync.copyUrl': '複製 {url}',
      'settings.common.save': '儲存',
      'settings.common.refresh': '重新整理',
      'settings.common.logout': '登出',
      'settings.common.checking': '檢查中...',
      'settings.common.checkingEllipsis': '檢查中...',
      'settings.common.notChecked': '尚未檢查',
      'settings.common.notFound': '找不到',
      'settings.common.current': '目前版本',
      'settings.common.error': '錯誤',
      'settings.sections.accounts': '帳號',
      'settings.sections.general': '一般',
      'settings.sections.main': '主畫面',
      'settings.sections.window': '視窗',
      'settings.sections.collection': '採集',
      'settings.summary.tools': '追蹤 {tracked} · 顯示 {visible} · 置頂 {pinned}',
      'settings.summary.accounts': '已連結 {linked}/{total}',
      'settings.summary.limits': '啟用 {enabled} · {refresh}',
      'settings.summary.views': '{visible}/{total} 顯示',
      'settings.summary.general': '登入時啟動 {startup} · 更新',
      'settings.summary.appearance': '{theme} · 自訂 {vendors}',
      'settings.summary.on': '開',
      'settings.summary.off': '關',
      'settings.summary.unavailable': '不可用',
      'settings.summary.minutes': '{minutes} 分鐘',
      'settings.tools.title': '工具',
      'settings.tools.note': '追蹤控制採集；顯示只影響主列表。',
      'settings.tools.track': '追蹤',
      'settings.tools.show': '顯示',
      'settings.tools.trackClient': '追蹤 {name}',
      'settings.tools.showClient': '在工具列表顯示 {name}',
      'settings.tools.hideClient': '從工具列表隱藏 {name}',
      'settings.tools.pinClient': '置頂 {name}',
      'settings.tools.unpinClient': '取消置頂 {name}',
      'settings.tools.reorderClient': '拖曳排序 {name}。也可用上下鍵移動。',
      'settings.tools.resetOrder': '重設排序',
      'settings.tools.showAll': '顯示全部',
      'settings.tools.status.active': '偵測中',
      'settings.tools.status.waiting': '等待資料',
      'settings.tools.status.missing': '未安裝',
      'settings.tools.status.signIn': '需登入',
      'settings.tools.status.openApp': '需開啟 App',
      'settings.views.title': '主畫面',
      'settings.views.note': '調整主畫面視圖的顯示與切換順序。',
      'settings.views.showView': '顯示 {name}',
      'settings.views.hideView': '隱藏 {name}',
      'settings.views.reorderView': '拖曳排序 {name}。也可用上下鍵移動。',
      'settings.views.resetOrder': '重設排序',
      'settings.views.showAll': '顯示全部',
      'settings.views.configureTrend': '設定 {name}',
      'settings.views.enableTrend': '啟用趨勢',
      'views.tool': '工具',
      'views.status': '狀態',
      'views.device': '裝置',
      'views.model': '模型',
      'views.session': '會話',
      'views.limits': '額度',
      'views.trends': '趨勢',
      'trends.empty': '尚無使用歷史',
      'trends.open': '開啟儀表板',
      'trends.range.week': '近 7 天',
      'trends.range.month': '本月每日',
      'trends.range.year': '歷年每月',
      'trends.activeDays': '活躍天數',
      'trends.currentStreak': '連續天數',
      'trends.longestStreak': '最長連續',
      'trends.peakDay': '峰值單日',
      'dashboard.title': '使用儀表板',
      'dashboard.heatmap.title': 'Token 活動',
      'dashboard.tab.trends': '趨勢',
      'dashboard.tab.activity': '總覽',
      'dashboard.stack.client': '依工具',
      'dashboard.stack.model': '依模型',
      'dashboard.mode.bars': '棒形圖',
      'dashboard.mode.kline': 'K 線',
      'dashboard.range.7': '7 天',
      'dashboard.range.30': '30 天',
      'dashboard.range.90': '90 天',
      'dashboard.range.365': '1 年',
      'dashboard.range.all': '全部',
      'dashboard.empty': '尚無使用歷史',
      'dashboard.stat.totalTokens': '總 Token',
      'dashboard.stat.totalCost': '總花費',
      'dashboard.stat.favoriteModel': '常用模型',
      'dashboard.stat.messages': '訊息數',
      'dashboard.tooltip.inputCacheHit': '輸入 (快取命中)',
      'dashboard.tooltip.inputCacheMiss': '輸入 (快取未命中)',
      'dashboard.tooltip.output': '輸出',
      'serviceStatus.ok': '正常',
      'serviceStatus.degraded': '降級',
      'serviceStatus.outage': '中斷',
      'serviceStatus.unknown': '未知',
      'serviceStatus.loading': '檢查中...',
      'serviceStatus.notChecked': '尚未檢查',
      'serviceStatus.noIssues': '無進行中的問題',
      'serviceStatus.listSeparator': '、',
      'serviceStatus.components': '受影響組件：{count}',
      'serviceStatus.incidents': '事件：{count}',
      'serviceStatus.maintenance': '維護：{count}',
      'serviceStatus.checkedAt': '{time} 檢查',
      'serviceStatus.openPage': '開啟 {name} status 頁',
      'serviceStatus.checkFailed': '狀態檢查失敗',
      'serviceStatus.providersNote': '選擇 Status 頁顯示哪些服務、以及順序。',
      'serviceStatus.allHidden': '已隱藏所有服務',
      'serviceStatus.expandProviders': '展開 {name} 的服務清單',
      'serviceStatus.configureProviders': '設定 {name} 服務',
      'serviceStatus.reorderProvider': '拖曳重新排序 {name}',
      'serviceStatus.hideProvider': '隱藏 {name}',
      'serviceStatus.showProvider': '顯示 {name}',
      'serviceStatus.agoSeconds': '{n} 秒前',
      'serviceStatus.agoMinutes': '{n} 分鐘前',
      'serviceStatus.agoHours': '{n} 小時前',
      'serviceStatus.refreshEvery': '檢查間隔',
      'serviceStatus.refreshManual': '手動',
      'serviceStatus.refreshMinutes': '{n} 分鐘',
      'settings.clientDisplay.title': 'CLI 列表',
      'settings.clientDisplay.note': '只調整主列表的顯示與順序；上方追蹤工具才會控制採集。',
      'settings.clientDisplay.moveUp': '將 {name} 在 CLI 列表上移',
      'settings.clientDisplay.moveDown': '將 {name} 在 CLI 列表下移',
      'settings.cursor.title': 'Cursor 帳號',
      'settings.cursor.openBrowser': '在瀏覽器開啟 cursor.com',
      'settings.cursor.step1Before': '在瀏覽器開啟',
      'settings.cursor.step1After': '（使用上方按鈕）。',
      'settings.cursor.step2Before': '開啟 DevTools（F12 或 Cmd+Opt+I）-> Application/Storage -> Cookies ->',
      'settings.cursor.step3Before': '複製',
      'settings.cursor.step3After': '的值。',
      'settings.cursor.step4': '貼到下方後按儲存。',
      'settings.cursor.manualPlaceholder': 'WorkosCursorSessionToken=...',
      'settings.cursor.saveToken': '儲存 token',
      'settings.cursor.loggedIn': '已登入',
      'settings.cursor.notLoggedIn': '尚未登入',
      'settings.cursor.expired': 'Session 已過期，請重新登入',
      'settings.cursor.billingResets': '帳單於 {date} 重置',
      'settings.cursor.statusCheckFailed': '狀態檢查失敗：{message}',
      'settings.cursor.loginRequired': '需要登入才能啟用 Cursor',
      'settings.cursor.loginFailed': '登入失敗：{message}',
      'settings.opencode.title': 'OpenCode 帳號',
      'settings.opencode.openBrowser': '在瀏覽器開啟 OpenCode 登入',
      'settings.opencode.step1Before': '在瀏覽器開啟',
      'settings.opencode.step1After': '（使用上方按鈕）並登入。',
      'settings.opencode.step2': '開啟 DevTools（F12 或 Cmd+Opt+I）-> Application/Storage -> Cookies -> opencode.ai。',
      'settings.opencode.step3Before': '複製',
      'settings.opencode.step3After': '的值。',
      'settings.opencode.step4': '貼到下方後按儲存。',
      'settings.opencode.cookiePlaceholder': 'auth=...',
      'settings.opencode.saveCookie': '儲存 cookie',
      'settings.opencode.statusSet': '已設定',
      'settings.opencode.statusNotSet': '尚未設定',
      'settings.opencode.statusLinked': '已連結',
      'settings.opencode.tagZenBalance': 'Zen 餘額',
      'settings.opencode.expired': 'Cookie 已過期，請重新連結',
      'settings.opencode.statusCheckFailed': '狀態檢查失敗：{message}',
      'settings.opencode.saveFailed': '連結失敗：{message}',
      'settings.deepseek.title': 'DeepSeek 帳號',
      'settings.deepseek.openBrowser': '在瀏覽器開啟 DeepSeek API 金鑰',
      'settings.deepseek.note': '貼上 DeepSeek API 金鑰。它只保存在本機，僅用於餘額 API。',
      'settings.deepseek.apiKeyPlaceholder': 'sk-...',
      'settings.deepseek.saveApiKey': '儲存 API 金鑰',
      'settings.deepseek.clearApiKey': '清除金鑰',
      'settings.deepseek.statusSet': '已設定',
      'settings.deepseek.statusEnv': '來自 .env',
      'settings.deepseek.statusNotSet': '尚未設定',
      'settings.deepseek.statusInvalid': 'API 金鑰無效',
      'settings.deepseek.saveFailed': '儲存失敗：{message}',
      'settings.limits.title': 'AI 工具限制',
      'settings.limits.refresh': '重新整理',
      'settings.limits.showSource': '顯示來源',
      'settings.limits.moveUp': '將 {name} 上移',
      'settings.limits.moveDown': '將 {name} 下移',
      'settings.limits.reorderProvider': '拖曳排序 {name}。也可用上下鍵移動。',
      'settings.limits.capability.auto': '自動',
      'settings.limits.capability.oauthCli': 'OAuth/CLI',
      'settings.limits.capability.cliRpc': 'CLI RPC',
      'settings.limits.capability.appCliRpc': 'App/CLI RPC',
      'settings.limits.capability.manualLogin': '手動登入',
      'settings.limits.capability.web': 'Web',
      'settings.limits.capability.appMustBeOpen': '需開啟 App 或 CLI',
      'settings.limits.capability.rpc': 'RPC',
      'settings.limits.capability.localZen': 'Local/Zen',
      'settings.limits.status.live': '已偵測',
      'settings.limits.status.linked': '已連結',
      'settings.limits.status.signIn': '需登入',
      'settings.limits.status.openApp': '請開啟 App 或 CLI',
      'settings.limits.status.noSyncedData': '尚無同步資料',
      'settings.limits.status.stale': '資料過期',
      'settings.limits.status.disabled': '已停用',
      'settings.limits.status.signInAgain': '重新登入',
      'settings.limits.status.limited': '受限',
      'settings.limits.status.usageApiLimited': '來源受限',
      'settings.limits.status.unavailable': '暫不可用',
      'settings.limits.status.notSetUp': '尚未設定',
      'settings.limits.capability.payg': '按量付費',
      'settings.limits.capability.apiKey': 'API 金鑰',
      'settings.limits.status.addApiKey': '新增 API 金鑰',
      'settings.limits.status.updateApiKey': '更新 API 金鑰',
      'settings.limits.status.error': '錯誤',
      'settings.limits.device.local': '本機',
      'settings.limits.device.from': '來自 {device}',
      'settings.limits.device.localAndSynced': '本機 + {count} 同步',
      'settings.limits.device.localAlso': '本機也有',
      'settings.display.title': '顯示模式',
      'settings.display.windowTitle': '視窗',
      'settings.display.presenceTitle': '浮窗與系統列',
      'settings.display.windowBehavior': '顯示方式',
      'settings.currency.label': '貨幣',
      'settings.currency.usd': 'USD - 美金',
      'settings.currency.twd': 'TWD - 台幣',
      'settings.currency.hkd': 'HKD - 港幣',
      'settings.currency.cny': 'CNY - 人民幣',
      'settings.display.windowBehaviorNote': '固定在桌面會讓 widget 留在其他 app 下方，鎖定拖曳與縮放，但仍可點擊操作。',
      'settings.windowBehavior.floating': '浮在其他 app 上方',
      'settings.windowBehavior.normal': '一般視窗',
      'settings.windowBehavior.desktop': '固定在桌面',
      'settings.windowBehavior.buttonTitle': '目前：{current}；點擊切換為 {next}',
      'settings.display.floatingBubble': '懸浮小窗',
      'settings.display.floatingBubbleNote': '將 widget 收成可拖曳的窄長小窗，點擊即可重新展開。',
      'settings.display.floatingBubbleTrigger': '展開方式',
      'settings.display.floatingBubbleContent': '懸浮球顯示',
      'settings.floatingBubbleTrigger.click': '點擊',
      'settings.floatingBubbleTrigger.hover': '懸停預覽',
      'settings.display.showTrayIcon': '顯示托盤／選單列圖示',
      'settings.display.trayMode': '僅托盤顯示',
      'settings.display.trayNote': '隱藏主視窗；改從 macOS 選單列或 Windows 系統匣顯示彈出視窗。',
      'settings.display.trayText': '托盤文字',
      'settings.display.windowShortcut': '快捷鍵',
      'settings.display.windowShortcutNote': '錄製全域快捷鍵，用來顯示或隱藏視窗。',
      'settings.display.windowShortcutListening': '按下快捷鍵，Esc 取消。',
      'settings.display.windowShortcutInvalid': '請搭配 Ctrl、Cmd 或 Alt。',
      'settings.display.windowShortcutRegistered': '已啟用 {shortcut}。',
      'settings.display.windowShortcutConflict': '無法註冊 {shortcut}，可能和其他 app 衝突。',
      'settings.shortcut.off': '關閉',
      'settings.shortcut.record': '錄製',
      'settings.shortcut.recording': '錄製中...',
      'settings.shortcut.clear': '清除',
      'settings.tray.tokensToday': '今日 Tokens（1.2M）',
      'settings.tray.costToday': '今日成本（$1.23）',
      'settings.tray.bothToday': '今日 Tokens + 成本（1.2M - $1.23）',
      'settings.tray.tokensTotal': '總 Tokens（1.36B）',
      'settings.tray.costTotal': '總成本（$8.28）',
      'settings.tray.bothTotal': '總 Tokens + 成本（1.36B - $8.28）',
      'settings.tray.barsSession': '額度條：單次剩餘最少',
      'settings.tray.barsWeekly': '額度條：週期剩餘最少',
      'settings.tray.barsAllSessions': '額度條：前兩個工具的單次額度',
      'settings.tray.barsWindow': '額度條：任一額度剩餘最少',
      'settings.tray.iconOnly': '只顯示圖示',
      'settings.startup.title': '啟動',
      'settings.startup.startAtLogin': '登入時啟動',
      'settings.startup.available': '僅在打包後的 macOS 和 Windows 版本可用。',
      'settings.startup.launchAtSignIn': '登入系統時啟動 Token Monitor。',
      'settings.appearance.title': '外觀',
      'settings.appearance.systemGlass': '系統玻璃效果',
      'settings.appearance.liveIndicator': '即時指示器',
      'settings.appearance.toolIcons': '工具圖示',
      'settings.appearance.titleIcon': '標題改用圖示',
      'settings.appearance.settingsInTitlebar': '設定鈕放回標題列',
      'settings.appearance.glass': '玻璃',
      'settings.appearance.depth': '深度',
      'settings.appearance.zoom': '縮放',
      'settings.appearance.resetGlass': '重設玻璃效果',
      'settings.appearance.resetDepth': '重設深度',
      'settings.appearance.resetZoom': '重設縮放',
      'settings.appearance.themeTitle': '介面主題',
      'settings.appearance.vendorTitle': '廠商色',
      'settings.appearance.vendorNote': '覆寫每個工具在圖表與清單的顏色。重設即回到品牌色。',
      'settings.appearance.vendorDefault': '其他工具',
      'settings.appearance.resetAll': '全部重設',
      'settings.appearance.resetBrand': '重設回品牌色',
      'settings.appearance.resetColor': '重設顏色',
      'settings.appearance.custom': '自訂',
      'settings.appearance.preset.default': '預設',
      'settings.appearance.preset.obsidian': '黑曜',
      'settings.appearance.preset.porcelain': '瓷白',
      'settings.appearance.color.accent': '強調色',
      'settings.appearance.color.bg': '背景',
      'settings.appearance.color.text': '文字',
      'settings.appearance.color.muted': '次要文字',
      'settings.integrations.title': '整合',
      'settings.integrations.discord': 'Discord Rich Presence',
      'settings.appUpdate.title': '應用程式更新',
      'settings.appUpdate.source': 'GitHub releases',
      'settings.appUpdate.installed': '已安裝',
      'settings.appUpdate.latest': '最新版本',
      'settings.appUpdate.check': '檢查更新',
      'settings.appUpdate.viewRelease': '查看 release',
      'settings.appUpdate.upToDate': '已是最新',
      'settings.appUpdate.upToDateShort': '已是最新',
      'settings.appUpdate.latestWithStatus': 'v{version}（{status}）',
      'settings.appUpdate.checking': '檢查中...',
      'settings.appUpdate.githubError': '無法連接 GitHub',
      'settings.appUpdate.dismiss': '忽略此版本',
      'settings.tokscale.title': 'Tokscale',
      'settings.tokscale.source': '來自 npm 的 CLI 依賴',
      'settings.tokscale.installed': '已安裝',
      'settings.tokscale.bundled': '內建版本',
      'settings.tokscale.npm': 'npm 上版本',
      'settings.tokscale.latestTag': '（latest tag）',
      'settings.tokscale.noteBefore': 'Token Monitor 使用 tokscale（MIT，開源）讀取 token 資料。',
      'settings.tokscale.learnMore': '了解更多',
      'settings.tokscale.checkNpm': '檢查 npm',
      'settings.tokscale.downloadNpm': '從 npm 下載',
      'settings.tokscale.resetBundled': '重設為內建版本',
      'settings.tokscale.downloadedSource': '從 npm 下載',
      'settings.tokscale.downloadedSourceWithAge': '從 npm 下載，{age}',
      'settings.tokscale.bundledSource': '隨此 app 內建',
      'settings.tokscale.currentSuffix': '目前版本',
      'settings.tokscale.checkingNpm': '正在檢查 npm...',
      'settings.tokscale.newerOnNpm': 'npm 上有較新的 tokscale。',
      'settings.tokscale.bundledCurrent': '內建 tokscale 已是最新。',
      'settings.tokscale.downloading': '正在從 npm 下載...',
      'settings.tokscale.downloaded': '已從 npm 下載 {version}。',
      'settings.tokscale.resetting': '正在重設...',
      'settings.tokscale.usingBundled': '正在使用內建 tokscale。',
      'settings.age.justNow': '剛剛',
      'settings.age.minutesAgo': '{minutes} 分鐘前',
      'settings.age.hoursAgo': '{hours} 小時前',
      'settings.age.daysAgo': '{days} 天前',
      'settings.advanced.title': '進階',
      'settings.advanced.note': '其他選項可在這裡調整：',
      'settings.advanced.openConfig': '開啟設定檔',
      'floatingBubble.expand': '顯示 Token Monitor',
      'detailLoading': '載入中…',
      'detailNotFound': '在這台機器上找不到對話紀錄。',
      'detailEmpty': '這段期間沒有活動。',
      'roleYou': '你',
      'sortNewest': '↕ 最新',
      'sortMostTokens': '↕ Token 最多'
    },
    'zh-CN': {
      'settings.language.title': '语言',
      'settings.language.label': '界面语言',
      'settings.language.auto': '自动（跟随系统）',
      'settings.language.english': 'English',
      'settings.language.zhTW': '繁體中文',
      'settings.language.zhCN': '简体中文',
      'settings.sync.title': '多设备同步',
      'settings.sync.localOnly': '仅限本机',
      'settings.sync.localOnlyDesc': '只显示这台设备。',
      'settings.sync.connectHub': '连接到 Hub',
      'settings.sync.connectHubDesc': '把这台设备的用量发送到其他地方的 Hub。',
      'settings.sync.hostHub': '在这台设备托管 Hub',
      'settings.sync.hostHubDesc': '在本机开启 Hub，让其他设备连接。',
      'settings.sync.hubUrl': 'Hub URL',
      'settings.sync.secret': '密钥',
      'settings.sync.secretPlaceholder': '选填的共享密钥',
      'settings.sync.port': '端口',
      'settings.sync.sharedSecret': '共享密钥',
      'settings.sync.copySecret': '复制密钥',
      'settings.sync.regenerateSecret': '重新生成',
      'settings.sync.hostNote': '其他设备可使用上方任一 URL 搭配共享密钥连接。macOS / Windows 第一次可能会询问是否允许传入连接。跨网络使用时，两边都运行 Tailscale 或 ZeroTier，虚拟 IP 的用法相同。',
      'settings.sync.hostWarning': 'Hub 只会在 Token Monitor 运行时工作。退出程序（不只是关闭窗口）会让所有已连接设备的 Hub 停止。',
      'settings.sync.deviceId': '设备 ID',
      'settings.sync.deviceIdPlaceholder': '自动（主机名）',
      'settings.sync.starting': '启动中...',
      'settings.sync.portInUse': '端口 {port} 已被占用',
      'settings.sync.hubStopped': 'Hub 已停止',
      'settings.sync.listening': '正在监听端口 {port}',
      'settings.sync.noLanAddress': '没有检测到 LAN 地址。这台机器上的其他设备可使用 http://127.0.0.1:{port}。',
      'settings.sync.connectWith': '其他设备使用以下地址连接：',
      'settings.sync.copyUrl': '复制 {url}',
      'settings.common.save': '保存',
      'settings.common.refresh': '刷新',
      'settings.common.logout': '登出',
      'settings.common.checking': '检查中...',
      'settings.common.checkingEllipsis': '检查中...',
      'settings.common.notChecked': '尚未检查',
      'settings.common.notFound': '未找到',
      'settings.common.current': '当前版本',
      'settings.common.error': '错误',
      'settings.sections.accounts': '账号',
      'settings.sections.general': '常规',
      'settings.sections.main': '主画面',
      'settings.sections.window': '窗口',
      'settings.sections.collection': '采集',
      'settings.summary.tools': '追踪 {tracked} · 显示 {visible} · 置顶 {pinned}',
      'settings.summary.accounts': '已连接 {linked}/{total}',
      'settings.summary.limits': '启用 {enabled} · {refresh}',
      'settings.summary.views': '{visible}/{total} 显示',
      'settings.summary.general': '登录时启动 {startup} · 更新',
      'settings.summary.appearance': '{theme} · 自定义 {vendors}',
      'settings.summary.on': '开',
      'settings.summary.off': '关',
      'settings.summary.unavailable': '不可用',
      'settings.summary.minutes': '{minutes} 分钟',
      'settings.tools.title': '工具',
      'settings.tools.note': '追踪控制采集；显示只影响主列表。',
      'settings.tools.track': '追踪',
      'settings.tools.show': '显示',
      'settings.tools.trackClient': '追踪 {name}',
      'settings.tools.showClient': '在工具列表显示 {name}',
      'settings.tools.hideClient': '从工具列表隐藏 {name}',
      'settings.tools.pinClient': '置顶 {name}',
      'settings.tools.unpinClient': '取消置顶 {name}',
      'settings.tools.reorderClient': '拖曳排序 {name}。也可用上下键移动。',
      'settings.tools.resetOrder': '重置排序',
      'settings.tools.showAll': '显示全部',
      'settings.tools.status.active': '检测中',
      'settings.tools.status.waiting': '等待数据',
      'settings.tools.status.missing': '未安装',
      'settings.tools.status.signIn': '需登录',
      'settings.tools.status.openApp': '需打开 App',
      'settings.views.title': '主界面',
      'settings.views.note': '调整主界面视图的显示与切换顺序。',
      'settings.views.showView': '显示 {name}',
      'settings.views.hideView': '隐藏 {name}',
      'settings.views.reorderView': '拖曳排序 {name}。也可用上下键移动。',
      'settings.views.resetOrder': '重置排序',
      'settings.views.showAll': '显示全部',
      'settings.views.configureTrend': '设置 {name}',
      'settings.views.enableTrend': '启用趋势',
      'views.tool': '工具',
      'views.status': '状态',
      'views.device': '设备',
      'views.model': '模型',
      'views.session': '会话',
      'views.limits': '额度',
      'views.trends': '趋势',
      'trends.empty': '暂无使用历史',
      'trends.open': '打开仪表板',
      'trends.range.week': '近 7 天',
      'trends.range.month': '本月每日',
      'trends.range.year': '历年每月',
      'trends.activeDays': '活跃天数',
      'trends.currentStreak': '连续天数',
      'trends.longestStreak': '最长连续',
      'trends.peakDay': '峰值单日',
      'dashboard.title': '使用仪表板',
      'dashboard.heatmap.title': 'Token 活动',
      'dashboard.tab.trends': '趋势',
      'dashboard.tab.activity': '总览',
      'dashboard.stack.client': '按工具',
      'dashboard.stack.model': '按模型',
      'dashboard.mode.bars': '柱状图',
      'dashboard.mode.kline': 'K 线',
      'dashboard.range.7': '7 天',
      'dashboard.range.30': '30 天',
      'dashboard.range.90': '90 天',
      'dashboard.range.365': '1 年',
      'dashboard.range.all': '全部',
      'dashboard.empty': '暂无使用历史',
      'dashboard.stat.totalTokens': '总 Token',
      'dashboard.stat.totalCost': '总花费',
      'dashboard.stat.favoriteModel': '常用模型',
      'dashboard.stat.messages': '消息数',
      'dashboard.tooltip.inputCacheHit': '输入 (缓存命中)',
      'dashboard.tooltip.inputCacheMiss': '输入 (缓存未命中)',
      'dashboard.tooltip.output': '输出',
      'serviceStatus.ok': '正常',
      'serviceStatus.degraded': '降级',
      'serviceStatus.outage': '中断',
      'serviceStatus.unknown': '未知',
      'serviceStatus.loading': '检查中...',
      'serviceStatus.notChecked': '尚未检查',
      'serviceStatus.noIssues': '无进行中的问题',
      'serviceStatus.listSeparator': '、',
      'serviceStatus.components': '受影响组件：{count}',
      'serviceStatus.incidents': '事件：{count}',
      'serviceStatus.maintenance': '维护：{count}',
      'serviceStatus.checkedAt': '{time} 检查',
      'serviceStatus.openPage': '打开 {name} status 页',
      'serviceStatus.checkFailed': '状态检查失败',
      'serviceStatus.providersNote': '选择 Status 页显示哪些服务、以及顺序。',
      'serviceStatus.allHidden': '已隐藏所有服务',
      'serviceStatus.expandProviders': '展开 {name} 的服务列表',
      'serviceStatus.configureProviders': '设置 {name} 服务',
      'serviceStatus.reorderProvider': '拖曳重新排序 {name}',
      'serviceStatus.hideProvider': '隐藏 {name}',
      'serviceStatus.showProvider': '显示 {name}',
      'serviceStatus.agoSeconds': '{n} 秒前',
      'serviceStatus.agoMinutes': '{n} 分钟前',
      'serviceStatus.agoHours': '{n} 小时前',
      'serviceStatus.refreshEvery': '检查间隔',
      'serviceStatus.refreshManual': '手动',
      'serviceStatus.refreshMinutes': '{n} 分钟',
      'settings.clientDisplay.title': 'CLI 列表',
      'settings.clientDisplay.note': '只调整主列表的显示和顺序；上方追踪工具才会控制采集。',
      'settings.clientDisplay.moveUp': '将 {name} 在 CLI 列表上移',
      'settings.clientDisplay.moveDown': '将 {name} 在 CLI 列表下移',
      'settings.cursor.title': 'Cursor 账号',
      'settings.cursor.openBrowser': '在浏览器打开 cursor.com',
      'settings.cursor.step1Before': '在浏览器打开',
      'settings.cursor.step1After': '（使用上方按钮）。',
      'settings.cursor.step2Before': '打开 DevTools（F12 或 Cmd+Opt+I）-> Application/Storage -> Cookies ->',
      'settings.cursor.step3Before': '复制',
      'settings.cursor.step3After': '的值。',
      'settings.cursor.step4': '粘贴到下方后点击保存。',
      'settings.cursor.manualPlaceholder': 'WorkosCursorSessionToken=...',
      'settings.cursor.saveToken': '保存 token',
      'settings.cursor.loggedIn': '已登录',
      'settings.cursor.notLoggedIn': '尚未登录',
      'settings.cursor.expired': 'Session 已过期，请重新登录',
      'settings.cursor.billingResets': '账单于 {date} 重置',
      'settings.cursor.statusCheckFailed': '状态检查失败：{message}',
      'settings.cursor.loginRequired': '需要登录才能启用 Cursor',
      'settings.cursor.loginFailed': '登录失败：{message}',
      'settings.opencode.title': 'OpenCode 账号',
      'settings.opencode.openBrowser': '在浏览器打开 OpenCode 登录',
      'settings.opencode.step1Before': '在浏览器打开',
      'settings.opencode.step1After': '（使用上方按钮）并登录。',
      'settings.opencode.step2': '打开 DevTools（F12 或 Cmd+Opt+I）-> Application/Storage -> Cookies -> opencode.ai。',
      'settings.opencode.step3Before': '复制',
      'settings.opencode.step3After': '的值。',
      'settings.opencode.step4': '粘贴到下方后点击保存。',
      'settings.opencode.cookiePlaceholder': 'auth=...',
      'settings.opencode.saveCookie': '保存 cookie',
      'settings.opencode.statusSet': '已设定',
      'settings.opencode.statusNotSet': '尚未设定',
      'settings.opencode.statusLinked': '已连接',
      'settings.opencode.tagZenBalance': 'Zen 余额',
      'settings.opencode.expired': 'Cookie 已过期，请重新连接',
      'settings.opencode.statusCheckFailed': '状态检查失败：{message}',
      'settings.opencode.saveFailed': '连接失败：{message}',
      'settings.deepseek.title': 'DeepSeek 账号',
      'settings.deepseek.openBrowser': '在浏览器打开 DeepSeek API 密钥',
      'settings.deepseek.note': '粘贴 DeepSeek API 密钥。它只保存在本机，仅用于余额 API。',
      'settings.deepseek.apiKeyPlaceholder': 'sk-...',
      'settings.deepseek.saveApiKey': '保存 API 密钥',
      'settings.deepseek.clearApiKey': '清除密钥',
      'settings.deepseek.statusSet': '已设定',
      'settings.deepseek.statusEnv': '来自 .env',
      'settings.deepseek.statusNotSet': '尚未设定',
      'settings.deepseek.statusInvalid': 'API 密钥无效',
      'settings.deepseek.saveFailed': '保存失败：{message}',
      'settings.limits.title': 'AI 工具限制',
      'settings.limits.refresh': '刷新',
      'settings.limits.showSource': '显示来源',
      'settings.limits.moveUp': '将 {name} 上移',
      'settings.limits.moveDown': '将 {name} 下移',
      'settings.limits.reorderProvider': '拖曳排序 {name}。也可用上下键移动。',
      'settings.limits.capability.auto': '自动',
      'settings.limits.capability.oauthCli': 'OAuth/CLI',
      'settings.limits.capability.cliRpc': 'CLI RPC',
      'settings.limits.capability.appCliRpc': 'App/CLI RPC',
      'settings.limits.capability.manualLogin': '手动登录',
      'settings.limits.capability.web': 'Web',
      'settings.limits.capability.appMustBeOpen': '需打开 App 或 CLI',
      'settings.limits.capability.rpc': 'RPC',
      'settings.limits.capability.localZen': 'Local/Zen',
      'settings.limits.status.live': '已检测',
      'settings.limits.status.linked': '已连接',
      'settings.limits.status.signIn': '需登录',
      'settings.limits.status.openApp': '请打开 App 或 CLI',
      'settings.limits.status.noSyncedData': '暂无同步数据',
      'settings.limits.status.stale': '数据过期',
      'settings.limits.status.disabled': '已停用',
      'settings.limits.status.signInAgain': '重新登录',
      'settings.limits.status.limited': '受限',
      'settings.limits.status.usageApiLimited': '来源受限',
      'settings.limits.status.unavailable': '暂不可用',
      'settings.limits.status.notSetUp': '尚未设置',
      'settings.limits.capability.payg': '按量付费',
      'settings.limits.capability.apiKey': 'API 密钥',
      'settings.limits.status.addApiKey': '添加 API 密钥',
      'settings.limits.status.updateApiKey': '更新 API 密钥',
      'settings.limits.status.error': '错误',
      'settings.limits.device.local': '本机',
      'settings.limits.device.from': '来自 {device}',
      'settings.limits.device.localAndSynced': '本机 + {count} 同步',
      'settings.limits.device.localAlso': '本机也有',
      'settings.display.title': '显示模式',
      'settings.display.windowTitle': '窗口',
      'settings.display.presenceTitle': '浮窗与系统托盘',
      'settings.display.windowBehavior': '显示方式',
      'settings.currency.label': '货币',
      'settings.currency.usd': 'USD - 美元',
      'settings.currency.twd': 'TWD - 新台币',
      'settings.currency.hkd': 'HKD - 港币',
      'settings.currency.cny': 'CNY - 人民币',
      'settings.display.windowBehaviorNote': '固定在桌面会让组件留在其他 app 下方，锁定拖动和缩放，但仍可点击操作。',
      'settings.windowBehavior.floating': '浮在其他 app 上方',
      'settings.windowBehavior.normal': '普通窗口',
      'settings.windowBehavior.desktop': '固定在桌面',
      'settings.windowBehavior.buttonTitle': '当前：{current}；点击切换为 {next}',
      'settings.display.floatingBubble': '悬浮小窗',
      'settings.display.floatingBubbleNote': '将组件收成可拖动的窄长小窗，点击即可重新展开。',
      'settings.display.floatingBubbleTrigger': '展开方式',
      'settings.display.floatingBubbleContent': '悬浮球显示',
      'settings.floatingBubbleTrigger.click': '点击',
      'settings.floatingBubbleTrigger.hover': '悬停预览',
      'settings.display.showTrayIcon': '显示托盘／菜单栏图标',
      'settings.display.trayMode': '仅托盘显示',
      'settings.display.trayNote': '隐藏主窗口；改从 macOS 菜单栏或 Windows 系统托盘显示弹窗。',
      'settings.display.trayText': '托盘文字',
      'settings.display.windowShortcut': '快捷键',
      'settings.display.windowShortcutNote': '录制全局快捷键，用来显示或隐藏窗口。',
      'settings.display.windowShortcutListening': '按下快捷键，Esc 取消。',
      'settings.display.windowShortcutInvalid': '请搭配 Ctrl、Cmd 或 Alt。',
      'settings.display.windowShortcutRegistered': '已启用 {shortcut}。',
      'settings.display.windowShortcutConflict': '无法注册 {shortcut}，可能和其他 app 冲突。',
      'settings.shortcut.off': '关闭',
      'settings.shortcut.record': '录制',
      'settings.shortcut.recording': '录制中...',
      'settings.shortcut.clear': '清除',
      'settings.tray.tokensToday': '今日 Tokens（1.2M）',
      'settings.tray.costToday': '今日成本（$1.23）',
      'settings.tray.bothToday': '今日 Tokens + 成本（1.2M - $1.23）',
      'settings.tray.tokensTotal': '总 Tokens（1.36B）',
      'settings.tray.costTotal': '总成本（$8.28）',
      'settings.tray.bothTotal': '总 Tokens + 成本（1.36B - $8.28）',
      'settings.tray.barsSession': '额度条：单次剩余最少',
      'settings.tray.barsWeekly': '额度条：周期剩余最少',
      'settings.tray.barsAllSessions': '额度条：前两个工具的单次额度',
      'settings.tray.barsWindow': '额度条：任一额度剩余最少',
      'settings.tray.iconOnly': '只显示图标',
      'settings.startup.title': '启动',
      'settings.startup.startAtLogin': '登录时启动',
      'settings.startup.available': '仅在打包后的 macOS 和 Windows 版本可用。',
      'settings.startup.launchAtSignIn': '登录系统时启动 Token Monitor。',
      'settings.appearance.title': '外观',
      'settings.appearance.systemGlass': '系统玻璃效果',
      'settings.appearance.liveIndicator': '实时指示器',
      'settings.appearance.toolIcons': '工具图标',
      'settings.appearance.titleIcon': '标题改用图标',
      'settings.appearance.settingsInTitlebar': '设置按钮放回标题栏',
      'settings.appearance.glass': '玻璃',
      'settings.appearance.depth': '深度',
      'settings.appearance.zoom': '缩放',
      'settings.appearance.resetGlass': '重置玻璃效果',
      'settings.appearance.resetDepth': '重置深度',
      'settings.appearance.resetZoom': '重置缩放',
      'settings.appearance.themeTitle': '界面主题',
      'settings.appearance.vendorTitle': '厂商色',
      'settings.appearance.vendorNote': '覆盖每个工具在图表与列表的颜色。重置即回到品牌色。',
      'settings.appearance.vendorDefault': '其他工具',
      'settings.appearance.resetAll': '全部重置',
      'settings.appearance.resetBrand': '重置回品牌色',
      'settings.appearance.resetColor': '重置颜色',
      'settings.appearance.custom': '自定义',
      'settings.appearance.preset.default': '默认',
      'settings.appearance.preset.obsidian': '黑曜',
      'settings.appearance.preset.porcelain': '瓷白',
      'settings.appearance.color.accent': '强调色',
      'settings.appearance.color.bg': '背景',
      'settings.appearance.color.text': '文字',
      'settings.appearance.color.muted': '次要文字',
      'settings.integrations.title': '集成',
      'settings.integrations.discord': 'Discord Rich Presence',
      'settings.appUpdate.title': '应用更新',
      'settings.appUpdate.source': 'GitHub releases',
      'settings.appUpdate.installed': '已安装',
      'settings.appUpdate.latest': '最新版本',
      'settings.appUpdate.check': '检查更新',
      'settings.appUpdate.viewRelease': '查看 release',
      'settings.appUpdate.upToDate': '已是最新',
      'settings.appUpdate.upToDateShort': '已是最新',
      'settings.appUpdate.latestWithStatus': 'v{version}（{status}）',
      'settings.appUpdate.checking': '检查中...',
      'settings.appUpdate.githubError': '无法连接 GitHub',
      'settings.appUpdate.dismiss': '忽略此版本',
      'settings.tokscale.title': 'Tokscale',
      'settings.tokscale.source': '来自 npm 的 CLI 依赖',
      'settings.tokscale.installed': '已安装',
      'settings.tokscale.bundled': '内置版本',
      'settings.tokscale.npm': 'npm 上版本',
      'settings.tokscale.latestTag': '（latest tag）',
      'settings.tokscale.noteBefore': 'Token Monitor 使用 tokscale（MIT，开源）读取 token 数据。',
      'settings.tokscale.learnMore': '了解更多',
      'settings.tokscale.checkNpm': '检查 npm',
      'settings.tokscale.downloadNpm': '从 npm 下载',
      'settings.tokscale.resetBundled': '重置为内置版本',
      'settings.tokscale.downloadedSource': '从 npm 下载',
      'settings.tokscale.downloadedSourceWithAge': '从 npm 下载，{age}',
      'settings.tokscale.bundledSource': '随此 app 内置',
      'settings.tokscale.currentSuffix': '当前版本',
      'settings.tokscale.checkingNpm': '正在检查 npm...',
      'settings.tokscale.newerOnNpm': 'npm 上有较新的 tokscale。',
      'settings.tokscale.bundledCurrent': '内置 tokscale 已是最新。',
      'settings.tokscale.downloading': '正在从 npm 下载...',
      'settings.tokscale.downloaded': '已从 npm 下载 {version}。',
      'settings.tokscale.resetting': '正在重置...',
      'settings.tokscale.usingBundled': '正在使用内置 tokscale。',
      'settings.age.justNow': '刚刚',
      'settings.age.minutesAgo': '{minutes} 分钟前',
      'settings.age.hoursAgo': '{hours} 小时前',
      'settings.age.daysAgo': '{days} 天前',
      'settings.advanced.title': '高级',
      'settings.advanced.note': '其他选项可在这里调整：',
      'settings.advanced.openConfig': '打开配置',
      'floatingBubble.expand': '显示 Token Monitor',
      'detailLoading': '加载中…',
      'detailNotFound': '在这台机器上找不到对话记录。',
      'detailEmpty': '这段时间没有活动。',
      'roleYou': '你',
      'sortNewest': '↕ 最新',
      'sortMostTokens': '↕ Token 最多'
    }
  };

  function localeFromTag(value) {
    const tag = String(value || '').replace(/_/g, '-').trim().toLowerCase();
    if (!tag) return null;
    if (tag === 'zh') return 'zh-TW';
    if (tag.startsWith('zh-hant') || /-(tw|hk|mo)\b/.test(tag)) return 'zh-TW';
    if (tag.startsWith('zh-hans') || /-(cn|sg|my)\b/.test(tag)) return 'zh-CN';
    if (tag === 'zh-tw') return 'zh-TW';
    if (tag === 'zh-cn') return 'zh-CN';
    if (tag === 'en' || tag.startsWith('en-')) return 'en';
    return null;
  }

  function normalizeLanguage(value) {
    const raw = String(value || '').replace(/_/g, '-').trim();
    const lower = raw.toLowerCase();
    if (lower === 'auto') return 'auto';
    return localeFromTag(raw) || 'auto';
  }

  function resolveLocale(language, preferredLanguages) {
    const normalized = normalizeLanguage(language);
    if (normalized !== 'auto') return normalized;
    const languages = Array.isArray(preferredLanguages) ? preferredLanguages : [preferredLanguages];
    for (const item of languages) {
      const locale = localeFromTag(item);
      if (locale) return locale;
    }
    return 'en';
  }

  function translate(locale, key, params = {}) {
    const resolved = normalizeLanguage(locale) === 'auto' ? 'en' : normalizeLanguage(locale);
    const template = MESSAGES[resolved]?.[key] ?? MESSAGES.en[key] ?? key;
    return String(template).replace(/\{([a-zA-Z0-9_]+)\}/g, (_match, name) => {
      return params[name] === undefined || params[name] === null ? '' : String(params[name]);
    });
  }

  function translated(locale, key) {
    return translate(locale, key);
  }

  function applyTranslations(root, locale) {
    const scope = root || (typeof document !== 'undefined' ? document : null);
    if (!scope || typeof scope.querySelectorAll !== 'function') return locale;
    const resolved = normalizeLanguage(locale) === 'auto' ? 'en' : normalizeLanguage(locale);
    const docEl = scope.documentElement || scope.ownerDocument?.documentElement;
    if (docEl?.setAttribute) docEl.setAttribute('lang', resolved);

    for (const el of scope.querySelectorAll('[data-i18n]')) {
      el.textContent = translated(resolved, el.dataset.i18n);
    }
    for (const el of scope.querySelectorAll('[data-i18n-title]')) {
      const text = translated(resolved, el.dataset.i18nTitle);
      el.title = text;
      if (el.setAttribute) el.setAttribute('title', text);
    }
    for (const el of scope.querySelectorAll('[data-i18n-aria-label]')) {
      const text = translated(resolved, el.dataset.i18nAriaLabel);
      if (el.setAttribute) el.setAttribute('aria-label', text);
    }
    for (const el of scope.querySelectorAll('[data-i18n-placeholder]')) {
      const text = translated(resolved, el.dataset.i18nPlaceholder);
      el.placeholder = text;
      if (el.setAttribute) el.setAttribute('placeholder', text);
    }
    return resolved;
  }

  return { LANGUAGE_OPTIONS, MESSAGES, applyTranslations, normalizeLanguage, resolveLocale, translate };
});
