From 28a2d25ce0967d73fa26a9dce99e40d06b92aace Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Wed, 29 Apr 2020 13:53:26 +0800 Subject: [PATCH] i18n --- .../main/java/io/metersphere/service/UserService.java | 11 ++++++----- .../java/io/metersphere/service/WorkspaceService.java | 2 +- .../src/main/resources/i18n/messages_en_US.properties | 7 ++++++- .../src/main/resources/i18n/messages_zh_CN.properties | 7 ++++++- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index dc7246aa0a..0e95828e6c 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -15,6 +15,7 @@ import io.metersphere.dto.OrganizationMemberDTO; import io.metersphere.dto.UserDTO; import io.metersphere.dto.UserRoleDTO; import io.metersphere.dto.UserRoleHelpDTO; +import io.metersphere.i18n.Translator; import io.metersphere.user.SessionUser; import io.metersphere.user.SessionUtils; import org.apache.commons.lang3.StringUtils; @@ -54,11 +55,11 @@ public class UserService { private void checkUserParam(User user) { if (StringUtils.isBlank(user.getName())) { - MSException.throwException("user_name_empty"); + MSException.throwException(Translator.get("user_name_is_null")); } if (StringUtils.isBlank(user.getEmail())) { - MSException.throwException("user_email_empty"); + MSException.throwException(Translator.get("user_email_is_null")); } // password } @@ -76,7 +77,7 @@ public class UserService { criteria.andEmailEqualTo(user.getEmail()); List userList = userMapper.selectByExample(userExample); if (!CollectionUtils.isEmpty(userList)) { - MSException.throwException("user_email_is_exist"); + MSException.throwException(Translator.get("user_email_already_exists")); } userMapper.insertSelective(user); } @@ -325,10 +326,10 @@ public class UserService { public boolean checkUserPassword(String userId, String password) { if (StringUtils.isBlank(userId)) { - MSException.throwException("Username cannot be null"); + MSException.throwException(Translator.get("user_name_is_null")); } if (StringUtils.isBlank(password)) { - MSException.throwException("Password cannot be null"); + MSException.throwException(Translator.get("password_is_null")); } UserExample example = new UserExample(); example.createCriteria().andIdEqualTo(userId).andPasswordEqualTo(CodingUtil.md5(password)); diff --git a/backend/src/main/java/io/metersphere/service/WorkspaceService.java b/backend/src/main/java/io/metersphere/service/WorkspaceService.java index 7956a9f90c..99e3f228f9 100644 --- a/backend/src/main/java/io/metersphere/service/WorkspaceService.java +++ b/backend/src/main/java/io/metersphere/service/WorkspaceService.java @@ -150,7 +150,7 @@ public class WorkspaceService { WorkspaceExample example = new WorkspaceExample(); example.createCriteria().andIdEqualTo(workspaceId); if (workspaceMapper.countByExample(example) == 0) { - MSException.throwException("workspace_not_exist"); + MSException.throwException(Translator.get("workspace_not_exists")); } } diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 97c25ebe9c..5dcf8e7cb9 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -23,4 +23,9 @@ max_thread_insufficient=The number of concurrent users exceeds cannot_edit_load_test_running=Cannot modify the running test test_not_found=Test cannot be found: test_not_running=Test is not running -before_delete_plan=There is an associated test case under this plan, please unlink it first! \ No newline at end of file +before_delete_plan=There is an associated test case under this plan, please unlink it first! +user_email_already_exists=User email already exists +user_name_is_null=User name cannot be null +user_email_is_null=User email cannot be null +password_is_null=Password cannot be null +workspace_not_exists=Workspace is not exists \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 150bd0d446..4203e0043e 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -23,4 +23,9 @@ max_thread_insufficient=并发用户数超额 cannot_edit_load_test_running=不能修改正在运行的测试 test_not_found=测试不存在: test_not_running=测试未运行 -before_delete_plan=该计划下存在关联测试用例,请先取消关联! \ No newline at end of file +before_delete_plan=该计划下存在关联测试用例,请先取消关联! +user_email_already_exists=用户邮箱已存在 +user_name_is_null=用户名不能为空 +user_email_is_null=用户邮箱不能为空 +password_is_null=密码不能为空 +workspace_not_exists=工作空间不存在 \ No newline at end of file