国际化遗漏

master
hang 2023-10-08 11:33:20 +08:00
parent f4bbd05671
commit 011b588f08
3 changed files with 13 additions and 6 deletions

View File

@ -2,6 +2,7 @@
using IRaCIS.Core.Infrastructure.Extention; using IRaCIS.Core.Infrastructure.Extention;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace IRaCIS.Core.Application.Filter namespace IRaCIS.Core.Application.Filter
@ -9,10 +10,14 @@ namespace IRaCIS.Core.Application.Filter
public class ProjectExceptionFilter : Attribute, IExceptionFilter public class ProjectExceptionFilter : Attribute, IExceptionFilter
{ {
private readonly ILogger<ProjectExceptionFilter> _logger; private readonly ILogger<ProjectExceptionFilter> _logger;
public readonly IStringLocalizer _localizer;
public ProjectExceptionFilter(ILogger<ProjectExceptionFilter> logger)
public ProjectExceptionFilter(ILogger<ProjectExceptionFilter> logger, IStringLocalizer localizer)
{ {
_logger = logger; _logger = logger;
_localizer = localizer;
} }
public void OnException(ExceptionContext context) public void OnException(ExceptionContext context)
{ {
@ -22,7 +27,7 @@ namespace IRaCIS.Core.Application.Filter
{ {
if (context.Exception.GetType().Name == "DbUpdateConcurrencyException") if (context.Exception.GetType().Name == "DbUpdateConcurrencyException")
{ {
context.Result = new JsonResult(ResponseOutput.NotOk("并发更新,当前不允许该操作" + context.Exception.Message)); context.Result = new JsonResult(ResponseOutput.NotOk(_localizer["ProjectException_ConcurrentUpdateNotAllowed"] + context.Exception.Message));
} }
if (context.Exception.GetType() == typeof(BusinessValidationFailedException) || context.Exception.GetType() == typeof(DBSaveFailedException)) if (context.Exception.GetType() == typeof(BusinessValidationFailedException) || context.Exception.GetType() == typeof(DBSaveFailedException))
@ -35,7 +40,7 @@ namespace IRaCIS.Core.Application.Filter
} }
else else
{ {
context.Result = new JsonResult(ResponseOutput.NotOk("当前操作失败,请联系开发人员查看系统日志排查 ", ApiResponseCodeEnum.ProgramException)); context.Result = new JsonResult(ResponseOutput.NotOk(_localizer["Project_ExceptionContactDeveloper"] , ApiResponseCodeEnum.ProgramException));
} }

View File

@ -2,7 +2,7 @@
"RequiredAttribute": "{0} is required", "RequiredAttribute": "{0} is required",
"TrialService_OnlyInInitOrProgress": "Operations are allowed only when the trial state is Initializing or Ongoing.", "TrialService_OnlyInInitOrProgress": "Operations are allowed only when the trial state is Initializing or Ongoing.",
"TrialService_ExistPN": "The same Trial ID already exists", "TrialService_ExistPN": "The same Trial ID already exists",
"SubjectService_ExistSubjectCode": "A patient with the relevant patient ID already exists.", "SubjectService_ExistSubjectCode": "A patient with the relevant patient ID already exists.",
@ -18,7 +18,8 @@
"SystemAnonymization_InvalidGroupOrElement": "Please check whether the element number or group number configured by DicomTag meets the requirements.", "SystemAnonymization_InvalidGroupOrElement": "Please check whether the element number or group number configured by DicomTag meets the requirements.",
"ProjectException_ConcurrentUpdateNotAllowed": "Concurrent update, operation not allowed at this time.",
"Project_ExceptionContactDeveloper": "Your current operation failed, please contact the developer to check the system log for troubleshooting. ",
"User_UsernameExist": "The user name already exists.", "User_UsernameExist": "The user name already exists.",
"User_PhoneDup": "A user with the same phone number already exists in this user type.", "User_PhoneDup": "A user with the same phone number already exists in this user type.",

View File

@ -19,7 +19,8 @@
"SystemAnonymization_InvalidGroupOrElement": "请核对DicomTag 配置的元素号或者组号是否符合要求", "SystemAnonymization_InvalidGroupOrElement": "请核对DicomTag 配置的元素号或者组号是否符合要求",
"ProjectException_ConcurrentUpdateNotAllowed": "并发更新,当前不允许该操作",
"Project_ExceptionContactDeveloper": "您当前的操作失败,请联系开发人员查看系统日志排查",