From 54e28cad1a3f7b181ec72d153a05f2fb3ef646d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=94=E6=B0=91=E5=B0=8F=E9=95=87?= <262610965@qq.com> Date: Wed, 2 Oct 2024 10:52:54 +0800 Subject: [PATCH] :whale: #376 Partial i18n of business framework --- .../skeleton/core/BarSkeletonSetting.java | 2 +- .../action/skeleton/core/PrintActionKit.java | 44 +++++++++------ .../core/flow/internal/DebugInOut.java | 52 +++++++++++++----- .../action/skeleton/core/runner/Runners.java | 3 +- .../eventbus/InternalAboutEventBus.java | 5 +- .../game/action/skeleton/i18n/Bundle.java | 54 +++++++++++++++++++ .../game/action/skeleton/i18n/MessageKey.java | 45 ++++++++++++++++ .../action/skeleton/kit/RangeBroadcast.java | 3 +- .../src/main/resources/iohao.properties | 17 ++++++ .../src/main/resources/iohao_zh_CN.properties | 17 ++++++ .../game/action/skeleton/i18n/BundleTest.java | 41 ++++++++++++++ .../broker/client/ext/ExternalBizRegions.java | 3 +- .../micro/join/ExternalJoinSelectors.java | 3 +- .../core/netty/DefaultExternalCore.java | 13 +++-- .../core/client/BrokerClientBuilder.java | 2 +- .../external/client/InputCommandCreate.java | 3 +- .../game/external/client/kit/ScannerKit.java | 9 ++-- 17 files changed, 273 insertions(+), 43 deletions(-) create mode 100644 common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/Bundle.java create mode 100644 common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/MessageKey.java create mode 100644 common/common-core/src/main/resources/iohao.properties create mode 100644 common/common-core/src/main/resources/iohao_zh_CN.properties create mode 100644 common/common-core/src/test/java/com/iohao/game/action/skeleton/i18n/BundleTest.java diff --git a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/BarSkeletonSetting.java b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/BarSkeletonSetting.java index 1d89ed4fc..e47476303 100644 --- a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/BarSkeletonSetting.java +++ b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/BarSkeletonSetting.java @@ -57,7 +57,7 @@ public final class BarSkeletonSetting { boolean printDataCodec = true; /** true runners 日志打印 */ - boolean printRunners = true; + boolean printRunners = false; /** inOut 的 in 。 true 开启 */ @Deprecated diff --git a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/PrintActionKit.java b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/PrintActionKit.java index f9b6c532c..bd1de225e 100644 --- a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/PrintActionKit.java +++ b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/PrintActionKit.java @@ -22,6 +22,8 @@ import com.iohao.game.action.skeleton.core.codec.DataCodec; import com.iohao.game.action.skeleton.core.flow.ActionMethodInOut; import com.iohao.game.action.skeleton.core.runner.Runners; +import com.iohao.game.action.skeleton.i18n.MessageKey; +import com.iohao.game.action.skeleton.i18n.Bundle; import com.iohao.game.action.skeleton.toy.IoGameBanner; import com.iohao.game.common.kit.ArrayKit; import com.iohao.game.common.kit.StrKit; @@ -78,7 +80,9 @@ private static void extractedRunners(BarSkeleton barSkeleton) { List nameList = runners.listRunnerName(); String title = "@|CYAN ======================== Runners ========================= |@"; IoGameBanner.println(Ansi.ansi().render(title)); - IoGameBanner.println("如果需要关闭打印, 查看 BarSkeletonBuilder#setting#printRunners"); + + var printActionKitClose = Bundle.getMessage(MessageKey.printActionKitPrintClose); + IoGameBanner.println(printActionKitClose + " BarSkeletonBuilder.setting.printRunners"); for (String name : nameList) { String info = String.format("@|BLUE %s |@", name); @@ -94,7 +98,9 @@ private static void extractedRunners(BarSkeleton barSkeleton) { void printInout(List inOuts) { String title = "@|CYAN ======================== InOut ========================= |@"; IoGameBanner.println(Ansi.ansi().render(title)); - IoGameBanner.println("如果需要关闭打印, 查看 BarSkeletonBuilder#setting#printInout"); + + var printActionKitClose = Bundle.getMessage(MessageKey.printActionKitPrintClose); + IoGameBanner.println(printActionKitClose + " BarSkeletonBuilder.setting.printInout"); for (ActionMethodInOut inOut : inOuts) { String info = String.format("@|BLUE %s |@", inOut.getClass()); @@ -103,7 +109,7 @@ void printInout(List inOuts) { } void printHandler(List handlers) { - String iohaoTitle = "@|CYAN ======================== 业务框架 iohao ========================= |@"; + String iohaoTitle = "@|CYAN ======================== iohao ========================= |@"; IoGameBanner.println(Ansi.ansi().render(iohaoTitle)); IoGameBanner.println(IoGameVersion.VERSION); String colorStr = "@|BLACK BLACK|@ @|RED RED|@ @|GREEN GREEN|@ @|YELLOW YELLOW|@ @|BLUE BLUE|@ @|MAGENTA MAGENTA|@ @|CYAN CYAN|@ @|WHITE WHITE|@ @|DEFAULT DEFAULT|@"; @@ -111,7 +117,9 @@ void printHandler(List handlers) { String title = "@|CYAN ======================== Handler ========================= |@"; IoGameBanner.println(Ansi.ansi().render(title)); - IoGameBanner.println("如果需要关闭打印, 查看 BarSkeletonBuilder#setting#printHandler"); + + var printActionKitClose = Bundle.getMessage(MessageKey.printActionKitPrintClose); + IoGameBanner.println(printActionKitClose + " BarSkeletonBuilder.setting.printHandler"); for (Handler handler : handlers) { String info = String.format("@|BLUE %s |@", handler.getClass()); @@ -123,11 +131,13 @@ void printActionCommand(ActionCommand[][] behaviors, boolean shortName) { String title = "@|CYAN ======================== action ========================= |@"; IoGameBanner.println(Ansi.ansi().render(title)); - String tip = """ - 如果需要关闭打印, 查看 BarSkeletonBuilder#setting#printAction; - 如需要打印(class method params return)完整的包名, 查看 BarSkeletonBuilder#setting#printActionShort; - """; - IoGameBanner.print(tip); + var printActionKitClose = Bundle.getMessage(MessageKey.printActionKitPrintClose); + IoGameBanner.println(printActionKitClose + " BarSkeletonBuilder.setting.printAction"); + + var printActionKitPrintFull = Bundle.getMessage(MessageKey.printActionKitPrintFull); + IoGameBanner.println(printActionKitPrintFull + " BarSkeletonBuilder.setting.printActionShort"); + + String cmdName = Bundle.getMessage(MessageKey.cmdName); for (int cmd = 0; cmd < behaviors.length; cmd++) { ActionCommand[] subBehaviors = behaviors[cmd]; @@ -179,7 +189,7 @@ void printActionCommand(ActionCommand[][] behaviors, boolean shortName) { params.put("actionSimpleName", subBehavior.getActionControllerClazz().getSimpleName()); params.put("lineNumber", subBehavior.actionCommandDoc.getLineNumber()); - String routeCell = Color.red.format("路由: {cmd} - {subCmd}", params); + String routeCell = Color.red.format(cmdName + ": {cmd} - {subCmd}", params); String actionCell = Color.white.wrap("--- action :"); String actionNameCell = Color.blue.format("{actionName}", params); String methodNameCell = Color.blue.format("{methodName}", params); @@ -206,12 +216,14 @@ void printActionCommand(ActionCommand[][] behaviors, boolean shortName) { } void printDataCodec() { - DataCodec dataCodec = DataCodecKit.dataCodec; - - String title = "@|CYAN ======================== 当前使用的编解码器 ========================= |@"; + var printActionKitDataCodec = Bundle.getMessage(MessageKey.printActionKitDataCodec); + String title = "@|CYAN ======================== %s ========================= |@".formatted(printActionKitDataCodec); IoGameBanner.println(Ansi.ansi().render(title)); - IoGameBanner.println("如果需要关闭打印, 查看 BarSkeletonBuilder#setting#printDataCodec"); + var printActionKitClose = Bundle.getMessage(MessageKey.printActionKitPrintClose); + IoGameBanner.println(printActionKitClose + " BarSkeletonBuilder.setting.printDataCodec"); + + DataCodec dataCodec = DataCodecKit.dataCodec; String info = String.format("@|BLUE %s - %s |@", dataCodec.codecName(), dataCodec.getClass().getName()); IoGameBanner.println(Ansi.ansi().render(info)); @@ -232,7 +244,9 @@ private void shortName(Map params, boolean shortName) { private void checkReturnType(final Class returnTypeClazz) { if (Set.class.isAssignableFrom(returnTypeClazz) || Map.class.isAssignableFrom(returnTypeClazz)) { // 参数的不支持不写逻辑了,这里告诉一下就行了。看之后的需要在考虑是否支持吧 - ThrowKit.ofRuntimeException("action 返回值和参数不支持 set、map 和 基础类型!"); + // Action return values and parameters do not support set, map and basic types! + var printActionKitCheckReturnType = Bundle.getMessage(MessageKey.printActionKitCheckReturnType); + ThrowKit.ofRuntimeException(printActionKitCheckReturnType); } } diff --git a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/flow/internal/DebugInOut.java b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/flow/internal/DebugInOut.java index 127e1e4b8..4aff27ba2 100644 --- a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/flow/internal/DebugInOut.java +++ b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/flow/internal/DebugInOut.java @@ -27,6 +27,8 @@ import com.iohao.game.action.skeleton.core.flow.ActionMethodInOut; import com.iohao.game.action.skeleton.core.flow.FlowContext; import com.iohao.game.action.skeleton.core.flow.attr.FlowAttr; +import com.iohao.game.action.skeleton.i18n.Bundle; +import com.iohao.game.action.skeleton.i18n.MessageKey; import com.iohao.game.action.skeleton.protocol.HeadMetadata; import com.iohao.game.action.skeleton.protocol.ResponseMessage; import com.iohao.game.action.skeleton.protocol.wrapper.ByteValueList; @@ -173,6 +175,8 @@ public void fuckOut(final FlowContext flowContext) { ResponseMessage responseMessage = flowContext.getResponse(); + extractedI18n(paramMap); + if (responseMessage.hasError()) { this.printValidate(flowContext, paramMap); } else { @@ -180,6 +184,26 @@ public void fuckOut(final FlowContext flowContext) { } } + private static void extractedI18n(Map paramMap) { + String debugInOutThreadName = Bundle.getMessage(MessageKey.debugInOutThreadName); + paramMap.put(MessageKey.debugInOutThreadName, debugInOutThreadName); + + String debugInOutParamName = Bundle.getMessage(MessageKey.debugInOutParamName); + paramMap.put(MessageKey.debugInOutParamName, debugInOutParamName); + + String debugInOutReturnData = Bundle.getMessage(MessageKey.debugInOutReturnData); + paramMap.put(MessageKey.debugInOutReturnData, debugInOutReturnData); + + String debugInOutErrorCode = Bundle.getMessage(MessageKey.debugInOutErrorCode); + paramMap.put(MessageKey.debugInOutErrorCode, debugInOutErrorCode); + + String debugInOutErrorMsg = Bundle.getMessage(MessageKey.debugInOutErrorMsg); + paramMap.put(MessageKey.debugInOutErrorMsg, debugInOutErrorMsg); + + String debugInOutTime = Bundle.getMessage(MessageKey.debugInOutTime); + paramMap.put(MessageKey.debugInOutTime, debugInOutTime); + } + private static void extractedTraceId(FlowContext flowContext, Map paramMap) { HeadMetadata headMetadata = flowContext.getHeadMetadata(); String traceId = headMetadata.getTraceId(); @@ -197,10 +221,12 @@ private static void extractedJoin(FlowContext flowContext, Map p HeadMetadata headMetadata = flowContext.getHeadMetadata(); int stick = headMetadata.getStick(); + String connectionWay = Bundle.getMessage(MessageKey.connectionWay); + String str = switch (stick) { - case 1 -> " [连接方式:TCP] "; - case 2 -> " [连接方式:WebSocket] "; - case 3 -> " [连接方式:UDP] "; + case 1 -> " [%s:TCP] ".formatted(connectionWay); + case 2 -> " [%s:WebSocket] ".formatted(connectionWay); + case 3 -> " [%s:UDP] ".formatted(connectionWay); default -> ""; }; @@ -218,13 +244,13 @@ private void printValidate(FlowContext flowContext, Map paramMap } String template = """ - ┏━━错误━━━ Debug. [({className}.java:{lineNumber}).{actionMethodName}] ━━━ {cmdInfo} ━━━ [{logicServerTag}] ━━━ [id:{logicServerId}] + ┏━━━━━ Error. [({className}.java:{lineNumber}).{actionMethodName}] ━━━ {cmdInfo} ━━━ [{logicServerTag}] ━━━ [id:{logicServerId}] ┣ userId: {userId} - ┣ 参数: {paramName} : {paramData} - ┣ 错误码: {errorCode} - ┣ 错误信息: {validatorMsg} - ┣ 时间: {time} ms (业务方法总耗时) - ┗━━━━━ [ioGame:{ioGameVersion}] ━━━━━ [线程:{threadName}] ━━━━━{joinName}━━━━━{traceId}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + ┣ {debugInOutParamName}: {paramName} : {paramData} + ┣ {debugInOutErrorCode}: {errorCode} + ┣ {debugInOutErrorMsg}: {validatorMsg} + ┣ {debugInOutTime}: {time} ms + ┗━━━━━ [ioGame:{ioGameVersion}] ━━━━━ [{debugInOutThreadName}:{threadName}] ━━━━━{joinName}━━━━━{traceId}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ """; String message = StrKit.format(template, paramMap); @@ -243,10 +269,10 @@ private void printNormal(FlowContext flowContext, Map paramMap) String template = """ ┏━━━━━ Debug. [({className}.java:{lineNumber}).{actionMethodName}] ━━━━━ {cmdInfo} ━━━━━ [{logicServerTag}] ━━━━━ [id:{logicServerId}] ┣ userId: {userId} - ┣ 参数: {paramName} : {paramData} - ┣ 响应: {returnData} - ┣ 时间: {time} ms (业务方法总耗时) - ┗━━━━━ [ioGame:{ioGameVersion}] ━━━━━ [线程:{threadName}] ━━━━━{joinName}━━━━━{traceId}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + ┣ {debugInOutParamName}: {paramName} : {paramData} + ┣ {debugInOutReturnData}: {returnData} + ┣ {debugInOutTime}: {time} ms + ┗━━━━━ [ioGame:{ioGameVersion}] ━━━━━ [{debugInOutThreadName}:{threadName}] ━━━━━{joinName}━━━━━{traceId}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ """; String message = StrKit.format(template, paramMap); diff --git a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/runner/Runners.java b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/runner/Runners.java index 84acdd313..6fccf673f 100644 --- a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/runner/Runners.java +++ b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/runner/Runners.java @@ -56,7 +56,8 @@ public Runners() { public void addRunner(Runner runner) { if (this.onStart.get()) { - ThrowKit.ofRuntimeException("运行中,不能添加 Runner 了"); + // 运行中,不能添加 Runner 了。 + ThrowKit.ofRuntimeException("Cannot add Runner while running."); } Objects.requireNonNull(runner); diff --git a/common/common-core/src/main/java/com/iohao/game/action/skeleton/eventbus/InternalAboutEventBus.java b/common/common-core/src/main/java/com/iohao/game/action/skeleton/eventbus/InternalAboutEventBus.java index 593e86f7f..db9bba1f0 100644 --- a/common/common-core/src/main/java/com/iohao/game/action/skeleton/eventbus/InternalAboutEventBus.java +++ b/common/common-core/src/main/java/com/iohao/game/action/skeleton/eventbus/InternalAboutEventBus.java @@ -405,7 +405,7 @@ void register(Object eventBusSubscriber, SubscriberInvokeCreator subscriberInvok Class clazz = eventBusSubscriber.getClass(); if (!eventBusSubscriberSet.add(clazz)) { - ThrowKit.ofRuntimeException("已经存在 " + clazz); + ThrowKit.ofRuntimeException("Already exists : " + clazz); } // 方法访问器: 获取类中自己定义的方法 @@ -528,7 +528,8 @@ final class DefaultEventBus implements EventBus { public void register(Object eventBusSubscriber) { if (status != EventBusStatus.register) { - ThrowKit.ofRuntimeException("运行中不允许注册订阅者,请在 EventRunner.registerEventBus 方法中注册。 "); + // 运行中不允许注册订阅者,请在 EventRunner.registerEventBus 方法中注册。 + ThrowKit.ofRuntimeException("Subscriber registration is not allowed during running. Please register in EventRunner.registerEventBus method."); } // 注册 diff --git a/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/Bundle.java b/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/Bundle.java new file mode 100644 index 000000000..7869109b9 --- /dev/null +++ b/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/Bundle.java @@ -0,0 +1,54 @@ +/* + * ioGame + * Copyright (C) 2021 - present 渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved. + * # iohao.com . 渔民小镇 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +package com.iohao.game.action.skeleton.i18n; + +import lombok.experimental.UtilityClass; + +import java.text.MessageFormat; +import java.util.Locale; +import java.util.Objects; +import java.util.ResourceBundle; + +/** + * @author 渔民小镇 + * @date 2024-10-02 + * @since 21.18 + */ +@UtilityClass +public final class Bundle { + final String baseName = "iohao"; + ResourceBundle bundle; + + ResourceBundle getBundle() { + if (Objects.isNull(bundle)) { + bundle = ResourceBundle.getBundle(baseName, Locale.getDefault()); + } + + return bundle; + } + + public String getMessage(String key) { + return getBundle().getString(key); + } + + public String getMessage(String key, Object... args) { + var keyPattern = getBundle().getString(key); + return MessageFormat.format(keyPattern, args); + } +} diff --git a/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/MessageKey.java b/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/MessageKey.java new file mode 100644 index 000000000..d599b8cf6 --- /dev/null +++ b/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/MessageKey.java @@ -0,0 +1,45 @@ +/* + * ioGame + * Copyright (C) 2021 - present 渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved. + * # iohao.com . 渔民小镇 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General License for more details. + * + * You should have received a copy of the GNU Affero General License + * along with this program. If not, see . + */ +package com.iohao.game.action.skeleton.i18n; + +/** + * @author 渔民小镇 + * @date 2024-10-02 + * @since 21.18 + */ +public interface MessageKey { + String cmdName = "cmdName"; + String gameExternalServer = "gameExternalServer"; + /** ExternalJoinEnum */ + String connectionWay = "connectionWay"; + + /* see PrintActionKit.java */ + String printActionKitPrintClose = "printActionKitPrintClose"; + String printActionKitPrintFull = "printActionKitPrintFull"; + String printActionKitDataCodec = "printActionKitDataCodec"; + String printActionKitCheckReturnType = "printActionKitCheckReturnType"; + + /* see DebugInOut.java */ + String debugInOutThreadName = "debugInOutThreadName"; + String debugInOutParamName = "debugInOutParamName"; + String debugInOutReturnData = "debugInOutReturnData"; + String debugInOutErrorCode = "debugInOutErrorCode"; + String debugInOutErrorMsg = "debugInOutErrorMsg"; + String debugInOutTime = "debugInOutTime"; +} diff --git a/common/common-core/src/main/java/com/iohao/game/action/skeleton/kit/RangeBroadcast.java b/common/common-core/src/main/java/com/iohao/game/action/skeleton/kit/RangeBroadcast.java index 4b81ee546..23db033a0 100644 --- a/common/common-core/src/main/java/com/iohao/game/action/skeleton/kit/RangeBroadcast.java +++ b/common/common-core/src/main/java/com/iohao/game/action/skeleton/kit/RangeBroadcast.java @@ -272,7 +272,8 @@ protected void trick() { protected void broadcast() { boolean emptyUser = CollKit.isEmpty(this.userIds); if (checkEmptyUser && emptyUser) { - ThrowKit.ofRuntimeException("没有添加消息推送人"); + // 请添加消息推送人 + ThrowKit.ofRuntimeException("Please add a message sender"); } // 推送响应(广播消息)给指定的用户列表 diff --git a/common/common-core/src/main/resources/iohao.properties b/common/common-core/src/main/resources/iohao.properties new file mode 100644 index 000000000..eb04297aa --- /dev/null +++ b/common/common-core/src/main/resources/iohao.properties @@ -0,0 +1,17 @@ +# common +gameExternalServer=GameExternalServer +cmdName=Routing +# ExternalJoinEnum +connectionWay=Connection way +# see PrintActionKit.java +printActionKitPrintClose=To turn off printing, see +printActionKitPrintFull=Print the full package name, see +printActionKitDataCodec=DataCodec +printActionKitCheckReturnType=Action return values and parameters do not support set, map and basic types! +# see DebugInOut.java +debugInOutThreadName=Thread +debugInOutParamName=RequestParam +debugInOutReturnData=ResponseData +debugInOutErrorCode=ErrorCode +debugInOutErrorMsg=ErrorMsg +debugInOutTime=ExecutionTime diff --git a/common/common-core/src/main/resources/iohao_zh_CN.properties b/common/common-core/src/main/resources/iohao_zh_CN.properties new file mode 100644 index 000000000..f727975f0 --- /dev/null +++ b/common/common-core/src/main/resources/iohao_zh_CN.properties @@ -0,0 +1,17 @@ +# common +gameExternalServer=\u6E38\u620F\u5BF9\u5916\u670D +cmdName=\u8DEF\u7531 +# ExternalJoinEnum +connectionWay=\u8FDE\u63A5\u65B9\u5F0F +# see PrintActionKit.java +printActionKitPrintClose=\u5173\u95ED\u6253\u5370, \u67E5\u770B +printActionKitPrintFull=\u6253\u5370\u5B8C\u6574\u5305\u540D, \u67E5\u770B +printActionKitDataCodec=\u5F53\u524D\u4F7F\u7528\u7684\u7F16\u89E3\u7801\u5668 +printActionKitCheckReturnType=action \u8FD4\u56DE\u503C\u548C\u53C2\u6570\u4E0D\u652F\u6301 set\u3001map \u548C \u57FA\u7840\u7C7B\u578B! +# see DebugInOut.java +debugInOutThreadName=\u7EBF\u7A0B +debugInOutParamName=\u53C2\u6570 +debugInOutReturnData=\u54CD\u5E94 +debugInOutErrorCode=\u9519\u8BEF\u7801 +debugInOutErrorMsg=\u9519\u8BEF\u4FE1\u606F +debugInOutTime=\u8017\u65F6 diff --git a/common/common-core/src/test/java/com/iohao/game/action/skeleton/i18n/BundleTest.java b/common/common-core/src/test/java/com/iohao/game/action/skeleton/i18n/BundleTest.java new file mode 100644 index 000000000..4008d9e2b --- /dev/null +++ b/common/common-core/src/test/java/com/iohao/game/action/skeleton/i18n/BundleTest.java @@ -0,0 +1,41 @@ +package com.iohao.game.action.skeleton.i18n; + +import com.iohao.game.action.skeleton.toy.IoGameBanner; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Locale; +import java.util.ResourceBundle; + +/** + * @author 渔民小镇 + * @date 2024-10-02 + * @since 21.18 + */ +public class BundleTest { + + @Test + public void getMessage() { + var b1 = ResourceBundle.getBundle(Bundle.baseName, Locale.getDefault()); + var b2 = ResourceBundle.getBundle(Bundle.baseName, Locale.getDefault()); + + Assert.assertEquals(b1, b2); + + extracted(); + + Locale.setDefault(Locale.US); + extracted(); + } + + private static void extracted() { + System.out.println("------------------"); + + Bundle.bundle = null; + + System.out.println(Locale.getDefault().toString()); + + String value = Bundle.getMessage(MessageKey.printActionKitPrintClose); + IoGameBanner.println(value + " BarSkeletonBuilder.setting.printRunners"); + Assert.assertNotNull(value); + } +} \ No newline at end of file diff --git a/external/external-core/src/main/java/com/iohao/game/external/core/broker/client/ext/ExternalBizRegions.java b/external/external-core/src/main/java/com/iohao/game/external/core/broker/client/ext/ExternalBizRegions.java index 6e7671754..fe56adb3c 100644 --- a/external/external-core/src/main/java/com/iohao/game/external/core/broker/client/ext/ExternalBizRegions.java +++ b/external/external-core/src/main/java/com/iohao/game/external/core/broker/client/ext/ExternalBizRegions.java @@ -54,7 +54,8 @@ public void add(ExternalBizRegion externalBizRegion) { int bizCode = externalBizRegion.getBizCode(); if (regionMap.containsKey(bizCode)) { - ThrowKit.ofRuntimeException("重复添加已经存在的业务码:" + bizCode); + // 重复添加已经存在的业务码 + ThrowKit.ofRuntimeException("Already exists : " + bizCode); } regionMap.put(bizCode, externalBizRegion); diff --git a/external/external-core/src/main/java/com/iohao/game/external/core/micro/join/ExternalJoinSelectors.java b/external/external-core/src/main/java/com/iohao/game/external/core/micro/join/ExternalJoinSelectors.java index 66229cd6b..614cfba90 100644 --- a/external/external-core/src/main/java/com/iohao/game/external/core/micro/join/ExternalJoinSelectors.java +++ b/external/external-core/src/main/java/com/iohao/game/external/core/micro/join/ExternalJoinSelectors.java @@ -53,7 +53,8 @@ public void putIfAbsent(ExternalJoinEnum joinEnum, ExternalJoinSelector joinSele */ public ExternalJoinSelector getExternalJoinSelector(ExternalJoinEnum joinEnum) { if (!map.containsKey(joinEnum)) { - ThrowKit.ofRuntimeException(joinEnum + " 还没有对应的连接实现类"); + // 没有对应的实现类 + ThrowKit.ofRuntimeException(joinEnum + " has no implementation class"); } return map.get(joinEnum); diff --git a/external/external-netty/src/main/java/com/iohao/game/external/core/netty/DefaultExternalCore.java b/external/external-netty/src/main/java/com/iohao/game/external/core/netty/DefaultExternalCore.java index 1acb570c8..1629e7466 100644 --- a/external/external-netty/src/main/java/com/iohao/game/external/core/netty/DefaultExternalCore.java +++ b/external/external-netty/src/main/java/com/iohao/game/external/core/netty/DefaultExternalCore.java @@ -20,6 +20,8 @@ import com.iohao.game.action.skeleton.core.DataCodecKit; import com.iohao.game.action.skeleton.core.codec.ProtoDataCodec; +import com.iohao.game.action.skeleton.i18n.Bundle; +import com.iohao.game.action.skeleton.i18n.MessageKey; import com.iohao.game.bolt.broker.core.common.IoGameGlobalConfig; import com.iohao.game.common.consts.IoGameLogName; import com.iohao.game.common.kit.PresentKit; @@ -63,8 +65,13 @@ public MicroBootstrap createMicroBootstrap() { final int externalCorePort = this.setting.getExternalCorePort(); if (IoGameGlobalConfig.openLog) { - log.info("启动游戏对外服 port: [{}] 连接方式: [{}] " + var gameExternalServerTip = Bundle.getMessage(MessageKey.gameExternalServer); + var connectionWayTip = Bundle.getMessage(MessageKey.connectionWay); + + log.info("{} port: [{}] - {}: [{}] " + , gameExternalServerTip , externalCorePort + , connectionWayTip , setting.getExternalJoinEnum().getName()); } @@ -81,11 +88,11 @@ private void check() { int externalCorePort = setting.getExternalCorePort(); if (externalCorePort <= 0) { - ThrowKit.ofIllegalArgumentException("游戏对外服端口必须 >0 " + externalCorePort); + ThrowKit.ofIllegalArgumentException("The externalServer port must be >0 " + externalCorePort); } Objects.requireNonNull(setting.getExternalJoinEnum() - , "需要设置一种连接方式:" + Arrays.toString(ExternalJoinEnum.values())); + , "Please set a ExternalJoinEnum:" + Arrays.toString(ExternalJoinEnum.values())); } /** diff --git a/net-bolt/bolt-core/src/main/java/com/iohao/game/bolt/broker/core/client/BrokerClientBuilder.java b/net-bolt/bolt-core/src/main/java/com/iohao/game/bolt/broker/core/client/BrokerClientBuilder.java index 9e98e8ece..c40b3f7ab 100644 --- a/net-bolt/bolt-core/src/main/java/com/iohao/game/bolt/broker/core/client/BrokerClientBuilder.java +++ b/net-bolt/bolt-core/src/main/java/com/iohao/game/bolt/broker/core/client/BrokerClientBuilder.java @@ -221,7 +221,7 @@ private void settingDefaultValue() { } if (Objects.isNull(this.appName)) { - ThrowKit.ofRuntimeException("必须设置 appName"); + ThrowKit.ofRuntimeException("Please set the appName"); } if (Objects.isNull(this.tag)) { diff --git a/widget/light-client/src/main/java/com/iohao/game/external/client/InputCommandCreate.java b/widget/light-client/src/main/java/com/iohao/game/external/client/InputCommandCreate.java index 5fa89a1bf..586007948 100644 --- a/widget/light-client/src/main/java/com/iohao/game/external/client/InputCommandCreate.java +++ b/widget/light-client/src/main/java/com/iohao/game/external/client/InputCommandCreate.java @@ -96,7 +96,8 @@ private void extractedChecked(CmdInfo cmdInfo) { var inputName = ClientKit.toInputName(cmdInfo); InputCommand inputCommand = clientUserInputCommands.getInputCommand(inputName); if (Objects.nonNull(inputCommand)) { - ThrowKit.ofRuntimeException("存在重复的路由命令 : " + cmdInfo); + // 存在重复的路由命令 + ThrowKit.ofRuntimeException("There are duplicate routing commands : " + cmdInfo); } } } diff --git a/widget/light-client/src/main/java/com/iohao/game/external/client/kit/ScannerKit.java b/widget/light-client/src/main/java/com/iohao/game/external/client/kit/ScannerKit.java index f42151a7b..8d359c6ca 100644 --- a/widget/light-client/src/main/java/com/iohao/game/external/client/kit/ScannerKit.java +++ b/widget/light-client/src/main/java/com/iohao/game/external/client/kit/ScannerKit.java @@ -71,7 +71,8 @@ public String nextLine(String defaultValue) { */ public String nextLine() { if (ClientUserConfigs.closeScanner) { - ThrowKit.ofRuntimeException("不支持控制台输入"); + // 不支持控制台输入 + ThrowKit.ofRuntimeException("No support for console input"); } return scanner.nextLine(); @@ -101,7 +102,8 @@ public long nextLong(long defaultValue) { */ public long nextLong() { if (ClientUserConfigs.closeScanner) { - ThrowKit.ofRuntimeException("不支持控制台输入"); + // 不支持控制台输入 + ThrowKit.ofRuntimeException("No support for console input"); } String s = ScannerKit.scanner.nextLine(); @@ -132,7 +134,8 @@ public int nextInt(int defaultValue) { */ public int nextInt() { if (ClientUserConfigs.closeScanner) { - ThrowKit.ofRuntimeException("不支持控制台输入"); + // 不支持控制台输入 + ThrowKit.ofRuntimeException("No support for console input"); } String s = ScannerKit.scanner.nextLine();