如何通过 MVCSiteMap 使用隐式本地化?

发布于 2024-09-28 15:02:45 字数 1343 浏览 1 评论 0原文

我正在尝试使用 MVCSiteMap 隐式本地化,但它不起作用。

这是我的示例 Web.Sitemap

<?xml version="1.0" encoding="utf-8" ?>

<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-2.0" enableLocalization="true">

<mvcSiteMapNode title="Home" controller="Home" action="Index" changeFrequency="Always" updatePriority="Normal">

    <mvcSiteMapNode resourceKey="Products" title="Products" controller="Products" action="Index">
        <mvcSiteMapNode title="Edit" controller="Products" action="Edit" />
    </mvcSiteMapNode>

    <mvcSiteMapNode title="Categories" controller="Categories" action="Index" />
    <mvcSiteMapNode title="Suppliers" controller="Suppliers" action="Index" />

</mvcSiteMapNode>
</mvcSiteMap>

上面的站点地图中有 resourceKey="Products" ,在 Web 中有相应的 Products.title .sitemap.resx 文件,位于 App_GlobalResources 文件夹内。按照以下说明操作: http://msdn.microsoft.com/ en-us/library/ms178427(VS.80).aspx

我在这里缺少什么?

编辑

这已在变更集 52831 中实现。

I'm trying to use implict localization with MVCSiteMap but it's not working.

Here's my sample Web.Sitemap:

<?xml version="1.0" encoding="utf-8" ?>

<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-2.0" enableLocalization="true">

<mvcSiteMapNode title="Home" controller="Home" action="Index" changeFrequency="Always" updatePriority="Normal">

    <mvcSiteMapNode resourceKey="Products" title="Products" controller="Products" action="Index">
        <mvcSiteMapNode title="Edit" controller="Products" action="Edit" />
    </mvcSiteMapNode>

    <mvcSiteMapNode title="Categories" controller="Categories" action="Index" />
    <mvcSiteMapNode title="Suppliers" controller="Suppliers" action="Index" />

</mvcSiteMapNode>
</mvcSiteMap>

I have resourceKey="Products" in the above sitemap and a corresponding Products.title in Web.sitemap.resx file, inside App_GlobalResources folder. Followed these instructions: http://msdn.microsoft.com/en-us/library/ms178427(VS.80).aspx

What I am missing here?

Edit

This has been implemented in the changeset 52831.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

染柒℉ 2024-10-05 15:02:45

感谢项目所有者 Maarten Balliauw,MvcSitemapProvider 的最新版本(在撰写本文时为 2.2.1 版)解决了这个问题!

MvcSitemapProvider 的隐式本地化几乎与默认 SitemapProvider 相同(请参阅如何:本地化站点地图数据)。唯一的区别是,您必须在 Web.Config 文件(如此处所述)。

This was addressed in the latest version (at the time of this writing, version 2.2.1) of MvcSitemapProvider thanks to the project's owner, Maarten Balliauw!

MvcSitemapProvider's implicit localization is almost identical as the default SitemapProvider (see How to: Localize Site-Map Data). The ONLY difference is that instead setting <siteMap enableLocalization="true"> in the sitemap file itself, you must set this in the Web.Config file (as described here).

蓝梦月影 2024-10-05 15:02:45

您需要从 MvcSiteMapNode 中的资源文件访问菜单项的标题

<mvcSiteMapNode title="$resources:MenuLocaliSations,Dashboard" controller="Dashboard" action="Index" changeFrequency="Always" updatePriority="Normal">

You need to access the title of the menu item from the resource file in your MvcSiteMapNode

<mvcSiteMapNode title="$resources:MenuLocaliSations,Dashboard" controller="Dashboard" action="Index" changeFrequency="Always" updatePriority="Normal">
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文