Sitemap Providers are a nice feature of asp.NET 2.0, especially with the possibilities to develop your own custom providers.

One problem I faced is the ability to localize title, description .. for my custom provider.
After goggling a lot, I found… that I was not alone with that problem, and that nobody had posted the solution online

(The only solutions that I found were quirky fixes, like programmatically parsing the sitemap nodes title at page load, without using the built-in localization system…)

I found tips here .. And the solution is darn easy:

In your custom provider, in the method

Public Overrides Function BuildSiteMap() As System.Web.SiteMapNode

Load your sitemap nodes using the following method

Public Sub New( _
ByVal provider As SiteMapProvider, _
ByVal key As String, _
ByVal url As String, _
ByVal title As String, _
ByVal description As String, _
ByVal roles As IList, _
ByVal attributes As NameValueCollection, _
ByVal explicitResourceKeys As NameValueCollection, _
ByVal implicitResourceKey As String _
)

 

instead of the commonly used method

Public Sub New( _
ByVal provider As SiteMapProvider, _
ByVal key As String, _
ByVal url As String, _
ByVal title As String
)

In my case in use the implicitResourceKey to pass the resource name,
and my custom localization provider (sql resources) does the rest…

Dim node As New SiteMapNode(Me, key, url, title, string.empty, Nothing, Nothing, Nothing, {title resource name})

 

And then tell your application that your custom sitemap is localized by setting the enableLocalization="true"

<siteMap defaultProvider="MyCustomSiteMapProvider" enabled="true">
            <providers>
                    <add name="MyCustomSiteMapProvider" type="MyCustomSiteMapProviderType, MyCustomSiteMapProviderType.dll"  enableLocalization="true"/>
                      </providers>
        </siteMap>
 

 

Edit 30 Jan. : the first visitor coming on a page receives the correct language, but then the sitemap does not localize to the other languages!!!
I gave up, and now I populate the nodes’ text at runtime…

Protected Sub TopMenu_MenuItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs) Handles TopMenu.MenuItemDataBound
Dim n As SiteMapNode = CType(e.Item.DataItem, SiteMapNode)
Dim title As String = GetGlobalResourceObject("resource", n.ResourceKey)
e.Item.Text = title 
End Sub