Add i18n support for response message (#753)

* feat: i18n support

* Optimize i18n

* Update the locale in the code

* Update the zh-CN file

* Update the en-US file

* Update the reload filter

* Update locale success plugin value

* Fix lint

* Update pydantic error message translation

* Update to minimal implementation

* Fix minimal missing code
This commit is contained in:
Dylan
2025-08-15 19:57:10 +08:00
committed by GitHub
parent 4500dd0128
commit cd48bb4210
16 changed files with 340 additions and 134 deletions
@@ -10,6 +10,7 @@ from backend.app.admin.schema.token import GetLoginToken
from backend.app.admin.schema.user import AddOAuth2UserParam
from backend.app.admin.service.login_log_service import login_log_service
from backend.common.enums import LoginLogStatusType, UserSocialType
from backend.common.i18n import t
from backend.common.security import jwt
from backend.core.conf import settings
from backend.database.db import async_db_session
@@ -113,7 +114,7 @@ class OAuth2Service:
username=sys_user.username,
login_time=timezone.now(),
status=LoginLogStatusType.success.value,
msg='登录成功(OAuth2',
msg=t('success.login.oauth2_success'),
)
background_tasks.add_task(login_log_service.create, **login_log)
await redis_client.delete(f'{settings.CAPTCHA_LOGIN_REDIS_PREFIX}:{request.state.ip}')