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

Resource from different assembly #109

Closed
minXak opened this issue Dec 4, 2012 · 5 comments
Closed

Resource from different assembly #109

minXak opened this issue Dec 4, 2012 · 5 comments

Comments

@minXak
Copy link

minXak commented Dec 4, 2012

Hi,

Is there any way to access Resources for sitemap from different Project/assembly?

Thanks a lot for any advice.

@NightOwl888
Copy link
Collaborator

This is really more of a .NET question than an MvcSiteMapProvider question. If I understand correctly, this can be done by implementing your own resource provider.

http://stackoverflow.com/questions/3395009/localization-of-web-sitemap-using-a-resx-file-in-other-project
http://msdn.microsoft.com/en-us/library/aa905797.aspx

For now, I am marking this issue closed. Feel free to reopen it if you have any new information related to this topic.

@Prado
Copy link

Prado commented May 5, 2014

I wonder if anyone did this.
I'm using MvcSiteMapProvider v4.4.8.0 in a MVC4 project with .net attributes.
I followed the article mentioned above from MSDN, but after that, how can you point the Title from MvcSiteMapNode to be something from my Resources which are in another project?
Do I need to use other attributes, such as ResourceKey?

Edit:
Forget it.
I erased all the ExternalResourceProvider code and just used the Title attribute on the DisplayTemplates views to call the Resources with that key. It worked for me and I can't see any upside downs.

@NightOwl888
Copy link
Collaborator

Actually, I don't know the answer to your question because I have never implemented a resource provider myself, but this post may help. It looks like you just add the resource provider into the web.config file to get it working.

If you prefer something more lightweight than Microsoft's extension point, you could implement IStringLocalizer and inject your implementation with DI.

The downside to using the DisplayTemplates to do it is that you will have to add localization code in multiple places and any explicit usage of the ISiteMapNode instance won't be localized automatically. Besides the Title property, the Description, ImageUrl, and custom attributes are also localizable properties.

@NightOwl888
Copy link
Collaborator

I have posted a working example on StackOverflow of how to create a IStringLocalizer implementation that is based on Microsoft's ResourceManager extension point. It includes a sample of how you might use a resource from another assembly. It isn't the most extensible design - you can only use 1 assembly and 1 resource file - but it will work if that is all you need.

@NightOwl888
Copy link
Collaborator

FYI - I have opened a new issue #344 to gather requirements to address this issue better. Your feedback is appreciated.

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

No branches or pull requests

3 participants