diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/notice/sender/AfterReturningNoticeSendService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/notice/sender/AfterReturningNoticeSendService.java index 0e68cfb25a..46332b6ccb 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/notice/sender/AfterReturningNoticeSendService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/notice/sender/AfterReturningNoticeSendService.java @@ -10,6 +10,7 @@ import io.metersphere.system.service.NoticeSendService; import io.metersphere.system.service.SystemParameterService; import jakarta.annotation.Resource; import org.apache.commons.lang3.StringUtils; +import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; @@ -24,7 +25,7 @@ public class AfterReturningNoticeSendService { @Async public void sendNotice(String taskType, String event, List resources, SessionUser sessionUser, String currentProjectId) { - + setLanguage(sessionUser.getLanguage()); // 有批量操作发送多次 BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo(); for (Map resource : resources) { @@ -73,6 +74,16 @@ public class AfterReturningNoticeSendService { return defaultTemplateTitleMap.get(taskType + "_" + event); } + private static void setLanguage(String language) { + Locale locale = Locale.SIMPLIFIED_CHINESE; + if (StringUtils.containsIgnoreCase("US",language)) { + locale = Locale.US; + } else if (StringUtils.containsIgnoreCase("TW",language)){ + locale = Locale.TAIWAN; + } + LocaleContextHolder.setLocale(locale); + } + /** * 有些默认的值,避免通知里出现 ${key}