-
Notifications
You must be signed in to change notification settings - Fork 218
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
Requirements for New Localization Extension Point #344
Comments
I think a well working implementation is like the System.ComponentModel.DataAnnotations; [Display(ResourceType=typeof(DisplayResources), Name="LName", Description="LNameDescription")] |
So where are we on this topic? Currently I'm forced to modify MvcSitemapProvider source code and manually reference custom .dll files which is no good |
@herrquark - This implementation has not yet been started, and my current schedule doesn't allow much time to work on MvcSiteMapProvider. However, there is no reason to modify the source code and compile your own version of MvcSiteMapProvider in order to implement this functionality. Also, this is exactly the way it was done in MvcSiteMapProvider v3.x, which is why this extension point hasn't been given a higher priority. Current Approaches for Accessing External ResourcesIf you are using external DI. All you need to do is implement Alternatively, you could implement a ResourceProviderFactory as specified in the MSDN documentation to provide resources from an external assembly for your entire application (whenever you call GetGlobalResourceObject). Since MvcSiteMapProvider calls HttpContext.GetGlobalResourceObject it will automatically use your implementation. You can plug your implementation directly into ASP.NET by using the <globalization uiCulture="auto" culture="auto" resourceProviderFactoryType="CustomResourceProviders.ExternalResourceProviderFactory, CustomResourceProviders, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f201d8942d9dbbb1" />
|
It has been brought to my attention that using Local and Global resources in conjunction with MVC is difficult to do and is best avoided because the way the default settings are set up by Visual Studio when adding these resource files will not compile down to something that can be accessed via MVC. Also there were a few requests from people who want to provide their localized resources in a separate library from the MVC application, and the current proposed way is not very flexible in that it
With that in mind, I think it is time to create a new extension point that accounts for these limitations and makes use of modern techniques and extension points of ASP.NET that are commonly used by MVC (without dropping support for the existing functionality).
I am not really a subject matter expert on globalization, so I would really appreciate any feedback on what use cases need to be solved for and how best to tackle them.
In reading Microsoft's extensive document on ASP.NET localization, I notice that there are actually 2 extensibility points that ASP.NET provides:
If I understand correctly, the second extension point is designed to plug directly into ASP.NET and affects the HttpContext.Current.GetGlobalResourceObject method (which MvcSiteMapProvider already uses). Therefore, implementing these abstractions and then providing them via web.config is and always has been an option for providing resources in a separate assembly (even if not using DI). Also, it wouldn't make sense for MvcSiteMapProvider to utilize IResourceProvider or ResourceProviderFactory directly since these plug into ASP.NET.
So (I think) the only real nut to crack here is how to make it simple to extend MvcSiteMapProvider to allow the user to supply resources from assemblies that are external to the ASP.NET application in an extensible way. Let's start with a list of requirements. Feel free to add or provide feedback on the requirements list - I will update the list in this 1st post as the feedback rolls in so it is easy to read in one place.
My current thinking is to add this extensibility point as a constructor argument to the default StringLocalizer class, replacing the explicit call to httpContext.GetGlobalResourceObject with the new provider. Essentially, that means that this feature can be added in a minor version without dropping support for any existing code that relies on the current implementation.
The text was updated successfully, but these errors were encountered: