forked from aspnetcorehero/Boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(identity-pages-localization): adds singleton SharedResourceLocali…
…zer services to access IStringLocalizer from Razor identity pages for correct localization. resolves: aspnetcorehero#34
- Loading branch information
1 parent
c5c9bca
commit b9786db
Showing
6 changed files
with
61 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
AspNetCoreHero.Boilerplate.Web/Services/SharedResourceLocalizer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Reflection; | ||
using Microsoft.Extensions.Localization; | ||
|
||
namespace AspNetCoreHero.Boilerplate.Web.Services | ||
{ | ||
public class SharedResourceLocalizer | ||
{ | ||
public readonly IStringLocalizer _localizer; | ||
|
||
public SharedResourceLocalizer(IStringLocalizerFactory factory) | ||
{ | ||
var type = typeof(SharedResource); | ||
var assemblyName = new AssemblyName(type.GetTypeInfo().Assembly.FullName); | ||
_localizer = factory.Create("SharedResource", assemblyName.Name); | ||
} | ||
|
||
public LocalizedString GetLocalizedHtmlString(string key) | ||
{ | ||
return _localizer[key]; | ||
} | ||
|
||
public LocalizedString GetLocalizedHtmlString(string key, string parameter) | ||
{ | ||
return _localizer[key, parameter]; | ||
} | ||
|
||
} | ||
} |