【问题标题】:How to use resources files .resx to get translated column header text in mvcgrid.net如何使用资源文件 .resx 在 mvcgrid.net 中获取已翻译的列标题文本
【发布时间】:2017-06-10 08:01:04
【问题描述】:

如何使用资源文件 .resx 获取 mvcgrid.net 中已翻译的列标题文本?

【问题讨论】:

  • 这还是个问题。

标签: internationalization mvcgrid.net


【解决方案1】:

有一个本地化示例:http://mvcgrid.net/demo/localization

但我们是通过 _Grid.cshtml 视图实现的,该视图的配置如下:

GridDefaults gridDefaults = new GridDefaults()
{
      RenderingMode = RenderingMode.Controller,
      ViewPath = "~/Views/MVCGrid/_Grid.cshtml",
      NoResultsMessage = "Sorry, no results were found"
};

并在 _Grid.cshtml 中循环遍历列:

<tr>
    @foreach (var col in Model.Columns)
    {
        var thStyleAttr = !String.IsNullOrWhiteSpace(ColumnStyle(col)) ? String.Format(" style='{0}'", ColumnStyle(col)) : "";
        <th onclick='@Html.Raw(ColumnOnClick(col))' @(Html.Raw(thStyleAttr))>@DbRes.T(col.HeaderText, "Grids") @(SortImage(col))</th>
    }
</tr>

请注意,我们这里没有使用资源,但我们使用的是这个库:https://github.com/RickStrahl/Westwind.Globalization,但我认为应该是相同的想法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-12
    相关资源
    最近更新 更多