Can you explain how to implement localization in web.sitemap please?
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"/>
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
It's worthy to notice that you also need to set enableLocalization="true"
at siteMap
tag. Otherwise it will not work.
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.
© 2022 - 2024 — McMap. All rights reserved.