Closed mkgn closed 3 years ago
Hello @mkgn ,
Well, I will try to assist you to better understand the code of XLocalizer.
Below is a brief of the contents of each package.
ExpressMemoryCache
EFResourceProvider
where the real interaction with DB is done.services.AddRazorPages()
.AddXDbLocalizer<DbContext>(ops => ...);
So, I think you may want to modify the caching system to have a different cache page for each tenant. Another part to customize could be in the DependencyInjection class of XLocalizer.DB, so instead of passing a DbContext
you may want to pass some tenant object I'm not sure, just brainstorming :)
I recommend that instead of modifying the original code, you can extend it by implementing its interfaces (IDbResourceManager
, IDbCultureManager
, etc.) to provide multi-tenant support. See the docs for some more details.
Last but not least, XLocalizerOptions
is another place to add extra options if necessary.
Let me know if you need any additional help,
Best, Ziya
Btw, all localization services IStringLocalizer
, IHtmlLocalizer
, RequestLocalizationOptions
, ...etc. are registered as singleton services. So it will not work as you expect! may be you should modify the code to register all related singleton services as TenantSingleton. Below articles may give an idea:
Issue is closed due to long time no activity.
Feel free to reopen if you need any further help.
BR, Ziya
Hello,
My question is about some guidance to see whether I can change your code so I can try to modify your code to support multi-tenancy. Let me brief my setup. I am trying to keep it simple and only considering storing strings (no localized icons, images etc.)
What I don't get is which parts in your code needs customizations to use the connection string dynamically. Basically resource should be loaded at the first request which is the only way to identify the tenant. So itll be the point whre it loads all resources fro that tenant and cache it for subsequent calls for that tenant. Ex:- a dictionary object with <key,resource collection> like <tenant1,tenant1resourcecollection>
If you can give me some pointers, I will try to manage it myself.