* Default ResourcePath behavior is to look next to .cs file

This commit is contained in:
ryanbrandenburg 2015-12-10 17:08:21 -08:00
Родитель 0b013ae769
Коммит 5074bf0c57
4 изменённых файлов: 7 добавлений и 5 удалений

Просмотреть файл

@ -67,7 +67,9 @@ namespace Microsoft.Extensions.Localization
var typeInfo = resourceSource.GetTypeInfo(); var typeInfo = resourceSource.GetTypeInfo();
var assembly = typeInfo.Assembly; 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, _ => return _localizerCache.GetOrAdd(baseName, _ =>
new ResourceManagerStringLocalizer( new ResourceManagerStringLocalizer(

Просмотреть файл

@ -118,6 +118,6 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<data name="Hello" xml:space="preserve"> <data name="Hello" xml:space="preserve">
<value>Bonjour from Customer in root folder</value> <value>Bonjour from Customer in Models folder</value>
</data> </data>
</root> </root>

Просмотреть файл

@ -77,7 +77,7 @@ namespace Microsoft.AspNet.Localization.FunctionalTests
applicationBaseUrl, applicationBaseUrl,
"ResourcesAtRootFolder", "ResourcesAtRootFolder",
"fr-FR", "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] [ConditionalFact]
@ -92,7 +92,7 @@ namespace Microsoft.AspNet.Localization.FunctionalTests
"http://localhost:5076", "http://localhost:5076",
"ResourcesAtRootFolder", "ResourcesAtRootFolder",
"fr-FR", "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] [ConditionalFact]
@ -107,7 +107,7 @@ namespace Microsoft.AspNet.Localization.FunctionalTests
"http://localhost:5077/", "http://localhost:5077/",
"ResourcesAtRootFolder", "ResourcesAtRootFolder",
"fr-FR", "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");
} }
} }
} }