Skip to content

feat(builtin_commands): add multi-language support for /help command#8134

Open
oujunhaoyueling wants to merge 1 commit intoAstrBotDevs:masterfrom
oujunhaoyueling:feat/help-multilang
Open

feat(builtin_commands): add multi-language support for /help command#8134
oujunhaoyueling wants to merge 1 commit intoAstrBotDevs:masterfrom
oujunhaoyueling:feat/help-multilang

Conversation

@oujunhaoyueling
Copy link
Copy Markdown

@oujunhaoyueling oujunhaoyueling commented May 10, 2026

Screenshots or Test Results / 运行截图或测试结果

image image

Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Add configurable multi-language support for the /help built-in command and resolve a cron manager type issue when registering the send_message_to_user tool.

New Features:

  • Introduce a configurable help_language option for the built-in commands plugin to localize /help output.
  • Add translations for built-in command descriptions and help texts in English, Simplified Chinese, Traditional Chinese, and Russian.

Bug Fixes:

  • Fix type usage in cron manager by looking up the send_message_to_user builtin tool by its string identifier instead of the tool class.

Enhancements:

  • Wire plugin configuration into the builtin HelpCommand so it can render localized messages based on the selected language.

- Add help_language config option with 4 language choices (en-US, zh-CN, zh-TW, ru-RU)
- Add i18n translations for command descriptions
- Add new i18n files for zh-TW and ru-RU
- Fix type error in cron manager get_builtin_tool call
@auto-assign auto-assign Bot requested review from Fridemn and Soulter May 10, 2026 07:26
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. feature:plugin The bug / feature is about AstrBot plugin system. labels May 10, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider normalizing/validating help_language once in HelpCommand.__init__ (e.g., falling back to a known default if the config value is invalid) instead of relying on TRANSLATIONS.get in each lookup.
  • The large TRANSLATIONS dict hardcodes strings in Python; it may be cleaner and more consistent with the rest of the plugin to load these from the existing i18n JSON files or a separate resource module so translations can be extended without touching code.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider normalizing/validating `help_language` once in `HelpCommand.__init__` (e.g., falling back to a known default if the config value is invalid) instead of relying on `TRANSLATIONS.get` in each lookup.
- The large `TRANSLATIONS` dict hardcodes strings in Python; it may be cleaner and more consistent with the rest of the plugin to load these from the existing i18n JSON files or a separate resource module so translations can be extended without touching code.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces multi-language support for built-in commands, primarily focusing on the /help command. It adds i18n configuration files for English, Russian, and Chinese, and updates the HelpCommand logic to handle localized descriptions. Feedback suggests using neutral keys in translation files instead of Chinese characters and leveraging the existing JSON-based i18n system rather than hardcoding translation dictionaries in the source code. Additionally, a regression was noted where internal commands are no longer filtered from the help output, and it is recommended to restore this exclusion.

},
"config": {
"builtin_commands": {
"配置": "Config"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using a Chinese string as a key in an English i18n file is inconsistent. It is recommended to use a neutral, English-based key (e.g., "config_title") across all translation files to maintain consistency and avoid encoding issues.

Comment on lines +9 to +74
TRANSLATIONS = {
"en-US": {
"no_commands": "No enabled built-in commands.",
"version_format": "AstrBot v{version}(WebUI: {dashboard_version})",
"commands": {
"help": "Show help message",
"sid": "Get session ID and other related information",
"reset": "Reset conversation history",
"stop": "Stop agent execution",
"new": "Create new conversation",
"stats": "Show token usage statistics for the current conversation",
"provider": "View or switch LLM Provider",
"dashboard_update": "Update AstrBot WebUI",
"set": "Set session variable",
"unset": "Unset session variable",
},
},
"zh-CN": {
"no_commands": "没有启用的内置指令。",
"version_format": "AstrBot v{version}(WebUI: {dashboard_version})",
"commands": {
"help": "显示帮助信息",
"sid": "获取会话ID和其他相关信息",
"reset": "重置对话历史",
"stop": "停止Agent执行",
"new": "创建新对话",
"stats": "显示当前对话的Token使用统计",
"provider": "查看或切换LLM提供商",
"dashboard_update": "更新AstrBot WebUI",
"set": "设置会话变量",
"unset": "取消设置会话变量",
},
},
"zh-TW": {
"no_commands": "沒有啟用的內建指令。",
"version_format": "AstrBot v{version}(WebUI: {dashboard_version})",
"commands": {
"help": "顯示幫助信息",
"sid": "獲取會話ID和其他相關信息",
"reset": "重置對話歷史",
"stop": "停止Agent執行",
"new": "創建新對話",
"stats": "顯示當前對話的Token使用統計",
"provider": "查看或切換LLM提供商",
"dashboard_update": "更新AstrBot WebUI",
"set": "設置會話變量",
"unset": "取消設置會話變量",
},
},
"ru-RU": {
"no_commands": "Нет включенных встроенных команд.",
"version_format": "AstrBot v{version}(WebUI: {dashboard_version})",
"commands": {
"help": "Показать справку",
"sid": "Получить ID сессии и другую информацию",
"reset": "Сбросить историю диалога",
"stop": "Остановить выполнение агента",
"new": "Создать новый диалог",
"stats": "Показать статистику использования токенов",
"provider": "Просмотр или смена провайдера LLM",
"dashboard_update": "Обновить AstrBot WebUI",
"set": "Установить переменную сессии",
"unset": "Сбросить переменную сессии",
},
},
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Hardcoding a large translation dictionary directly in the source code is discouraged as it makes maintenance and adding new languages more difficult. Since the plugin already utilizes JSON-based i18n files in the .astrbot-plugin/i18n/ directory, consider leveraging the existing i18n system to manage these strings.

Comment on lines +116 to 117
if not effective:
continue
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The previous logic specifically excluded several internal commands (set, unset, help, dashboard_update) from the help list to keep the output clean. This exclusion has been removed, which will cause these commands to appear in the /help response. If this change was unintentional, please restore the filtering.

Suggested change
if not effective:
continue
if not effective or effective in ["set", "unset", "help", "dashboard_update"]:
continue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature:plugin The bug / feature is about AstrBot plugin system. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant