How to implement localization in web.sitemap

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

+7
localization
source share
4 answers

Use the global resource file.

App_GlobalResources\Web.sitemap.resx 

Then use the keys in the web.sitemap file, for example:

 <siteMapNode url="somepage.aspx" title="Name" resourceKey="PageName"/> 
+4
source share

If you have global resources, you can use it like this:

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

Where SiteMapLocalizations: resource name HomePageTitle: resource key thee

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

+4
source share

It is worth noting that you also need to set enableLocalization="true" in the siteMap tag. Otherwise it will not work.

+2
source share

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

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

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

4) Open a new Web.sitemap.resx file. Add each <siteMapNode> resourceKey created in step 2 to the list of resources in the Name column, then .Description to specify a localized description, and .Title to set a localized header. Then the displayed text goes into the "Value" column.

Please note that Visual Studio marks each resource record with a red exclamation mark, which says that this is an invalid identifier - ignore the warning.

For example, if your <siteMapNode> has a resourceKey with the value "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 into other languages ​​by duplicating the resx file and renaming the copy according to the new culture.

If this does not work, make sure that the new resource file is in the GlobalResources directory and not in LocalResources. Also make sure OutputCache is disabled.

0
source share

All Articles