Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

End user wants to add languages dynamically to his website

We have to build an event registration website for our client in ASP.NET using C#. One of the requirements is that the client wants to add new foreign languages to his website himself using en excel file. I know how to make a website multilingual in Visual Studio, but I have no idea how to generate a resource file based on an excel file in code. I also noticed VS generates a second file called Resource.en.designer.cs but I can't find any documentation how to generate that file either.

btw, the enduser is anything but IT-related. He knows his way around excel though (obviously).

Any help is appreciated!

Yoeri

EDIT: !Robert Levy Provided a good method! HOW TO:

STEP 1: Read the excel file (using an OleDBAdapter was the best method for me, as you can use column headers etc) Write the language to a txt file in this format: KEY=TRANSLATION no spaces or anything else

STEP 2: Locate ResGen.exe on your computer (it comes with Visual Studio, so look somewhere like c:\program files\visual studio\sdk... however I found it @ C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\ResGen.exe)

STEP 3:

Invoke the exe with Process.Start("resgen.exe") hint: use ProcesStartInfo for easy argument and preferences settings

(STEP 4:)

Move the file to your desired location (I find the App_GlobalResources works perfectly)

STEP 5:

Set the user currentUIculture to your desired culture!

like image 229
Yoeri Avatar asked Nov 05 '22 00:11

Yoeri


1 Answers

ResGen.exe will compile resource files for you. You could either get him to deliver text files in the format used by that tool or write your own code that extracts from excel to generate the text files. Then just invoke this EXE and deploy your newly generated resource DLL. I am assuming you already know how to read things from resource files and use the appropriate one based on user preference.

http://msdn.microsoft.com/en-us/library/ccec7sz1.aspx

like image 152
Robert Levy Avatar answered Nov 09 '22 08:11

Robert Levy