@@ -20,7 +20,6 @@ public class ResourceManagerStringLocalizerFactory : IStringLocalizerFactory
20
20
private readonly ConcurrentDictionary < string , ResourceManagerStringLocalizer > _localizerCache =
21
21
new ConcurrentDictionary < string , ResourceManagerStringLocalizer > ( ) ;
22
22
private readonly IApplicationEnvironment _applicationEnvironment ;
23
-
24
23
private readonly string _resourcesRelativePath ;
25
24
26
25
/// <summary>
@@ -69,7 +68,8 @@ public IStringLocalizer Create(Type resourceSource)
69
68
70
69
var baseName = string . IsNullOrEmpty ( _resourcesRelativePath )
71
70
? typeInfo . FullName
72
- : _applicationEnvironment . ApplicationName + "." + _resourcesRelativePath + typeInfo . FullName ;
71
+ : _applicationEnvironment . ApplicationName + "." + _resourcesRelativePath
72
+ + TrimPrefix ( typeInfo . FullName , _applicationEnvironment . ApplicationName + "." ) ;
73
73
74
74
return _localizerCache . GetOrAdd ( baseName , _ =>
75
75
new ResourceManagerStringLocalizer (
@@ -95,7 +95,7 @@ public IStringLocalizer Create(string baseName, string location)
95
95
96
96
var rootPath = location ?? _applicationEnvironment . ApplicationName ;
97
97
var assembly = Assembly . Load ( new AssemblyName ( rootPath ) ) ;
98
- baseName = rootPath + "." + _resourcesRelativePath + baseName ;
98
+ baseName = rootPath + "." + _resourcesRelativePath + TrimPrefix ( baseName , rootPath + "." ) ;
99
99
100
100
return _localizerCache . GetOrAdd ( baseName , _ =>
101
101
new ResourceManagerStringLocalizer (
@@ -105,5 +105,15 @@ public IStringLocalizer Create(string baseName, string location)
105
105
_resourceNamesCache )
106
106
) ;
107
107
}
108
+
109
+ private static string TrimPrefix ( string name , string prefix )
110
+ {
111
+ if ( name . StartsWith ( prefix , StringComparison . Ordinal ) )
112
+ {
113
+ return name . Substring ( prefix . Length ) ;
114
+ }
115
+
116
+ return name ;
117
+ }
108
118
}
109
119
}
0 commit comments