From 343f4ba04b908990c36abfaf6c93eb8eedff08fd Mon Sep 17 00:00:00 2001 From: MiaoWoo Date: Sat, 29 Feb 2020 00:44:11 +0800 Subject: [PATCH] feat: add command error i18n Signed-off-by: MiaoWoo --- packages/api/src/command.ts | 8 ++++---- packages/i18n/languages/en.yml | 2 ++ packages/i18n/languages/zh_cn.yml | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/api/src/command.ts b/packages/api/src/command.ts index 86f25396..6b0011b5 100644 --- a/packages/api/src/command.ts +++ b/packages/api/src/command.ts @@ -33,9 +33,9 @@ export namespace command { try { return executor(sender, command, Java.from(args)); } catch (ex) { - console.console(`§6玩家 §a${sender.name} §6执行 §b${plugin.description.name} §6插件 §d${command} ${Java.from(args).join(' ')} §6命令时发生异常 §4${ex}`); + console.i18n("ms.api.command.execute.error", { sender: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }) console.ex(ex); - console.sender(sender, [`§6执行 §b${plugin.description.name} §6插件 §d${command} ${Java.from(args).join(' ')} §6命令时发生异常`, ...console.stack(ex)]) + console.sender(sender, [i18n.translate("ms.api.command.execute.error", { sender: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }), ...console.stack(ex)]) return true; } } @@ -48,9 +48,9 @@ export namespace command { var complete = tabCompleter(sender, command, Java.from(args)) || []; return this.copyPartialMatches(complete, token); } catch (ex) { - console.console(`§6玩家 §a${sender.name} §6执行 §b${plugin.description.name} §6插件 §d${command} ${Java.from(args).join(' ')} §6补全时发生异常 §4${ex}`); + console.i18n("ms.api.command.tab.completer.error", { sender: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }) console.ex(ex); - console.sender(sender, [`§6执行 §b${plugin.description.name} §6插件 §d${command} ${Java.from(args).join(' ')} §6补全时发生异常 §4${ex}`, ...console.stack(ex)]); + console.sender(sender, [i18n.translate("ms.api.command.tab.completer.error", { sender: sender.name, plugin: plugin.description.name, command, args: Java.from(args).join(' '), ex }), ...console.stack(ex)]); return []; } } diff --git a/packages/i18n/languages/en.yml b/packages/i18n/languages/en.yml index 19ef0768..3c38263e 100644 --- a/packages/i18n/languages/en.yml +++ b/packages/i18n/languages/en.yml @@ -23,6 +23,8 @@ ms.api.event.unregister: "[{name}] unregister event {event}" ms.api.command.register.input.error: "CommandExec Must be a function... Input: {exec}" ms.api.command.register: "[{plugin}] register command {name}({cmd})..." ms.api.command.unregister: "[{plugin}] unregister command {name}..." +ms.api.command.execute.error: "§6Player {player} §6exec §b{plugin} §6Plugin Command §d{command} {args} §6error §4{ex}" +ms.api.command.tab.completer.error: "§6Player {player} §6exec §b{plugin} §6Plugin TabComplete §d{command} {args} §6error §4{ex}" ms.plugin.initialize: "Initialization MiaoScript Plugin System: {plugin} ..." ms.plugin.event.map: "Total {count} {type} Event Mapping Complate..." diff --git a/packages/i18n/languages/zh_cn.yml b/packages/i18n/languages/zh_cn.yml index d22eb7dc..341b2f71 100644 --- a/packages/i18n/languages/zh_cn.yml +++ b/packages/i18n/languages/zh_cn.yml @@ -23,10 +23,12 @@ ms.api.event.unregister: "[{name}] 注销事件 {event}" ms.api.command.register.input.error: "CommandExec 必须为一个函数... 输入: {exec}" ms.api.command.register: "[{plugin}] 注册命令 {name}({cmd})..." ms.api.command.unregister: "[{plugin}] 注销命令 {name}..." +ms.api.command.execute.error: "§6玩家 §a{player} §6执行 §b{plugin} §6插件 §d{command} {args} §6命令时发生异常 §4{ex}" +ms.api.command.tab.completer.error: "§6玩家 §a{player} §6执行 §b{plugin} §6插件 §d{command} {args} §6补全时发生异常 §4{ex}" ms.plugin.initialize: "初始化 MiaoScript 插件系统: {plugin} ..." ms.plugin.event.map: "总计 {count} 个 {type} 事件 映射完成..." -ms.plugin.manager.scan: "在 {folder} 文件夹中扫描插件..." +ms.plugin.manager.scan: "扫描 {folder} 文件夹中插件..." ms.plugin.manager.initialize.error: "§6插件 §b{name} §6初始化错误 §4{ex}" ms.plugin.manager.stage: "{stage} {plugin} 版本 {version} 作者 {author}" ms.plugin.manager.stage.load: "加载"