Compiling Resource file in a PreCompiled web site at the production server

So you have a precompile web site located on the customer's production server and you want few of the following:

  1. Allow the customer IT / PS to alter the resource you are using (without your help)
  2. Create a simple mechanism of updating the resource file without distributing a DLL.

To do a task like this you would probably create a provider for the localization and start coding you way threw the solution, I suggest another approach that is far more simple and doesn't require you / customer to deal with DLLs and also enable the customer's IT / PS to write an application that will enable him to edit the resource.

High Level Solution

on the production server you will have a directory that will hold all the pre compile RESX file + few utility classes that can be called in various ways (web page / schedule / exe , etc).

Few Words

  1. For simplicity you will only update a specific culture and not natural - the reason is that i don't want to start messing with a more complex compilation of a typed resource).
  2. The entire localization related files will stay with a new directory.
  3. You will have to have a new directory that will hold the pre compiled RESX (for each culture other than the natural as said in Pr.1)
  4. You will have to create a batch file / VBS that will do all the compilation and moving of the new resource.

Detailed Solution

  1. Create a new directory called "LocalizationKit" (This is for simplicity)
  2. Create a new directory under "LocalizationKit" called "Utilities" - this directory will hold all the files needed to compile the resource at the production server.
    Copy the following files to this directory:
    1. al.exe
    2. al.exe.config
    3. alink.dll
    4. alinkui.dll
    5. ResGen.exe
  3. On your post build event create a task that will copy each resource (related files) to a new directory under "LocalizationKit" based on the culture name (E.g. en-US, en-GB, etc)
  4. Create a batch / VBS file that will do the following for all the resources:
    1. Convert the RESX file to .resources using resgen (E.g. Resgen.exe [file.resx])
    2. Compile the relevant .resource files to one DLL (E.g. al.exe /nologo /t:lib /embed:[resource], [file name] /culture:[RESX culture] /out:App_GlobalResources.resources.dll
    3. Copy the newly created resource DLL to the relevant directory under the bin (E.g. ..\Bin\en-US\) [Make sure that the directory exist, if not than create it]
    4. Delete the ".Resource" file (not needed)

Now all that you have to do on your production server is to alter the relevant RESX file in the "LocalizationKit" directory and call the method before.

Using this solution you can give the customer the option to change keys in the resource without needing you / new code.

Hope this help you (if you want a sample directory mail me).

Compiling Resource file in a PreCompiled web site at the production server Compiling Resource file in a PreCompiled web site at the production  server Reviewed by Ran Davidovitz on 11:52 PM Rating: 5

6 comments:

Anonymous said...

Hello Ran,

I have been searching for this exact solution.
Can you send me your sample code?
eastburnj (at) quaero (dot) com

Josh

Jefferson said...

Hi, I am having a web application which has app_localresources per module, how can i do the same but in diferents folders?, do you have an example?.

Ran Davidovitz said...

Hi,

I dont have an example for that use case but i suggest that to:
1. Add the relevant RESX files to the original SLN and compile (to understand how the RESX should be embedded)
2. Alter the batch file to recursively take the relevant RESX file and embed them as needed

Post a comment after you finish, i am sure other want it :)

thanks

wow power leveling said...

welcome to the wow power leveling cheap Wow gold service site, buy cheap wow gold,wow gold,world of warcraft power leveling buy wow gold

Maqk said...

can you please provide details of these files and what is there role in this localization ?

al.exe
al.exe.config
alink.dll
alinkui.dll
ResGen.exe

Ran Davidovitz said...

ResGen - used to compile the txt resource to a resources file

AL - used to merge the resource into a DLL (loaded by ASP.NET)

other DLL are used by AL.EXE

hope that clarifies.

as a side note i would suggest to move to DB resource provider.

Powered by Blogger.