fix(国际化): 接口返回信息国际化

--user=郭雨琦 接口返回信息国际化
This commit is contained in:
guoyuqi 2021-12-22 16:43:00 +08:00 committed by xiaomeinvG
parent 08d9c80b96
commit 867d6dbd9f
4 changed files with 21 additions and 19 deletions

View File

@ -11,6 +11,7 @@ import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.SessionUtils; import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.EnvironmentGroupRequest; import io.metersphere.controller.request.EnvironmentGroupRequest;
import io.metersphere.dto.EnvironmentGroupDTO; import io.metersphere.dto.EnvironmentGroupDTO;
import io.metersphere.i18n.Translator;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -19,12 +20,14 @@ import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionUtils; import org.mybatis.spring.SqlSessionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; 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; import java.util.stream.Collectors;
/** /**
@ -157,16 +160,9 @@ public class EnvironmentGroupService {
} }
private void checkEnvironmentGroup(EnvironmentGroupRequest request) { private void checkEnvironmentGroup(EnvironmentGroupRequest request) {
Locale locale = LocaleContextHolder.getLocale();
String name = request.getName(); String name = request.getName();
if (StringUtils.isBlank(name)) { if (StringUtils.isBlank(name)) {
if(Locale.US.toString().equalsIgnoreCase(locale.toString())){ MSException.throwException(Translator.get("null_environment_group_name"));
MSException.throwException("environment group name is null.");
}else if(Locale.TRADITIONAL_CHINESE.toString().equalsIgnoreCase(locale.toString())){
MSException.throwException("環境組名稱不存在。");
}else{
MSException.throwException("环境组名称不存在。");
}
} }
EnvironmentGroupExample environmentGroupExample = new EnvironmentGroupExample(); EnvironmentGroupExample environmentGroupExample = new EnvironmentGroupExample();
@ -178,13 +174,7 @@ public class EnvironmentGroupService {
} }
if (environmentGroupMapper.countByExample(environmentGroupExample) > 0) { if (environmentGroupMapper.countByExample(environmentGroupExample) > 0) {
if(Locale.US.toString().equalsIgnoreCase(locale.toString())){ MSException.throwException(Translator.get("environment_group_name")+request.getName()+Translator.get("environment_group_exist"));
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() + " 已存在!");
}
} }
} }

View File

@ -285,6 +285,10 @@ test_case_status=Case status
id_not_rightful=ID is not rightful id_not_rightful=ID is not rightful
# mock # mock
mock_warning=No matching Mock expectation was found mock_warning=No matching Mock expectation was found
zentao_test_type_error=请求方式错误 zentao_test_type_error=invalid Zentao request
#项目报告 #项目报告
enterprise_test_report=Enterprise report 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

View File

@ -284,6 +284,10 @@ test_case_status=用例状态
id_not_rightful=ID 不合法 id_not_rightful=ID 不合法
# mock # mock
mock_warning=未找到匹配的Mock期望 mock_warning=未找到匹配的Mock期望
zentao_test_type_error=invalid Zentao request zentao_test_type_error=无效的 Zentao 请求
#项目报告 #项目报告
enterprise_test_report=项目报告 enterprise_test_report=项目报告
#环境组
null_environment_group_name = 环境组名称不存在
environment_group_name = 环境组名称
environment_group_exist = 已存在

View File

@ -287,3 +287,7 @@ mock_warning=未找到匹配的Mock期望
zentao_test_type_error=請求方式錯誤 zentao_test_type_error=請求方式錯誤
#项目报告 #项目报告
enterprise_test_report=項目報告 enterprise_test_report=項目報告
#环境组
null_environment_group_name = 環境組名稱不存在
environment_group_name = 環境組名稱
environment_group_exist = 已存在