diff --git a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs index fa48d0d43c..009ddf37bf 100644 --- a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs +++ b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using Localization.Resources.AbpUi; using Microsoft.Extensions.Localization; using Microsoft.Extensions.Options; using Volo.Abp.Authorization; @@ -19,15 +20,18 @@ namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling { public bool SendAllExceptionsToClients { get; set; } = false; - private readonly ExceptionLocalizationOptions _localizationOptions; - private readonly IStringLocalizerFactory _stringLocalizerFactory; + protected ExceptionLocalizationOptions LocalizationOptions { get; } + protected IStringLocalizerFactory StringLocalizerFactory { get; } + protected IStringLocalizer L { get; } public DefaultExceptionToErrorInfoConverter( IOptions localizationOptions, - IStringLocalizerFactory stringLocalizerFactory) + IStringLocalizerFactory stringLocalizerFactory, + IStringLocalizer abpUiStringLocalizer) { - _stringLocalizerFactory = stringLocalizerFactory; - _localizationOptions = localizationOptions.Value; + StringLocalizerFactory = stringLocalizerFactory; + L = abpUiStringLocalizer; + LocalizationOptions = localizationOptions.Value; } public RemoteServiceErrorInfo Convert(Exception exception) @@ -74,7 +78,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling { if (errorInfo.Message.IsNullOrEmpty()) { - errorInfo.Message = L("ValidationError"); + errorInfo.Message = L["ValidationErrorMessage"]; } if (errorInfo.Details.IsNullOrEmpty()) @@ -89,7 +93,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling if (errorInfo.Message.IsNullOrEmpty()) { - errorInfo.Message = L("InternalServerError"); + errorInfo.Message = L["InternalServerErrorMessage"]; } return errorInfo; @@ -110,13 +114,13 @@ namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling var codeNamespace = exceptionWithErrorCode.Code.Split(':')[0]; - var localizationResourceType = _localizationOptions.ErrorCodeNamespaceMappings.GetOrDefault(codeNamespace); + var localizationResourceType = LocalizationOptions.ErrorCodeNamespaceMappings.GetOrDefault(codeNamespace); if (localizationResourceType == null) { return; } - var stringLocalizer = _stringLocalizerFactory.Create(localizationResourceType); + var stringLocalizer = StringLocalizerFactory.Create(localizationResourceType); var localizedString = stringLocalizer[exceptionWithErrorCode.Code]; if (localizedString.ResourceNotFound) { @@ -142,7 +146,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling { return new RemoteServiceErrorInfo( string.Format( - L("EntityNotFound"), + L["EntityNotFoundErrorMessage"], exception.EntityType.Name, exception.Id ) @@ -264,7 +268,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling protected virtual string GetValidationErrorNarrative(IHasValidationErrors validationException) { var detailBuilder = new StringBuilder(); - detailBuilder.AppendLine(L("ValidationNarrativeTitle")); + detailBuilder.AppendLine(L["ValidationNarrativeErrorMessageTitle"]); foreach (var validationResult in validationException.ValidationErrors) { @@ -274,11 +278,5 @@ namespace Volo.Abp.AspNetCore.Mvc.ExceptionHandling return detailBuilder.ToString(); } - - protected virtual string L(string name) - { - //TODO: Localization? - return name; - } } } \ No newline at end of file diff --git a/src/Volo.Abp.UI/Localization/Resources/AbpUi/en.json b/src/Volo.Abp.UI/Localization/Resources/AbpUi/en.json index dbd20ba903..4d34beb230 100644 --- a/src/Volo.Abp.UI/Localization/Resources/AbpUi/en.json +++ b/src/Volo.Abp.UI/Localization/Resources/AbpUi/en.json @@ -1,6 +1,18 @@ { "culture": "en", "texts": { + "InternalServerErrorMessage": "An internal error occurred during your request!", + "ValidationErrorMessage": "Your request is not valid!", + "ValidationNarrativeErrorMessageTitle": "The following errors were detected during validation.", + "DefaultErrorMessage": "An error has occurred!", + "DefaultErrorMessage401": "You are not authenticated! You should sign in to perform this operation.", + "DefaultErrorMessage403": "You are not allowed to perform this operation!", + "DefaultErrorMessage404": "The resource requested could not found on the server!", + "EntityNotFoundErrorMessage": "There is no entity {0} with id = {1}!", + "AreYouSure": "Are you sure?", + "Cancel": "Cancel", + "Yes": "Yes", + "No": "No", "Close": "Close", "Save": "Save", "SavingWithThreeDot": "Saving...", diff --git a/src/Volo.Abp.UI/Localization/Resources/AbpUi/tr.json b/src/Volo.Abp.UI/Localization/Resources/AbpUi/tr.json index 9fdd55ba69..0422a04ad1 100644 --- a/src/Volo.Abp.UI/Localization/Resources/AbpUi/tr.json +++ b/src/Volo.Abp.UI/Localization/Resources/AbpUi/tr.json @@ -1,6 +1,18 @@ { "culture": "tr", "texts": { + "InternalServerErrorMessage": "Sayfa işlenirken sunucu tarafında beklenmedik bir hata oluştu!", + "ValidationErrorMessage": "İşleminiz geçerli değil!", + "ValidationNarrativeErrorMessageTitle": "Aşağıdaki hatalar doğrulama sırasında tespit edilmiştir.", + "DefaultErrorMessage": "Bir hata oluştu!", + "DefaultErrorMessage401": "Giriş yapılmamış! Bu işlemi gerçekleştirmek için uygulamaya giriş yapmalısınız.", + "DefaultErrorMessage403": "Bu işlemi gerçekleştirmek için gereken izne sahip değilsiniz!", + "DefaultErrorMessage404": "İstenilen kaynak sunucuda bulunamadı!", + "EntityNotFoundErrorMessage": "Id değeri {1} olan {0} türünden bir nesne bulunamadı!", + "AreYouSure": "Emin misiniz?", + "Cancel": "Vazgeç", + "Yes": "Evet", + "No": "Hayır", "Close": "Kapat", "Save": "Kaydet", "SavingWithThreeDot": "Kaydediliyor...",