From 22ff5f0b4b8983160ecef28437c41b82b133996e Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Thu, 4 Jun 2020 15:19:10 +0800 Subject: [PATCH] 'i18n' --- .../metersphere/controller/LoginController.java | 16 ++++++++-------- .../resources/i18n/messages_en_US.properties | 6 +++++- .../resources/i18n/messages_zh_CN.properties | 6 +++++- .../resources/i18n/messages_zh_TW.properties | 4 ++++ 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/io/metersphere/controller/LoginController.java b/backend/src/main/java/io/metersphere/controller/LoginController.java index 92d3cbfc9e..6b01b6cfdb 100644 --- a/backend/src/main/java/io/metersphere/controller/LoginController.java +++ b/backend/src/main/java/io/metersphere/controller/LoginController.java @@ -1,9 +1,9 @@ package io.metersphere.controller; import io.metersphere.base.domain.UserRole; -import io.metersphere.commons.utils.SessionUtils; import io.metersphere.controller.request.LoginRequest; import io.metersphere.dto.UserDTO; +import io.metersphere.i18n.Translator; import io.metersphere.service.UserService; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; @@ -64,22 +64,22 @@ public class LoginController { // 返回 userDTO return ResultHolder.success(subject.getSession().getAttribute("user")); } else { - return ResultHolder.error("login fail"); + return ResultHolder.error(Translator.get("login_fail")); } } catch (ExcessiveAttemptsException e) { - msg = "excessive attempts"; + msg = "excessive_attempts"; } catch (LockedAccountException e) { - msg = "the user has been locked."; + msg = "user_locked"; } catch (DisabledAccountException e) { - msg = "the user has been disabled. "; + msg = "user_has_been_disabled "; } catch (ExpiredCredentialsException e) { - msg = "user expires. "; + msg = "user_expires. "; } catch (AuthenticationException e) { msg = e.getMessage(); } catch (UnauthorizedException e) { - msg = "not authorized. " + e.getMessage(); + msg = "not_authorized" + e.getMessage(); } - return ResultHolder.error(msg); + return ResultHolder.error(Translator.get(msg)); } @GetMapping(value = "/signout") diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 23b199455e..c021488f57 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -100,4 +100,8 @@ api_test_name_already_exists=Test name already exists password_is_incorrect=Incorrect password user_not_exist=user does not exist: user_has_been_disabled=the user has been disabled. -excessive_attempts=Excessive attempts \ No newline at end of file +excessive_attempts=Excessive attempts +user_locked=the user has been locked. +user_expires=user expires. +not_authorized=not authorized. +login_fail=Login fail \ 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 a899cf8073..5c82e94f38 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -103,5 +103,9 @@ password_is_incorrect=密码不正确 user_not_exist=用户不存在: user_has_been_disabled=用户已被禁用 excessive_attempts=操作频繁 -user_has_been_locked +user_locked=用户被锁定 +user_expires=用户过期 +not_authorized=未经授权 + + diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 32d3150c1f..57cbfb51e2 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -101,3 +101,7 @@ password_is_incorrect=密碼不正確 user_not_exist=用戶不存在: user_has_been_disabled.=用戶已被禁用 excessive_attempts=操作頻繁 +user_locked=用戶被鎖定 +user_expires=用戶過期 +not_authorized=未經授權。 +login_fail=登入失敗