Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize .net resource files for different customer?

I have an asp.net mvc application which uses Resx files for different languages. The files are existing in Web project and another one service layer.

I want now to customize some labels for specific customer (they have accounts and login to our web app). Is it possible to to archive with less code change?

Have reached some articles like below but switch to use database seems require much work.

  • https://stackoverflow.com/a/19277221/4903729
  • or https://msdn.microsoft.com/en-us/library/aa905797.aspx
  • or http://afana.me/archive/2013/11/01/aspnet-mvc-internationalization-store-strings-in-database-or-xml.aspx/

It seems using a custom resource provider to load customer based resx files could help but the difficulty I am thinking of is:

  • how to pass customerID to the resource provider.
  • how to load resource dll file from custom directory like \bin\de\customer1*.resources.dll or \bin\it\customer1*.resources.dll
like image 737
hazjack Avatar asked Jan 01 '26 17:01

hazjack


1 Answers

So well I have a solution working ! (based on the post from Afana), code change should be very less (create xml files, run ResourceBuilder.exe).

What I did customize is just little:

  • Modify the ResourceBuilder to generate all keys in a partial class
  • Manually create Resources.provider.cs which instantiates XmlResourceProvider for individual customer or accepts default xml resource

enter image description here

  • If this helps here is the poc - change CustomerId / uiCulture to test.
like image 163
hazjack Avatar answered Jan 04 '26 17:01

hazjack



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!