-
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
Localization without .resx files #364
Comments
At present, the only way to change the source the resources are read from is to implement your own IStringLocalizer. To inject your implementation, you will need to switch to using external DI for MvcSiteMapProvider if you are not already using an external DI package. If you are already using DI in your project, you can just upgrade to one of the modules-only packages (the one that matches the DI container you are using) and follow the instructions in the Readme file to integrate the module with your DI setup.
Replace the x with your MVC version and the containerName with the container that you are using. If you are not currently using DI, it is simpler - just pick a DI container and upgrade to the full DI package that contains a composition root. This will wire up a fully functional DI configuration for you.
Note that although it doesn't make much difference which DI container you use, we make the assumption that you already know the syntax to configure it. Most of the documentation examples are provided using the StructureMap DI container. I have posted an IStringLocalizer based on ResourceManager to show how this can be done, including the changes you will need to make to the DI module (StructureMap example shown). There is also a working demo application. Unfortunately, this really wasn't meant to be an extension point for 3rd parties to inject their own localization source, so there is some logic from the original StringLocalizer that you need to duplicate in order for it to function. We are currently gathering requirements to build a new localization extension point as a first class feature, and your feedback is welcome. |
Hello, I have same problem. I using Autofac for dependency container. And I want use my own string localization on sitemap titles(not resource file). Anyone succed it? |
Hi,
I am using mvcSiteMapProvider for breadcrumbs in my project. For localization, I am fetching the resources from the database on start of the application and then filling up the cache (
System.Web.HttpContext.Current.Cache["languageList"]
) containing the resources' key-value pair.As I am using this approach to localize the website, I do not want to create resource files just for mvcSiteMapProvider. So, how can I localize the breadcrumbs without using the Global Resource files?
The text was updated successfully, but these errors were encountered: