How to implement localization in web.sitemap

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

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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

Method 2

Use a global resource file.

App_GlobalResourcesWeb.sitemap.resx

Then use keys in the web.sitemap like;

<siteMapNode url="somepage.aspx" title="Name"  resourceKey="PageName"/>

Method 3

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

Method 4

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.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x