From 7d07e18853f6ee4a50e16899a0d01ba36d354faf Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 16 Oct 2024 11:06:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=9D=99=E6=80=81=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=9B=BD=E9=99=85=E5=8C=96=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessFilter/UnifiedApiResultFilter.cs | 2 +- .../ProjectExceptionFilter.cs | 4 +- .../UnifiedApiResultFilter.cs | 2 +- .../MinimalAPI/GlobalExceptionHandler.cs | 4 +- .../Helper/FileStoreHelper.cs | 6 +-- .../Helper/InternationalizationHelper.cs | 10 ++--- .../Helper/SendEmailHelper.cs | 4 +- .../ImageAndDoc/DownloadAndUploadService.cs | 2 +- .../Service/ImageAndDoc/StudyService.cs | 4 +- IRaCIS.Core.Domain/GlobalUsings.cs | 1 + .../ReadingQuestionCriterionTrial.cs | 2 +- IRaCIS.Core.Domain/Trial/Trial.cs | 2 +- .../_IRaCIS/Output/ResponseOutput.cs | 4 +- .../_IRaCIS/_Config/_StaticData.cs | 44 +++++-------------- 14 files changed, 35 insertions(+), 56 deletions(-) diff --git a/IRC.Core.SCP/BusinessFilter/UnifiedApiResultFilter.cs b/IRC.Core.SCP/BusinessFilter/UnifiedApiResultFilter.cs index 4dffb183c..69af4a5f9 100644 --- a/IRC.Core.SCP/BusinessFilter/UnifiedApiResultFilter.cs +++ b/IRC.Core.SCP/BusinessFilter/UnifiedApiResultFilter.cs @@ -77,7 +77,7 @@ namespace IRaCIS.Core.Application.Service.BusinessFilter else if(statusCode != 200&&!(objectResult.Value is IResponseOutput)) { //---程序错误,请联系开发人员。 - var apiResponse = ResponseOutput.NotOk(StaticData.International("UnifiedAPI_ProgramError")); + var apiResponse = ResponseOutput.NotOk(I18n.T("UnifiedAPI_ProgramError")); objectResult.Value = apiResponse; objectResult.DeclaredType = apiResponse.GetType(); diff --git a/IRaCIS.Core.Application/BusinessFilter/LegacyController/ProjectExceptionFilter.cs b/IRaCIS.Core.Application/BusinessFilter/LegacyController/ProjectExceptionFilter.cs index 997aae9c8..444c1dfbd 100644 --- a/IRaCIS.Core.Application/BusinessFilter/LegacyController/ProjectExceptionFilter.cs +++ b/IRaCIS.Core.Application/BusinessFilter/LegacyController/ProjectExceptionFilter.cs @@ -30,9 +30,9 @@ public class ProjectExceptionFilter(ILogger _logger, ISt var info = string.Empty; - if (!string.IsNullOrWhiteSpace(error!.LocalizedKey) && StaticData.Log_Locoalize_Dic.ContainsKey(error!.LocalizedKey)) + if (!string.IsNullOrWhiteSpace(error!.LocalizedKey) && StaticData.Localizer_Dev_Dic.ContainsKey(error!.LocalizedKey)) { - info = $"[{error!.LocalizedKey}]:{StaticData.Log_Locoalize_Dic[error!.LocalizedKey]}"; + info = $"[{error!.LocalizedKey}]:{StaticData.Localizer_Dev_Dic[error!.LocalizedKey]}"; } diff --git a/IRaCIS.Core.Application/BusinessFilter/LegacyController/UnifiedApiResultFilter.cs b/IRaCIS.Core.Application/BusinessFilter/LegacyController/UnifiedApiResultFilter.cs index a1997eabc..bba090181 100644 --- a/IRaCIS.Core.Application/BusinessFilter/LegacyController/UnifiedApiResultFilter.cs +++ b/IRaCIS.Core.Application/BusinessFilter/LegacyController/UnifiedApiResultFilter.cs @@ -83,7 +83,7 @@ public class UnifiedApiResultFilter : Attribute, IAsyncResultFilter else if (statusCode != 200 && !(objectResult.Value is IResponseOutput)) { //---程序错误,请联系开发人员。 - var apiResponse = ResponseOutput.NotOk(StaticData.International("UnifiedAPI_ProgramError")); + var apiResponse = ResponseOutput.NotOk(I18n.T("UnifiedAPI_ProgramError")); objectResult.Value = apiResponse; objectResult.DeclaredType = apiResponse.GetType(); diff --git a/IRaCIS.Core.Application/BusinessFilter/MinimalAPI/GlobalExceptionHandler.cs b/IRaCIS.Core.Application/BusinessFilter/MinimalAPI/GlobalExceptionHandler.cs index 688c2cd24..1cdec4619 100644 --- a/IRaCIS.Core.Application/BusinessFilter/MinimalAPI/GlobalExceptionHandler.cs +++ b/IRaCIS.Core.Application/BusinessFilter/MinimalAPI/GlobalExceptionHandler.cs @@ -39,9 +39,9 @@ public class GlobalExceptionHandler(IStringLocalizer _localizer, ILogger(CacheKeys.TrialTaskStudyUidDBLock(incommand.TrialId, incommand.VisitTaskId, incommand.Study.StudyInstanceUid)) != Guid.Empty) { //---当前已有人正在上传和归档该检查! - return ResponseOutput.NotOk(StaticData.International("UploadDownLoad_ArchiveInProgress")); + return ResponseOutput.NotOk(I18n.T("UploadDownLoad_ArchiveInProgress")); } else { diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs index ce3ab2dbb..3fc485f84 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs @@ -102,7 +102,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc if (cacheValue != Guid.Empty && cacheValue != _userInfo.Id) { //---当前已有人正在上传和归档该检查! - return ResponseOutput.NotOk(StaticData.International("UploadDownLoad_ArchiveInProgress")); + return ResponseOutput.NotOk(I18n.T("UploadDownLoad_ArchiveInProgress")); } else { @@ -134,7 +134,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc if (_fusionCache.GetOrDefault(CacheKeys.TrialStudyUidDBLock(incommand.TrialId, incommand.Study.StudyInstanceUid)) != Guid.Empty) { //---当前已有人正在上传和归档该检查! - return ResponseOutput.NotOk(StaticData.International("UploadDownLoad_ArchiveInProgress")); + return ResponseOutput.NotOk(I18n.T("UploadDownLoad_ArchiveInProgress")); } else { diff --git a/IRaCIS.Core.Domain/GlobalUsings.cs b/IRaCIS.Core.Domain/GlobalUsings.cs index c7a91c2b9..8970cf57c 100644 --- a/IRaCIS.Core.Domain/GlobalUsings.cs +++ b/IRaCIS.Core.Domain/GlobalUsings.cs @@ -4,3 +4,4 @@ global using System; global using System.Collections.Generic; global using System.ComponentModel.DataAnnotations; global using System.ComponentModel.DataAnnotations.Schema; +global using IRaCIS.Core.Infrastructure.Extention; diff --git a/IRaCIS.Core.Domain/Reading/ReadingCriterion/ReadingQuestionCriterionTrial.cs b/IRaCIS.Core.Domain/Reading/ReadingCriterion/ReadingQuestionCriterionTrial.cs index 51e0a0d57..3a2d77ac4 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingCriterion/ReadingQuestionCriterionTrial.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingCriterion/ReadingQuestionCriterionTrial.cs @@ -62,7 +62,7 @@ public class ReadingQuestionCriterionTrial : BaseAddAuditEntity [Comment("全局阅片评估更新类型")] public string GlobalUpdateType { get; set; } = string.Empty; [Comment("评估原因")] - public string EvaluationReason { get; set; } = StaticData.International("CriterionTrial_EvaluationReason"); + public string EvaluationReason { get; set; } = I18n.T("CriterionTrial_EvaluationReason"); [Comment("是否显示详情")] public bool IsShowDetail { get; set; } = true; diff --git a/IRaCIS.Core.Domain/Trial/Trial.cs b/IRaCIS.Core.Domain/Trial/Trial.cs index d112c6cf7..cba96ac82 100644 --- a/IRaCIS.Core.Domain/Trial/Trial.cs +++ b/IRaCIS.Core.Domain/Trial/Trial.cs @@ -132,7 +132,7 @@ public partial class Trial : BaseFullDeleteAuditEntity public bool VisitPlanConfirmed { get; set; } [Comment("受试者编号具体规则")] - public string SubjectCodeRule { get; set; } = StaticData.International("Trial_number"); + public string SubjectCodeRule { get; set; } = I18n.T("Trial_number"); [Comment("是否 提醒受试者编号规则")] public bool IsNoticeSubjectCodeRule { get; set; } = true; diff --git a/IRaCIS.Core.Infrastructure/_IRaCIS/Output/ResponseOutput.cs b/IRaCIS.Core.Infrastructure/_IRaCIS/Output/ResponseOutput.cs index 9023c87e5..d4ceae5be 100644 --- a/IRaCIS.Core.Infrastructure/_IRaCIS/Output/ResponseOutput.cs +++ b/IRaCIS.Core.Infrastructure/_IRaCIS/Output/ResponseOutput.cs @@ -117,9 +117,9 @@ namespace IRaCIS.Core.Infrastructure.Extention var info = string.Empty; - if (!string.IsNullOrWhiteSpace(key) && StaticData.Log_Locoalize_Dic.ContainsKey(key)) + if (!string.IsNullOrWhiteSpace(key) && StaticData.Localizer_Dev_Dic.ContainsKey(key)) { - info = $"[{key}]:{StaticData.Log_Locoalize_Dic[key]}"; + info = $"[{key}]:{StaticData.Localizer_Dev_Dic[key]}"; } return new ResponseOutput().NotOk(msg, code: code, localizedInfo: info); diff --git a/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs b/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs index d10de14af..b651aa78a 100644 --- a/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs +++ b/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Threading; @@ -12,7 +13,7 @@ public static class StaticData public static Dictionary Zh_CN_Dic = new Dictionary(); - public static Dictionary Log_Locoalize_Dic = new Dictionary(); + public static Dictionary Localizer_Dev_Dic = new Dictionary(); #region 国际化 @@ -33,44 +34,21 @@ public static class StaticData /// /// /// - public static string International(string key, params object?[] args) + public static string I18n(string key, params object?[] args) { - try - { - return string.Format(GetLanguageDictionary(key), args); - } - catch (Exception) - { + var isEn_US = System.Globalization.CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US; - return string.Empty; + if (isEn_US) + { + return En_US_Dic[key]; } + else + { + return Zh_CN_Dic[key]; + } } - public static string GetLanguageDictionary(string key) - { - try - { - var type = Thread.CurrentThread.CurrentUICulture.Name; - if (type == "zh-CN") - { - return Zh_CN_Dic[key]; - - } - else - { - return En_US_Dic[key]; - - } - } - catch (Exception) - { - - return string.Empty; - } - - } - #endregion #region 字典表项固定值