From 5d67d427caaf92c93ef2a9313396c541aa330ea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Mon, 18 Dec 2017 00:31:09 +0300 Subject: [PATCH] Seperate validations to AbpValidationResource. --- src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs | 5 ++++- .../Localization/Resource/en.json | 2 -- .../Localization/Resource/tr.json | 2 -- src/Volo.Abp/Volo.Abp.csproj | 13 +++++++++++++ src/Volo.Abp/Volo/Abp/AbpKernelModule.cs | 6 ++++++ .../Resources/Validation/IdentityResource.cs | 8 ++++++++ .../Abp/Localization/Resources/Validation/en.json | 7 +++++++ .../Abp/Localization/Resources/Validation/tr.json | 7 +++++++ .../Volo/Abp/Localization/AbpLocalization_Tests.cs | 3 ++- 9 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 src/Volo.Abp/Volo/Abp/Localization/Resources/Validation/IdentityResource.cs create mode 100644 src/Volo.Abp/Volo/Abp/Localization/Resources/Validation/en.json create mode 100644 src/Volo.Abp/Volo/Abp/Localization/Resources/Validation/tr.json diff --git a/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs b/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs index f46a90d262..6170f2179c 100644 --- a/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs +++ b/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs @@ -6,6 +6,7 @@ using Volo.Abp.Identity.Web.Localization.Resource; using Volo.Abp.Identity.Web.Navigation; using Volo.Abp.Identity.Web.ObjectMappings; using Volo.Abp.Localization; +using Volo.Abp.Localization.Resources.Validation; using Volo.Abp.Modularity; using Volo.Abp.Ui.Navigation; using Volo.Abp.VirtualFileSystem; @@ -41,7 +42,9 @@ namespace Volo.Abp.Identity.Web services.Configure(options => { - options.Resources.AddJson("en"); + //TODO: Declare base type by attribute + options.Resources.AddJson("en") + .InheritFrom(typeof(AbpValidationResource)); }); services.Configure(options => diff --git a/src/Volo.Abp.Identity.Web/Localization/Resource/en.json b/src/Volo.Abp.Identity.Web/Localization/Resource/en.json index 55b6d65ab6..b7378abbba 100644 --- a/src/Volo.Abp.Identity.Web/Localization/Resource/en.json +++ b/src/Volo.Abp.Identity.Web/Localization/Resource/en.json @@ -15,8 +15,6 @@ "Save": "Save", "Password": "Password", "UserDeletionConfirmationMessage": "User '{0}' will be deleted. Do you confirm that?", - "MaxLengthKey": "The field {0} must be a string or array type with a maximum length of '{1}'.", - "The {0} field is required.": "The {0} field is required.", "TwoFactorVerification": "Two factor verification", "AccountLockoutOnFailedLoginAttempts": "Locking account after failed login attempts" } diff --git a/src/Volo.Abp.Identity.Web/Localization/Resource/tr.json b/src/Volo.Abp.Identity.Web/Localization/Resource/tr.json index 1c6625d237..0f8830e7ef 100644 --- a/src/Volo.Abp.Identity.Web/Localization/Resource/tr.json +++ b/src/Volo.Abp.Identity.Web/Localization/Resource/tr.json @@ -15,8 +15,6 @@ "Save": "Kaydet", "Password": "Şifre", "UserDeletionConfirmationMessage": "{0} kullanıcısı silinecektir. Onaylıyor musunuz?", - "The field {0} must be a string or array type with a maximum length of '{1}'.": "{0} alanı en fazla '{1}' karakter uzunluğunda olmalıdır.", - "The {0} field is required.": "{0} alanı zorunludur.", "TwoFactorVerification": "İki aşamalı doğrumala", "AccountLockoutOnFailedLoginAttempts": "Başarısız giriş denemeleri sonrası hesabı kilitleme" } diff --git a/src/Volo.Abp/Volo.Abp.csproj b/src/Volo.Abp/Volo.Abp.csproj index 5022b66a8f..f0acf74ab9 100644 --- a/src/Volo.Abp/Volo.Abp.csproj +++ b/src/Volo.Abp/Volo.Abp.csproj @@ -13,6 +13,19 @@ + + + + + + + PreserveNewest + + + PreserveNewest + + + diff --git a/src/Volo.Abp/Volo/Abp/AbpKernelModule.cs b/src/Volo.Abp/Volo/Abp/AbpKernelModule.cs index 271ec364fa..575863d6a6 100644 --- a/src/Volo.Abp/Volo/Abp/AbpKernelModule.cs +++ b/src/Volo.Abp/Volo/Abp/AbpKernelModule.cs @@ -2,6 +2,7 @@ using Volo.Abp.ApiVersioning; using Volo.Abp.Data; using Volo.Abp.Localization; +using Volo.Abp.Localization.Resources.Validation; using Volo.Abp.Modularity; using Volo.Abp.ObjectMapping; using Volo.Abp.Reflection; @@ -52,6 +53,11 @@ namespace Volo.Abp options.Contributers.Add(); options.Contributers.Add(); }); + + services.Configure(options => + { + options.Resources.AddJson("en"); + }); } } } diff --git a/src/Volo.Abp/Volo/Abp/Localization/Resources/Validation/IdentityResource.cs b/src/Volo.Abp/Volo/Abp/Localization/Resources/Validation/IdentityResource.cs new file mode 100644 index 0000000000..5e849d832c --- /dev/null +++ b/src/Volo.Abp/Volo/Abp/Localization/Resources/Validation/IdentityResource.cs @@ -0,0 +1,8 @@ +namespace Volo.Abp.Localization.Resources.Validation +{ + [ShortLocalizationResourceName("AbpValidation")] + public class AbpValidationResource + { + + } +} diff --git a/src/Volo.Abp/Volo/Abp/Localization/Resources/Validation/en.json b/src/Volo.Abp/Volo/Abp/Localization/Resources/Validation/en.json new file mode 100644 index 0000000000..aa4d13410a --- /dev/null +++ b/src/Volo.Abp/Volo/Abp/Localization/Resources/Validation/en.json @@ -0,0 +1,7 @@ +{ + "culture": "en", + "texts": { + "The field {0} must be a string or array type with a maximum length of '{1}'.": "The field {0} must be a string or array type with a maximum length of '{1}'.", + "The {0} field is required.": "The {0} field is required." + } +} \ No newline at end of file diff --git a/src/Volo.Abp/Volo/Abp/Localization/Resources/Validation/tr.json b/src/Volo.Abp/Volo/Abp/Localization/Resources/Validation/tr.json new file mode 100644 index 0000000000..222739fd2f --- /dev/null +++ b/src/Volo.Abp/Volo/Abp/Localization/Resources/Validation/tr.json @@ -0,0 +1,7 @@ +{ + "culture": "tr", + "texts": { + "The field {0} must be a string or array type with a maximum length of '{1}'.": "{0} alanı en fazla '{1}' karakter uzunluğunda olmalıdır.", + "The {0} field is required.": "{0} alanı zorunludur." + } +} \ No newline at end of file diff --git a/test/Volo.Abp.Tests/Volo/Abp/Localization/AbpLocalization_Tests.cs b/test/Volo.Abp.Tests/Volo/Abp/Localization/AbpLocalization_Tests.cs index a947f3d47a..7981922126 100644 --- a/test/Volo.Abp.Tests/Volo/Abp/Localization/AbpLocalization_Tests.cs +++ b/test/Volo.Abp.Tests/Volo/Abp/Localization/AbpLocalization_Tests.cs @@ -112,7 +112,8 @@ namespace Volo.Abp.Localization { options.Resources.AddJson("en"); options.Resources.AddJson("en"); - + + //TODO: Declare base type by attribute options.Resources.AddJson("en") .InheritFrom( typeof(LocalizationTestValidationResource),