При запуске у меня есть следующий код
Метод ConfigurationServices
Код: Выделить всё
services.AddLocalization(options => options.ResourcesPath = "Resources");
services.AddMvc()
.AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix)
.AddDataAnnotationsLocalization();
Код: Выделить всё
app.UseStaticFiles();
app.UseCookiePolicy();
var supportedCultures = new[]
{
new CultureInfo("en-US"),
new CultureInfo("es-ES"),
};
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("en-US"),
// Formatting numbers, dates, etc.
SupportedCultures = supportedCultures,
// UI strings that we have localized.
SupportedUICultures = supportedCultures
});
app.UseStaticFiles();
app.UseStaticFiles();
app.UseMvc();
Код: Выделить всё
@page
@using Microsoft.AspNetCore.Mvc.Localization
@model IndexModel
@inject IViewLocalizer Localizer
@{
ViewData["Title"] = "Error";
}
Welcome to ASP.NET Localization
This is Localization
@Localizer["Overview"]
Код: Выделить всё
private readonly IStringLocalizer Localizer;
public IndexModel(IStringLocalizer localizer)
{
Localizer = localizer;
}
\Resources\Index.es.resx
В настоящее время у него есть ключ для обзора.
Я загружаю приложение и пытаюсь изменить культуру как
Код: Выделить всё
https://localhost:44345/?culture=es-ES
Подробнее здесь: https://stackoverflow.com/questions/559 ... ot-working
Мобильная версия