feat(il10n): introduce localization support#25
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces localization (internationalization) support to the SiFli SDK CodeKit VS Code extension using VS Code's native l10n API. The implementation adds English and Simplified Chinese translations for all user-facing strings.
Changes:
- Added localization infrastructure with
l10ndirectory and bundle files for English and Chinese - Replaced all hardcoded Chinese strings with
vscode.l10n.t()calls throughout the codebase - Updated
package.jsonto use localized strings for commands, views, and configuration descriptions
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Added l10n directory reference and replaced hardcoded strings with localization keys |
| package.nls.json | English localization bundle for package.json metadata |
| package.nls.zh-cn.json | Chinese localization bundle for package.json metadata |
| l10n/bundle.l10n.json | English runtime message bundle |
| l10n/bundle.l10n.zh-cn.json | Chinese runtime message bundle |
| src/services/*.ts | Replaced Chinese user-facing messages with localized strings |
| src/providers/*.ts | Replaced Chinese UI strings with localized strings |
| src/commands/*.ts | Replaced Chinese command messages with localized strings |
| src/probe-rs/extension.ts | Added localization for probe-rs debugger messages |
| src/extension.ts | Localized release notes dialog |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -1,12 +1,13 @@ | |||
| { | |||
There was a problem hiding this comment.
The PR title contains a typo: "il10n" should be "i18n" (internationalization). The standard abbreviation is "i18n" (i + 18 letters + n), not "il10n".
| "Select download baud rate (current: {0})": "Select download baud rate (current: {0})", | ||
| "Monitor baud rate: {0}": "Monitor baud rate: {0}", | ||
| "Select monitor baud rate (current: {0})": "Select monitor baud rate (current: {0})", | ||
| "Serial port configured: {0}\\nDownload baud rate: {1}\\nMonitor baud rate: {2}": "Serial port configured: {0}\\nDownload baud rate: {1}\\nMonitor baud rate: {2}", |
There was a problem hiding this comment.
The localization bundle files use escaped newlines (\\n) but the source code uses regular newlines (\n). This creates a mismatch - the bundle keys won't match the actual calls. The bundle files should use single backslash \n to match the source code, not double backslash \\n.
| "Serial port configured: {0}\\nDownload baud rate: {1}\\nMonitor baud rate: {2}": "Serial port configured: {0}\\nDownload baud rate: {1}\\nMonitor baud rate: {2}", | |
| "Serial port configured: {0}\nDownload baud rate: {1}\nMonitor baud rate: {2}": "Serial port configured: {0}\nDownload baud rate: {1}\nMonitor baud rate: {2}", |
| "Select download baud rate (current: {0})": "选择下载波特率(当前:{0})", | ||
| "Monitor baud rate: {0}": "监视波特率:{0}", | ||
| "Select monitor baud rate (current: {0})": "选择监视波特率(当前:{0})", | ||
| "Serial port configured: {0}\\nDownload baud rate: {1}\\nMonitor baud rate: {2}": "已配置串口:{0}\\n下载波特率:{1}\\n监视波特率:{2}", |
There was a problem hiding this comment.
The localization bundle files use escaped newlines (\\n) but the source code uses regular newlines (\n). This creates a mismatch - the bundle keys won't match the actual calls. The bundle files should use single backslash \n to match the source code, not double backslash \\n.
| "Serial port configured: {0}\\nDownload baud rate: {1}\\nMonitor baud rate: {2}": "已配置串口:{0}\\n下载波特率:{1}\\n监视波特率:{2}", | |
| "Serial port configured: {0}\nDownload baud rate: {1}\nMonitor baud rate: {2}": "已配置串口:{0}\n下载波特率:{1}\n监视波特率:{2}", |
| vscode.l10n.t("probe-rs doesn't seem to be installed. Do you want to install it automatically now?"), | ||
| installLabel |
There was a problem hiding this comment.
Inconsistent indentation: this line appears to use extra spaces or tabs that don't align with the surrounding code. The line should be aligned consistently with the rest of the function call.
| ); | ||
| this.currentSdkVersionStatusItem.text = 'SDK: N/A'; | ||
| this.currentSdkVersionStatusItem.tooltip = '点击切换 SiFli SDK 版本'; | ||
| this.currentSdkVersionStatusItem.text = vscode.l10n.t('SDK: {0}', vscode.l10n.t('N/A')); |
There was a problem hiding this comment.
Nested localization calls are problematic here. The vscode.l10n.t('N/A') inside vscode.l10n.t('SDK: {0}', ...) creates an unnecessary nested lookup. Instead, define notAvailable first (as done in line 156 of the updateStatusBarItems method) and use it directly, or have the bundle contain the complete string with "N/A" already included.
| 100 | ||
| ); | ||
| this.currentBoardStatusItem.text = '$(circuit-board) SiFli Board: N/A'; | ||
| this.currentBoardStatusItem.text = vscode.l10n.t('$(circuit-board) SiFli Board: {0}', vscode.l10n.t('N/A')); |
There was a problem hiding this comment.
Nested localization calls are problematic here. The vscode.l10n.t('N/A') inside vscode.l10n.t('$(circuit-board) SiFli Board: {0}', ...) creates an unnecessary nested lookup. Instead, define notAvailable first (as done in line 156 of the updateStatusBarItems method) and use it directly, or have the bundle contain the complete string with "N/A" already included.
| 99 | ||
| ); | ||
| this.currentSerialPortStatusItem.text = '$(plug) COM: N/A'; | ||
| this.currentSerialPortStatusItem.text = vscode.l10n.t('$(plug) COM: {0}', vscode.l10n.t('N/A')); |
There was a problem hiding this comment.
Nested localization calls are problematic here. The vscode.l10n.t('N/A') inside vscode.l10n.t('$(plug) COM: {0}', ...) creates an unnecessary nested lookup. Instead, define notAvailable first (as done in line 156 of the updateStatusBarItems method) and use it directly, or have the bundle contain the complete string with "N/A" already included.
| "Current SiFli board: {0}\\nBuild threads: J{1}\\nClick to change board or threads": "Current SiFli board: {0}\\nBuild threads: J{1}\\nClick to change board or threads", | ||
| "Current serial port: {0}\\nDownload baud rate: {1}\\nMonitor baud rate: {2}\\nClick to configure serial port": "Current serial port: {0}\\nDownload baud rate: {1}\\nMonitor baud rate: {2}\\nClick to configure serial port", | ||
| "Current SiFli SDK version: {0}\\nClick to switch SDK version": "Current SiFli SDK version: {0}\\nClick to switch SDK version", |
There was a problem hiding this comment.
The localization bundle files use escaped newlines (\\n) but the source code uses regular newlines (\n). This creates a mismatch - the bundle keys won't match the actual calls. The bundle files should use single backslash \n to match the source code, not double backslash \\n.
| "Current SiFli board: {0}\\nBuild threads: J{1}\\nClick to change board or threads": "Current SiFli board: {0}\\nBuild threads: J{1}\\nClick to change board or threads", | |
| "Current serial port: {0}\\nDownload baud rate: {1}\\nMonitor baud rate: {2}\\nClick to configure serial port": "Current serial port: {0}\\nDownload baud rate: {1}\\nMonitor baud rate: {2}\\nClick to configure serial port", | |
| "Current SiFli SDK version: {0}\\nClick to switch SDK version": "Current SiFli SDK version: {0}\\nClick to switch SDK version", | |
| "Current SiFli board: {0}\nBuild threads: J{1}\nClick to change board or threads": "Current SiFli board: {0}\nBuild threads: J{1}\nClick to change board or threads", | |
| "Current serial port: {0}\nDownload baud rate: {1}\nMonitor baud rate: {2}\nClick to configure serial port": "Current serial port: {0}\nDownload baud rate: {1}\nMonitor baud rate: {2}\nClick to configure serial port", | |
| "Current SiFli SDK version: {0}\nClick to switch SDK version": "Current SiFli SDK version: {0}\nClick to switch SDK version", |
|
|
||
| void (async () => { | ||
| if (!(await probeRsInstalled())) { | ||
| const installLabel = vscode.l10n.t('Install'); |
There was a problem hiding this comment.
Inconsistent indentation: this line appears to use extra spaces or tabs that don't align with the surrounding code. The line should be aligned with the declaration on line 41 above it.
| ); | ||
|
|
||
| if (resp === 'Install') { | ||
| if (resp === installLabel) { |
There was a problem hiding this comment.
Inconsistent indentation: this line appears to use extra spaces or tabs that don't align with the surrounding code. The condition should be aligned consistently with the rest of the if statement.
No description provided.