diff --git a/backend/src/main/java/io/metersphere/service/EnvironmentGroupService.java b/backend/src/main/java/io/metersphere/service/EnvironmentGroupService.java index efa5d97b5c..9ddad71015 100644 --- a/backend/src/main/java/io/metersphere/service/EnvironmentGroupService.java +++ b/backend/src/main/java/io/metersphere/service/EnvironmentGroupService.java @@ -11,6 +11,7 @@ import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.SessionUtils; import io.metersphere.controller.request.EnvironmentGroupRequest; import io.metersphere.dto.EnvironmentGroupDTO; +import io.metersphere.i18n.Translator; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; @@ -19,12 +20,14 @@ import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.mybatis.spring.SqlSessionUtils; import org.springframework.beans.BeanUtils; -import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; import java.util.stream.Collectors; /** @@ -157,16 +160,9 @@ public class EnvironmentGroupService { } private void checkEnvironmentGroup(EnvironmentGroupRequest request) { - Locale locale = LocaleContextHolder.getLocale(); String name = request.getName(); if (StringUtils.isBlank(name)) { - if(Locale.US.toString().equalsIgnoreCase(locale.toString())){ - MSException.throwException("environment group name is null."); - }else if(Locale.TRADITIONAL_CHINESE.toString().equalsIgnoreCase(locale.toString())){ - MSException.throwException("環境組名稱不存在。"); - }else{ - MSException.throwException("环境组名称不存在。"); - } + MSException.throwException(Translator.get("null_environment_group_name")); } EnvironmentGroupExample environmentGroupExample = new EnvironmentGroupExample(); @@ -178,13 +174,7 @@ public class EnvironmentGroupService { } if (environmentGroupMapper.countByExample(environmentGroupExample) > 0) { - if(Locale.US.toString().equalsIgnoreCase(locale.toString())){ - MSException.throwException("Environment group name " + request.getName() + " already exists!"); - }else if(Locale.TRADITIONAL_CHINESE.toString().equalsIgnoreCase(locale.toString())){ - MSException.throwException("環境組名稱 " + request.getName() + " 已存在!"); - }else{ - MSException.throwException("环境组名称 " + request.getName() + " 已存在!"); - } + MSException.throwException(Translator.get("environment_group_name")+request.getName()+Translator.get("environment_group_exist")); } } diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 9f48995a84..2aa95b95e6 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -285,6 +285,10 @@ test_case_status=Case status id_not_rightful=ID is not rightful # mock mock_warning=No matching Mock expectation was found -zentao_test_type_error=请求方式错误 +zentao_test_type_error=invalid Zentao request #项目报告 enterprise_test_report=Enterprise report +#环境组 +null_environment_group_name = Environment group name is null +environment_group_name = Environment group name +environment_group_exist = already exists diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index dc06fd2460..5e09e3f76d 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -284,6 +284,10 @@ test_case_status=用例状态 id_not_rightful=ID 不合法 # mock mock_warning=未找到匹配的Mock期望 -zentao_test_type_error=invalid Zentao request +zentao_test_type_error=无效的 Zentao 请求 #项目报告 enterprise_test_report=项目报告 +#环境组 +null_environment_group_name = 环境组名称不存在 +environment_group_name = 环境组名称 +environment_group_exist = 已存在 \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 86c613adfc..b7f0e41ea0 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -287,3 +287,7 @@ mock_warning=未找到匹配的Mock期望 zentao_test_type_error=請求方式錯誤 #项目报告 enterprise_test_report=項目報告 +#环境组 +null_environment_group_name = 環境組名稱不存在 +environment_group_name = 環境組名稱 +environment_group_exist = 已存在 \ No newline at end of file