From 5074bf0c57abf1dff8dc077d776f88c66120a54f Mon Sep 17 00:00:00 2001 From: ryanbrandenburg Date: Thu, 10 Dec 2015 17:08:21 -0800 Subject: [PATCH] * Default ResourcePath behavior is to look next to .cs file --- .../ResourceManagerStringLocalizerFactory.cs | 4 +++- .../Customer.fr-FR.resx} | 2 +- ...r.fr-FR.resx => StartupResourcesAtRootFolder.fr-FR.resx} | 0 .../LocalizationTest.cs | 6 +++--- 4 files changed, 7 insertions(+), 5 deletions(-) rename test/LocalizationWebsite/{LocalizationWebsite.Models.Customer.fr-FR.resx => Models/Customer.fr-FR.resx} (98%) rename test/LocalizationWebsite/{LocalizationWebsite.StartupResourcesAtRootFolder.fr-FR.resx => StartupResourcesAtRootFolder.fr-FR.resx} (100%) diff --git a/src/Microsoft.Extensions.Localization/ResourceManagerStringLocalizerFactory.cs b/src/Microsoft.Extensions.Localization/ResourceManagerStringLocalizerFactory.cs index 4e3d721..45e11b0 100644 --- a/src/Microsoft.Extensions.Localization/ResourceManagerStringLocalizerFactory.cs +++ b/src/Microsoft.Extensions.Localization/ResourceManagerStringLocalizerFactory.cs @@ -67,7 +67,9 @@ namespace Microsoft.Extensions.Localization var typeInfo = resourceSource.GetTypeInfo(); var assembly = typeInfo.Assembly; - var baseName = _applicationEnvironment.ApplicationName + "." + _resourcesRelativePath + typeInfo.FullName; + var baseName = string.IsNullOrEmpty(_resourcesRelativePath) + ? typeInfo.FullName + : _applicationEnvironment.ApplicationName + "." + _resourcesRelativePath + typeInfo.FullName; return _localizerCache.GetOrAdd(baseName, _ => new ResourceManagerStringLocalizer( diff --git a/test/LocalizationWebsite/LocalizationWebsite.Models.Customer.fr-FR.resx b/test/LocalizationWebsite/Models/Customer.fr-FR.resx similarity index 98% rename from test/LocalizationWebsite/LocalizationWebsite.Models.Customer.fr-FR.resx rename to test/LocalizationWebsite/Models/Customer.fr-FR.resx index a3a0136..1236654 100644 --- a/test/LocalizationWebsite/LocalizationWebsite.Models.Customer.fr-FR.resx +++ b/test/LocalizationWebsite/Models/Customer.fr-FR.resx @@ -118,6 +118,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Bonjour from Customer in root folder + Bonjour from Customer in Models folder \ No newline at end of file diff --git a/test/LocalizationWebsite/LocalizationWebsite.StartupResourcesAtRootFolder.fr-FR.resx b/test/LocalizationWebsite/StartupResourcesAtRootFolder.fr-FR.resx similarity index 100% rename from test/LocalizationWebsite/LocalizationWebsite.StartupResourcesAtRootFolder.fr-FR.resx rename to test/LocalizationWebsite/StartupResourcesAtRootFolder.fr-FR.resx diff --git a/test/Microsoft.AspNet.Localization.FunctionalTests/LocalizationTest.cs b/test/Microsoft.AspNet.Localization.FunctionalTests/LocalizationTest.cs index 0940888..27e75f3 100644 --- a/test/Microsoft.AspNet.Localization.FunctionalTests/LocalizationTest.cs +++ b/test/Microsoft.AspNet.Localization.FunctionalTests/LocalizationTest.cs @@ -77,7 +77,7 @@ namespace Microsoft.AspNet.Localization.FunctionalTests applicationBaseUrl, "ResourcesAtRootFolder", "fr-FR", - "Bonjour from StartupResourcesAtRootFolder Bonjour from Test in root folder Bonjour from Customer in root folder"); + "Bonjour from StartupResourcesAtRootFolder Bonjour from Test in root folder Bonjour from Customer in Models folder"); } [ConditionalFact] @@ -92,7 +92,7 @@ namespace Microsoft.AspNet.Localization.FunctionalTests "http://localhost:5076", "ResourcesAtRootFolder", "fr-FR", - "Bonjour from StartupResourcesAtRootFolder Bonjour from Test in root folder Bonjour from Customer in root folder"); + "Bonjour from StartupResourcesAtRootFolder Bonjour from Test in root folder Bonjour from Customer in Models folder"); } [ConditionalFact] @@ -107,7 +107,7 @@ namespace Microsoft.AspNet.Localization.FunctionalTests "http://localhost:5077/", "ResourcesAtRootFolder", "fr-FR", - "Bonjour from StartupResourcesAtRootFolder Bonjour from Test in root folder Bonjour from Customer in root folder"); + "Bonjour from StartupResourcesAtRootFolder Bonjour from Test in root folder Bonjour from Customer in Models folder"); } } }