ASP. NET 2.0: How to implement localization when using web. sitemap

Source: Internet
Author: User
There are two methods: localized web. sitemap and SiteMapProvider in different cultures/languages.
Direct localization of web. sitemap can be divided into Implicit expressions and Explicit expressions. I like to use implicit expressions, because there is less manual input. In web. sitemap, you must first add enableLocalization and set it to true. Add the resourceKey to the siteMapNode to be translated as The identifier in the resource file. For example
<SiteMap enableLocalization = "true"
Xmlns = "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<SiteMapNode url = "~ /Default. aspx "title =" Home"
Description = "Home Page" resourceKey = "Home">
Then add the corresponding resource file web. sitemap. resx and localized resource files (such as web. sitemap. zh-CN.resx), and must be placed in the App_GlobalResources folder (in Beta 1 is the Resources folder ). The name/identifier (name) of the content to be added to the resource file must correspond to web. sitemap. The preceding example shows Home. title and Home. description.
To use an explicit expression, add a public resource file in the App_GlobalResources folder, for example, AppResource. resx. Then the corresponding weib. sitemap should be modified as follows.
<SiteMap enableLocalization = "true"
Xmlns = "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<SiteMapNode url = "~ /Default. aspx "title =" $ resources: AppResource, HomeTitle"
Description = "$ resources: AppResource, HomeDesc">
The corresponding name/ID in the resource file should be HomeTitle and HomeDesc.
The second method is to use different SiteMapProvider for different cultures/languages, but I think it is better than the above method. First, add the custom SiteMapProvider in web. config, as shown below.
<SiteMap>
<Providers>
<Add name = "AspNetXmlSiteMapProvider_zhCN"
Type = "System. Web. XmlSiteMapProvider, System. Web ,..."
SiteMapFile = "sitemap. Zh-CN.xml"
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.