-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
zh dev star guides plugin i18n
插件可以在自己的目录下提供 .astrbot-plugin/i18n/*.json,让 WebUI 根据当前语言显示插件名称、描述和配置项文案。
your_plugin/
metadata.yaml
_conf_schema.json
.astrbot-plugin/
i18n/
zh-CN.json
en-US.json
语言文件名使用 WebUI 的 locale,例如 zh-CN.json、en-US.json。文件内容必须是 JSON object。
当当前语言没有对应翻译、某个字段缺失,或语言文件不存在时,AstrBot 会回退到默认文案:
- 插件名称、卡片短描述和描述回退到
metadata.yaml中的display_name、short_desc、desc。 - 配置项文案回退到
_conf_schema.json中的description、hint、labels。 - Page 文案回退到 Page 目录名、Page 默认标题或页面代码中提供的 fallback。
metadata 用于覆盖插件在插件页展示的名称、卡片短描述和描述。
{
"metadata": {
"display_name": "天气助手",
"short_desc": "一句话天气查询。",
"desc": "查询天气并提供出行建议。"
}
}config 用于覆盖 _conf_schema.json 中的配置文案。结构按配置项名称嵌套。
例如 _conf_schema.json:
{
"enable": {
"description": "Enable",
"type": "bool",
"hint": "Whether to enable this plugin.",
"default": true
},
"mode": {
"description": "Mode",
"type": "string",
"options": ["fast", "safe"],
"labels": ["Fast", "Safe"]
}
}对应 .astrbot-plugin/i18n/zh-CN.json:
{
"config": {
"enable": {
"description": "启用",
"hint": "是否启用这个插件。"
},
"mode": {
"description": "模式",
"labels": ["快速", "安全"]
}
}
}options 是配置保存值,不建议翻译。下拉框的展示文本请使用 labels。
pages 用于覆盖插件 Dashboard Page 的标题、描述和页面内自定义文案。结构按 Page 目录名嵌套。
例如插件页面目录:
pages/
settings/
index.html
对应 .astrbot-plugin/i18n/zh-CN.json:
{
"pages": {
"settings": {
"title": "设置",
"description": "管理这个插件的高级设置。",
"save": "保存",
"reset": "重置"
}
}
}title 会用于 WebUI 外壳标题和插件详情页中的 Page 组件名称,description 会用于插件详情页中的 Page 组件描述。其他字段由页面通过 bridge 自行读取:
const bridge = window.AstrBotPluginPage;
function render() {
document.getElementById("save").textContent = bridge.t(
"pages.settings.save",
"Save",
);
}
await bridge.ready();
render();
bridge.onContext(render);onContext() 用于响应 WebUI 语言切换;监听后通常不需要刷新 Page。
如果 _conf_schema.json 中有 object 类型配置,翻译也按同样的字段结构继续嵌套。
{
"config": {
"sub_config": {
"name": {
"description": "名称",
"hint": "显示在消息中的名称。"
}
}
}
}template_list 的模板名称和模板内字段也可以翻译。模板名称放在 templates.<模板名>.name,模板内字段继续往下嵌套。
{
"config": {
"rules": {
"description": "规则",
"templates": {
"default": {
"name": "默认模板",
"threshold": {
"description": "阈值",
"hint": "达到该值后触发规则。"
}
}
}
}
}
}下面是一个真实配置项的英文翻译示例:
{
"metadata": {
"display_name": "HAPI Vibe Coding Remote",
"desc": "Connect to a HAPI service and control coding agent sessions from chat platforms."
},
"config": {
"hapi_endpoint": {
"description": "HAPI service URL",
"hint": "Example: http://localhost:3006"
},
"output_level": {
"description": "SSE delivery level",
"hint": "silence: permission requests only; simple: plain text messages and system events; summary: recent N messages when a task completes; detail: all messages in real time",
"labels": ["Silence", "Simple", "Summary", "Detail"]
}
}
}插件国际化只读取 .astrbot-plugin/i18n 目录。语言文件必须使用嵌套 JSON 结构,不支持点号扁平 key。
- 首页
- 文档入口
- Top Level
- community events
- deploy
- dev
- others
- platform
- 接入 OneBot v11 协议实现
- 接入钉钉 DingTalk
- 接入 Discord
- 接入 Kook
- 接入飞书
- 接入 LINE
- 接入 Matrix
- 接入 Mattermost
- 接入 Misskey 平台
- 接入 QQ 官方机器人平台
- 通过 QQ官方机器人 接入 QQ (Webhook)
- 通过 QQ官方机器人 接入 QQ (Websockets)
- 接入 Satori 协议
- 接入 server-satori (基于 Koishi)
- 接入 Slack
- 接入消息平台
- 接入 Telegram
- 接入 VoceChat
- AstrBot 接入企业微信
- 接入企业微信智能机器人平台
- AstrBot 接入微信公众平台
- 接入个人微信
- providers
- use
- Home
- Docs Entry
- Top Level
- config
- deploy
- Deploy AstrBot on 1Panel
- Deploy AstrBot on BT Panel
- Deploy AstrBot on CasaOS
- Deploy AstrBot from Source Code
- Community-Provided Deployment Methods
- Deploy via Compshare
- Deploy with AstrBot Desktop Client
- Deploy AstrBot with Docker
- Deploy AstrBot with Kubernetes
- Deploy AstrBot with AstrBot Launcher
- Other Deployments
- Package Manager Deployment (uv)
- Installation via System Package Manager
- Preface
- dev
- AstrBot Configuration File
- AstrBot HTTP API
- Developing a Platform Adapter
- plugin
- AI
- Text to Image
- Handling Message Events
- Plugin Configuration
- Plugin Internationalization
- Plugin Pages
- Sending Messages
- Session Control
- Minimal Example
- Plugin Storage
- AstrBot Plugin Development Guide 🌠
- Publishing Plugins to the Plugin Marketplace
- ospp
- others
- platform
- Connect OneBot v11 Protocol Implementations
- Connect to DingTalk
- Connecting to Discord
- Connect to KOOK
- Connecting to Lark
- Connecting to LINE
- Connecting to Matrix
- Connecting to Mattermost
- Connecting to Misskey Platform
- Connect QQ Official Bot
- Connect QQ via QQ Official Bot (Webhook)
- Connect QQ via QQ Official Bot (Websockets)
- Connect to Satori Protocol
- Connect server-satori (Koishi)
- Connecting to Slack
- Messaging Platforms
- Connecting to Telegram
- Connect to VoceChat
- Connect AstrBot to WeCom
- Connect to WeCom AI Bot Platform
- Connect AstrBot to WeChat Official Account Platform
- Connect Personal WeChat
- providers
- Connect 302.AI
- Agent Runners
- Built-in Agent Runner
- Connect to Coze
- Connect to Alibaba Cloud Bailian Application
- Connect to DeerFlow
- Connect to Dify
- Connect AIHubMix
- coze
- dashscope
- dify
- 大语言模型提供商
- NewAPI
- Connect PPIO Cloud
- Connect LM Studio to Use DeepSeek-R1 and Other Models
- Integrating Ollama
- Connecting to SiliconFlow
- Connecting Model Services
- Connecting to TokenPony
- use
- Agent Runner
- Agent Sandbox Environment ⛵️
- astrbot sandbox
- Docker-based Code Interpreter
- Built-in Commands
- Computer Use
- Context Compression
- Custom Rules
- Function Calling
- AstrBot Knowledge Base
- MCP
- AstrBot Star
- Proactive Capabilities
- Anthropic Skills
- Agent Handoff and SubAgent
- Unified Webhook Mode
- Web Search
- WebUI