views:

45

answers:

2

How can I automate searching for strings in all .cs files and add certain code for localization, where I can use a key in resource files. Lets say there is a

string s = "A" 

in cs files. I need to change it to something like

string s = ("A","ResourceFileKey")

and then add to the resource file keys with country specific values. Is there any tool available? Presently I am using macros and searching ...

A: 

You can write your own. Its a simple String.Replace call. Read your file using FileStream Execute ReadToEnd method and you'll get a string. Then use String.Replace on it which will again return you a modified string. Replace your file content with the new string and save.

S M Kamran
A: 

If you just want to get all string literals out of your C# code to put them into your resource file, I suggest not to parse your C# code, but the IL code generated by the C# compiler, that ist much (!) easier.

Here is a helpful link with some code showing how to parse IL code:

http://www.codeproject.com/KB/cs/sdilreader.aspx

That, of course, does not solve your problem how to modify your existing code.

Doc Brown