From 953cb24a3b29f749944d48555cd962474a96e0ee Mon Sep 17 00:00:00 2001 From: Ivan Li Date: Tue, 8 Jul 2025 22:59:54 +0800 Subject: [PATCH] fix: resolve i18n implementation issues --- src/components/info/board-info-panel.tsx | 4 +-- .../display-info-panel.tsx | 15 ++++---- .../led-strip-test/led-strip-test.tsx | 34 +++++++++---------- .../white-balance/white-balance.tsx | 4 +-- src/i18n/locales/en-US.ts | 23 +++++++++++++ src/i18n/locales/zh-CN.ts | 25 +++++++++++++- src/i18n/types.ts | 23 +++++++++++++ 7 files changed, 100 insertions(+), 28 deletions(-) diff --git a/src/components/info/board-info-panel.tsx b/src/components/info/board-info-panel.tsx index 2c30258..5e9b1fb 100644 --- a/src/components/info/board-info-panel.tsx +++ b/src/components/info/board-info-panel.tsx @@ -23,7 +23,7 @@ export const BoardInfoPanel: Component<{ board: BoardInfo }> = (props) => { } if (props.board.ttl == null) { - return 'timeout'; + return t('info.timeout'); } return ( @@ -39,7 +39,7 @@ export const BoardInfoPanel: Component<{ board: BoardInfo }> = (props) => { } if ('Connecting' in props.board.connect_status) { - return `Connecting (${props.board.connect_status.Connecting.toFixed(0)})`; + return `${t('info.connecting')} (${props.board.connect_status.Connecting.toFixed(0)})`; } }); diff --git a/src/components/led-strip-configuration/display-info-panel.tsx b/src/components/led-strip-configuration/display-info-panel.tsx index f0f0810..02d41bd 100644 --- a/src/components/led-strip-configuration/display-info-panel.tsx +++ b/src/components/led-strip-configuration/display-info-panel.tsx @@ -1,5 +1,6 @@ import { Component, JSX, ParentComponent, splitProps } from 'solid-js'; import { DisplayInfo } from '../../models/display-info.model'; +import { useLanguage } from '../../i18n/index'; type DisplayInfoItemProps = { label: string; @@ -20,26 +21,28 @@ type DisplayInfoPanelProps = { export const DisplayInfoPanel: Component = (props) => { const [localProps, rootProps] = splitProps(props, ['display']); + const { t } = useLanguage(); + return (
- 显示器信息 + {t('displays.displayInfo')} {localProps.display.is_primary && ( -
主显示器
+
{t('displays.isPrimary')}
)}
- + {localProps.display.id} - + ({localProps.display.x}, {localProps.display.y}) - + {localProps.display.width} × {localProps.display.height} - + {localProps.display.scale_factor}×
diff --git a/src/components/led-strip-test/led-strip-test.tsx b/src/components/led-strip-test/led-strip-test.tsx index 5ec1d7a..a6236a9 100644 --- a/src/components/led-strip-test/led-strip-test.tsx +++ b/src/components/led-strip-test/led-strip-test.tsx @@ -191,14 +191,14 @@ export const LedStripTest = () => {
-

LED Strip Testing

+

{t('ledTest.title')}

{/* Hardware Selection */}
{ onInput={(e) => setLedCount(parseInt(e.target.value) || 60)} />
- +
- +
{ startTest(pattern)} disabled={!selectedBoard()} > - Start Test + {t('ledTest.startTestButton')} } > @@ -314,7 +314,7 @@ export const LedStripTest = () => { class="btn btn-error" onClick={() => stopTest()} > - Stop Test + {t('ledTest.stopTest')}
diff --git a/src/components/white-balance/white-balance.tsx b/src/components/white-balance/white-balance.tsx index a1ba100..3b08cc6 100644 --- a/src/components/white-balance/white-balance.tsx +++ b/src/components/white-balance/white-balance.tsx @@ -301,8 +301,8 @@ export const WhiteBalance = () => {
  1. {t('whiteBalance.fullscreenTip')}
  2. {t('whiteBalance.dragTip')}
  3. -
  4. 将RGB控制面板拖拽到合适位置
  5. -
  6. 对比LED灯条颜色与屏幕边缘颜色
  7. +
  8. {t('whiteBalance.dragPanelTip')}
  9. +
  10. {t('whiteBalance.compareColorsTip')}
diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts index b4d6196..cfd159a 100644 --- a/src/i18n/locales/en-US.ts +++ b/src/i18n/locales/en-US.ts @@ -58,6 +58,9 @@ export const enUS: TranslationDict = { deviceCount: 'Device Count', noDevicesFound: 'No Devices Found', checkConnection: 'Please check device connection status', + // Device status + timeout: 'Timeout', + connecting: 'Connecting', }, displays: { @@ -88,6 +91,9 @@ export const enUS: TranslationDict = { currentMode: 'Current Mode', maxMode: 'Max Mode', minMode: 'Min Mode', + // Display info panel specific + id: 'ID', + scale: 'Scale', }, ledConfig: { @@ -169,6 +175,9 @@ export const enUS: TranslationDict = { draggable: 'Draggable', exitFullscreen: 'Exit Fullscreen', notEnabled: 'Not Enabled', + // Missing white balance instructions + dragPanelTip: 'Drag the RGB control panel to a suitable position', + compareColorsTip: 'Compare LED strip colors with screen edge colors', }, ledTest: { @@ -197,6 +206,20 @@ export const enUS: TranslationDict = { singleScan: 'Single Scan', singleScanDesc: 'Light up each LED individually for precise position testing', breathingDesc: 'Breathing effect for the entire LED strip to test overall brightness', + // LED test form labels + ledCount: 'LED Count', + ledType: 'LED Type', + animationSpeed: 'Animation Speed (ms)', + startTestButton: 'Start Test', + // Hardware selection + selectHardwareBoard: 'Select Hardware Board', + devicesFound: 'device(s) found', + searching: 'Searching...', + chooseBoard: 'Choose a board', + noBoardsFound: 'No boards found', + connected: 'Connected', + connecting: 'Connecting', + disconnected: 'Disconnected', }, errors: { diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index 55177b8..ecb9973 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -58,6 +58,9 @@ export const zhCN: TranslationDict = { deviceCount: '设备总数', noDevicesFound: '未发现设备', checkConnection: '请检查设备连接状态', + // Device status + timeout: '超时', + connecting: '连接中', }, displays: { @@ -88,6 +91,9 @@ export const zhCN: TranslationDict = { currentMode: '当前模式', maxMode: '最大模式', minMode: '最小模式', + // Display info panel specific + id: 'ID', + scale: '缩放', }, ledConfig: { @@ -169,10 +175,13 @@ export const zhCN: TranslationDict = { draggable: '可拖拽', exitFullscreen: '退出全屏', notEnabled: '暂未启用', + // Missing white balance instructions + dragPanelTip: '将RGB控制面板拖拽到合适位置', + compareColorsTip: '对比LED灯条颜色与屏幕边缘颜色', }, ledTest: { - title: '灯带测试', + title: 'LED灯带测试', testEffects: '测试效果', staticColor: '静态颜色', rainbow: '彩虹', @@ -197,6 +206,20 @@ export const zhCN: TranslationDict = { singleScan: '单色扫描', singleScanDesc: '单个LED依次点亮,用于精确测试每个LED位置', breathingDesc: '整条灯带呼吸效果,用于测试整体亮度', + // LED test form labels + ledCount: 'LED数量', + ledType: 'LED类型', + animationSpeed: '动画速度 (ms)', + startTestButton: '开始测试', + // Hardware selection + selectHardwareBoard: '选择硬件板', + devicesFound: '个设备', + searching: '搜索中...', + chooseBoard: '选择设备', + noBoardsFound: '未找到设备', + connected: '已连接', + connecting: '连接中', + disconnected: '已断开', }, errors: { diff --git a/src/i18n/types.ts b/src/i18n/types.ts index 517e8db..c03dfc2 100644 --- a/src/i18n/types.ts +++ b/src/i18n/types.ts @@ -61,6 +61,9 @@ export interface TranslationDict { deviceCount: string; noDevicesFound: string; checkConnection: string; + // Device status + timeout: string; + connecting: string; }; // Display page @@ -92,6 +95,9 @@ export interface TranslationDict { currentMode: string; maxMode: string; minMode: string; + // Display info panel specific + id: string; + scale: string; }; // LED Strip Configuration @@ -175,6 +181,9 @@ export interface TranslationDict { draggable: string; exitFullscreen: string; notEnabled: string; + // Missing white balance instructions + dragPanelTip: string; + compareColorsTip: string; }; // LED Test @@ -204,6 +213,20 @@ export interface TranslationDict { singleScan: string; singleScanDesc: string; breathingDesc: string; + // LED test form labels + ledCount: string; + ledType: string; + animationSpeed: string; + startTestButton: string; + // Hardware selection + selectHardwareBoard: string; + devicesFound: string; + searching: string; + chooseBoard: string; + noBoardsFound: string; + connected: string; + connecting: string; + disconnected: string; }; // Error messages