Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization issues #483

Open
FrantisekBodnar opened this issue Oct 28, 2018 · 1 comment
Open

Localization issues #483

FrantisekBodnar opened this issue Oct 28, 2018 · 1 comment

Comments

@FrantisekBodnar
Copy link

Hi I would like to thank you for this library, it is great help in MVC application :)

But I found a several bugs MvcSiteMapProvider when I would like to use resource files for mvcSiteMapNode.

For Title & Description properties / attributes it works only with Explicit localization ($resources: ...).
When you try to use Implicit localization (use with resourceKey attribute), you will always get empty value or better say, it will return value specified in mvcSiteMapNode attribute in the XML sitemap file, but not from Resource file (in format ResourceKey.Attribute).

I checked the code, and the problem is that MvcSiteMapProvider.SiteMap class has invalid value in ResourceKey property, that returns SiteMapCacheKey (that is generated by ISiteMapCacheKeyGenerator.GenerateKey()) value that returns a string in format "sitemap://hostname/", but it should return Resource file Class Key (that is resource filename without resx extension). Without it, it will never return valid value from any Resource file.

public virtual string ResourceKey
{
	get
	{
		return this.siteMapSettings.SiteMapCacheKey;
	}
	set
	{
	}
}

For custom attributes in mvcSiteMapNode it doesn't work for any type of localization.
This time the problem is in MvcSiteMapProvider.Collections.Specialized.AttributeDictionary.Add() method, where is no reading from Resource file implemented at all (for Explicit & Implicit localization). It just parse string via MvcSiteMapProvider.Globalization.IExplicitResourceKeyParser.HandleResourceAttribute() method to determine if Explicit localization is used or not.

public void Add(string key, object value, bool throwIfReservedKey)
{
	if (this.reservedAttributeNameProvider.IsRegularAttribute(key))
	{
		if (value.GetType().Equals(typeof(string)))
			value = localizationService.ExtractExplicitResourceKey(key, value.ToString());

		if (!this.ContainsKey(key))
			base.Add(key, value);
		else
			base[key] = value;
	}
	else if (throwIfReservedKey)
	{
		throw new ReservedKeyException(string.Format(Resources.Messages.AttributeKeyReserved, this.siteMapNodeKey, key, value));
	}
}

Hopefully you would have time to fix it in next releases, so we can use the library with proper localization features. :)

Thanks for help
Franky

@snowfire20
Copy link

@FrantisekBodnar - have you received any updates on this issue?
I've been trying to get this working with the westwind db localization provider, and the resourceSet is always sitemap://hostname/.
is the only workaround to use explicit localization?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants