I don't understand, what else is there to explain? Everything is simple.
I use this authentication (if it even plays a role in this problem).
Any code where <span> is used together with asp-validation-form and class="text-danger" gives out all sorts of nonsense instead of Cyrillic letters.
In other types of nodes and generally everywhere (even on the same page), Cyrillic shows correctly.
For example:
The code of this page is as follows:
@model Project.Models.ApplicationUser
@{
ViewData["Title"] = "Create";
}
<br />
@inject LanguageService language
<h2 class="text-info">@language.Getkey("registration")</h2>
<form asp-action="Create" method="post" id="user-form" enctype="multipart/form-data">
<div class="p-4 rounded border">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<h3>@ViewBag.message</h3>
<div class="form-group row">
<div class="col-2">
<label asp-for="Login">@language.Getkey("login_name*")</label>
</div>
<div class="col-5">
<input asp-for="Login" class="form-control" exp/>
</div>
<span asp-validation-for="Login" class="text-danger">@language.Getkey("login_requires")</span>
</div>
<div class="form-group row">
<div class="col-2">
<label asp-for="Email">@language.Getkey("email*")</label>
</div>
<div class="col-5">
<input asp-for="Email" class="form-control"/>
</div>
<span asp-validation-for="Email" class="text-danger">@language.Getkey("required")</span>
</div>
<br></br>
<div class="form-group row">
<div class="col-2">
<label asp-for="PasswordHash">@language.Getkey("password*")</label>
</div>
<div class="col-5">
<form action="">
<div class="form-item">
<input asp-for="PasswordHash" type="password" class="form-control form-control-lg" id="password" placeholder="password"/>
<i class="fas fa-eye" id="eye"></i>
</div>
</form>
</div>
<span asp-validation-for="PasswordHash" class="text-danger">@language.Getkey("password_requires")</span>
</div>
<br></br>
<div class="form-group row">
<div class="col-2">
<label asp-for="FirstName">@language.Getkey("first_name*")</label>
</div>
<div class="col-5">
<input asp-for="FirstName" class="form-control"/>
</div>
<span asp-validation-for="FirstName" class="text-danger">@language.Getkey("required")</span>
</div>
<div class="form-group row">
<div class="col-2">
<label asp-for="LastName">@language.Getkey("last_name*")</label>
</div>
<div class="col-5">
<input asp-for="LastName" class="form-control" />
</div>
<span asp-validation-for="LastName" class="text-danger">@language.Getkey("required")</span>
</div>
<br></br>
<div class="form-group">
<a asp-area="Customer" asp-action="Index" asp-controller="Home" class="button large">@language.Getkey("general")</a>
<input type="submit" class="button large" value="@language.Getkey("register")"/>
</div>
</div>
</form>
@section Scripts{
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial");}
<script>
$(document).ready(function () {
$("#user-form").validate({
rules: {
Login : {
required: true
},
Email : {
required: true
},
PasswordHash : {
required: true
},
FirstName : {
required: true
},
LastName : {
required: true
}
},
messages: {
Login: @language.Getkey("unique_login_is_required"),
Email: @language.Getkey("email_is_required"),
PasswordHash: @language.Getkey("password_is_required"),
FirstName: @language.Getkey("first_name_is_required"),
LastName: @language.Getkey("last_name_is_required")
}
});
});
</script>
}
My code responsible for changing the language is as follows:
services.AddControllersWithViews();
services.AddSingleton<LanguageService>();
services.AddLocalization(options => options.ResourcesPath = "Resources");
services.AddMvc()
.AddViewLocalization()
.AddDataAnnotationsLocalization(options =>
{
options.DataAnnotationLocalizerProvider = (type, factory) =>
{
var assemblyName = new AssemblyName(typeof(ShareResource).GetTypeInfo().Assembly.FullName);
return factory.Create("ShareResource", assemblyName.Name);
};
});
services.Configure<RequestLocalizationOptions>(
options =>
{
var supportedCultures = new List<CultureInfo>
{
new CultureInfo("ru-RU"),
new CultureInfo("en-En")
};
options.DefaultRequestCulture = new RequestCulture(culture: "ru-RU", uiCulture: "ru-RU");
options.SupportedCultures = supportedCultures;
options.SupportedUICultures = supportedCultures;
options.RequestCultureProviders.Insert(0, new QueryStringRequestCultureProvider());
});
using Microsoft.Extensions.Localization;
using System.Reflection;
namespace Project.Models
{
public class LanguageService
{
private IStringLocalizer _localizer;
public LanguageService(IStringLocalizerFactory factory)
{
var type = typeof(ShareResource);
var assemblyName = new AssemblyName(type.GetTypeInfo().Assembly.FullName);
_localizer = factory.Create("SharedResource", assemblyName.Name);
}
public LocalizedString Getkey(string key)
{
return _localizer[key];
}
}
}
Well, there are, as always, files of the .resx
SharedResource.en-GB.resx
SharedResource.ru-RU.resx
SharedResource.de-DE.resx
SharedResource.el-GR.resx
That's it! There 's nothing more to tell.