I am using asp.net core 2.0 to develop my MVC application. However, I am using the SharedLocalizer in the view. I use the following code to inject it:
@using Microsoft.AspNetCore.Mvc.Localization
@using Microsoft.Extensions.Localization
@inject IViewLocalizer Localizer
@inject IStringLocalizer<SharedResources> SharedLocalizer
@inject IHtmlLocalizer<SharedResources> SharedHtmlLocalizer
This is how I call my SharedLocalizer:
function updateCommission(agentID) {
var msg = '@SharedLocalizer["Confirm Update Commission?"].Value.ToString()';
if (confirm(msg) == false)
return false;
}
But, my result looks like this:

If I use the SharedLocalizer in my html label / input, it displays fine. When I view my page source, the string also is the '$#1231';
How can I display the correct string with my setup?
Returns markup that is not HTML encoded @Html.Raw
refactor
function updateCommission(agentID) {
var msg = '@Html.Raw(SharedLocalizer["Confirm Update commission?"].Value.ToString())';
return confirm(msg);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With