How to implement localization in web.sitemap

前端 未结 4 930
长发绾君心
长发绾君心 2020-12-30 13:09

Can you explain how to implement localization in web.sitemap please?

相关标签:
4条回答
  • 2020-12-30 13:27

    If you have global resources you can use it like this

    <siteMapNode url="~/Default.aspx" Title="$resources:SiteMapLocalizations,HomePageTitle"></siteMapNode>
    

    Where SiteMapLocalizations: is the resource Name HomePageTitle: thee resource Key

    Reference: http://msdn.microsoft.com/en-us/library/ms178427.aspx

    0 讨论(0)
  • 2020-12-30 13:28

    It's worthy to notice that you also need to set enableLocalization="true" at siteMap tag. Otherwise it will not work.

    0 讨论(0)
  • 2020-12-30 13:29

    1) Add an enableLocalization='true' attribute to the <siteMap> root node in the Web.sitemap file.

    2) Add a unique resourceKey attribute to each <siteMapNode> node in the Web.sitemap file.

    3) Create a new Web.sitemap.resx resources file in the GlobalResources directory.

    4) Open the new Web.sitemap.resx file. Add each <siteMapNode> resourceKey attribute you created in Step 2 to the resources list under the Name column, followed by .Description to set the localized description, and .Title to set the localized title. The displayed text then goes into the Value column.

    Note that Visual Studio will flag each resource entry with a red exclamation saying that it's an invalid identifier - ignore the warning.

    For example, if your <siteMapNode> had a resourceKey of "Example", the localized Description tag would be Example.Description and the localized Title tag would be Example.Title

    That should do it. You can then provide translations for other languages by duplicating the resx file and renaming the copy to fit the new culture.

    If it doesn't work, make sure the new resource file is in the GlobalResources directory, not LocalResources. Also make sure OutputCache is disabled.

    0 讨论(0)
  • 2020-12-30 13:31

    Use a global resource file.

    App_GlobalResources\Web.sitemap.resx
    

    Then use keys in the web.sitemap like;

    <siteMapNode url="somepage.aspx" title="Name"  resourceKey="PageName"/>
    
    0 讨论(0)
提交回复
热议问题