TASK: 枚举类多语言;

This commit is contained in:
shahaibo
2023-11-23 10:32:33 +08:00
parent 5213b03598
commit ecec69a45e
3 changed files with 23 additions and 7 deletions

View File

@@ -53,7 +53,11 @@ public class BusinessException extends RuntimeException {
return new Locale(Language.valueOf(userInfo.getLanguage()).getValue());
}
private static String getMessageFromResource(String msg, Locale userLocale) {
public static String getMessageFromResource(String msg) {
return getMessageFromResource(msg, getUserLocale());
}
public static String getMessageFromResource(String msg, Locale userLocale) {
try (InputStream inputStream = BusinessException.class.getClassLoader().getResourceAsStream("messages_" + userLocale.getLanguage() + ".properties")) {
if (inputStream != null) {
ResourceBundle bundle = new PropertyResourceBundle(new InputStreamReader(inputStream, StandardCharsets.UTF_8));