【发布时间】:2017-02-09 01:32:24
【问题描述】:
我正在 .net 核心中编写 mvc 应用程序,我遇到了本地化问题,我不知道如何将 IViewLocalizer 添加到我的网格视图中。这是我的代码:
@using NonFactors.Mvc.Grid;
@using Microsoft.AspNetCore.Mvc.Localization
@inject IViewLocalizer Localizer
@model IEnumerable<WeegreeEmployeeFormsCore.Models.Employee>
@(Html
.Grid(Model)
.Build(columns =>
{
columns.Add(model => model.Name).Titled(Localizer["Name"]).Sortable(true).Filterable(true);
columns.Add(model => model.Surname).Titled(Localizer["Surname"]).Sortable(true).Filterable(true);
columns.Add(model => model.EmploymentDate).Titled(Localizer["Hired"]).Sortable(true).Filterable(true);
columns.Add(model => model.Country).Titled(Localizer["Country"]).Filterable(true).Sortable(true).Filterable(true);
columns.Add(model => model.EmploymentForm).Titled(Localizer["EmploymentForm"]).Filterable(true);
columns.Add(model => $"<a href=\"{Url.Action("Edit", "Form")}/{model.EmployeeId}\">{Localizer["Edit"]}</a>").Encoded(false);
columns.Add(model => $"<a href=\"{Url.Action("Details", "Form")}/{model.EmployeeId}\">Details</a>").Encoded(false);
})
.Pageable(pager =>
{
pager.PagesToDisplay = 10;
pager.CurrentPage = 1;
pager.RowsPerPage = 10;
})
.Sortable()
.Empty("No data found")
)
当我使用 {} 插入表达式 model.EmployeeId 时,它可以工作 - 链接正在工作,但是当我想使用 Localizer 获取题词 Edit/Edytuj/змінити etc 时。而不是我认为:
Microsoft.AspNetCore.Mvc.Localization.LocalizedHtmlString
【问题讨论】:
标签: c# linq asp.net-core linq-expressions asp.net-core-localization