Skip to content

feat(il10n): introduce localization support#25

Merged
HalfSweet merged 1 commit intoOpenSiFli:mainfrom
bakacai:feat/l10n
Feb 4, 2026
Merged

feat(il10n): introduce localization support#25
HalfSweet merged 1 commit intoOpenSiFli:mainfrom
bakacai:feat/l10n

Conversation

@bakacai
Copy link
Contributor

@bakacai bakacai commented Feb 4, 2026

No description provided.

Copilot AI review requested due to automatic review settings February 4, 2026 08:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 l10n directory and bundle files for English and Chinese
  • Replaced all hardcoded Chinese strings with vscode.l10n.t() calls throughout the codebase
  • Updated package.json to 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 @@
{
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title contains a typo: "il10n" should be "i18n" (internationalization). The standard abbreviation is "i18n" (i + 18 letters + n), not "il10n".

Copilot uses AI. Check for mistakes.
"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}",
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"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}",

Copilot uses AI. Check for mistakes.
"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}",
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"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}",

Copilot uses AI. Check for mistakes.
Comment on lines +42 to +43
vscode.l10n.t("probe-rs doesn't seem to be installed. Do you want to install it automatically now?"),
installLabel
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
);
this.currentSdkVersionStatusItem.text = 'SDK: N/A';
this.currentSdkVersionStatusItem.tooltip = '点击切换 SiFli SDK 版本';
this.currentSdkVersionStatusItem.text = vscode.l10n.t('SDK: {0}', vscode.l10n.t('N/A'));
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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'));
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
99
);
this.currentSerialPortStatusItem.text = '$(plug) COM: N/A';
this.currentSerialPortStatusItem.text = vscode.l10n.t('$(plug) COM: {0}', vscode.l10n.t('N/A'));
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +57 to +59
"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",
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"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",

Copilot uses AI. Check for mistakes.

void (async () => {
if (!(await probeRsInstalled())) {
const installLabel = vscode.l10n.t('Install');
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
);

if (resp === 'Install') {
if (resp === installLabel) {
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@HalfSweet HalfSweet merged commit a594e5e into OpenSiFli:main Feb 4, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants