c# - Running HttpUtility.JavaScriptStringEncode on all references to Resources translations? -


long version

in web app work on, put our translations .resx files refer calling resources.filename.keyname (as specified in "to retrieve global resources using strong typing" section of http://msdn.microsoft.com/en-us/library/ms227982%28v=vs.100%29.aspx).

in places retrieve value directly, in lot of cases retrieve value used in javascript, need this: httputility.javascriptstringencode(resources.filename.keyname)

the problem there thousands of these kinds of lines need wrapped call httputility.javascriptstringencode retroactively.

there has better way rather going through entire source code , manually wrapping each reference resources.

tl;dr version

i need better way of wrapping each resources.filename.keyname call httputility.javascriptstringencode() manually going each reference , adding myself.

i unable come true solution decided solve using regular expressions.

now, problem still using visual studio 2010, has it's own subset of regex not compatible lot of advanced trickery, assertions not option.

instead, found instances of <resources\.thread.{[a-za-z0-9_]+} , replaced httputility.javascriptstringencode( resources.thread.\1 ).

this can create duplicate calls though if had few instances calling javascriptstringencode, unfortunately following had find instances of httputility.javascriptstringencode\(httputility.javascriptstringencode\( {[a-za-z0-9_ \.\)]+}\)\) , replace httputility.javascriptstringencode( \1).

the lack of space @ end of replace string inside parenthesis intentional formatting.

there other derivatives sort out (spaces between parenthesis) baseline. after few more searches clean duplicate calls, done.

not best work, best come short of upgrading visual studio 2012/2013 , using real regex assertions in 1 shot (which recommended if can it).


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -