fix: 尝试修复发布之后国际化消息不能正常显示的问题

This commit is contained in:
CaptainB 2024-02-01 10:28:47 +08:00 committed by 刘瑞斌
parent db5182f37d
commit 6c0f1b50ed
1 changed files with 5 additions and 6 deletions

View File

@ -84,13 +84,11 @@ public class NoticeSendService {
private static void setLanguage(NoticeModel noticeModel) { private static void setLanguage(NoticeModel noticeModel) {
String language = (String) noticeModel.getParamMap().get("Language"); String language = (String) noticeModel.getParamMap().get("Language");
if (StringUtils.isBlank(language)) { Locale locale = Locale.SIMPLIFIED_CHINESE;
language = "zh_CN"; if (StringUtils.isNotBlank(language)) {
locale = Locale.forLanguageTag(language);
} }
if (language.contains("-")) { LocaleContextHolder.setLocale(locale);
language = language.replace("-","_");
}
LocaleContextHolder.setLocale(Locale.of(language));
} }
/** /**
@ -144,4 +142,5 @@ public class NoticeSendService {
LogUtils.error(e.getMessage(), e); LogUtils.error(e.getMessage(), e);
} }
} }
} }