Last post Jul 30, 2008 12:53 PM by xavierx
Jul 30, 2008 12:06 PM|xavierx|LINK
Dim RM As ResourceManager = New _
Label1.Text = RM.GetString("Please give us your comments")
Label2.Text = RM.GetString("Name (optional)")
Button1.Text = RM.GetString("OK")
I was curious if someone can tell me how the GetString works.
I guess i understand that you pass it the string and it finds the data name=" tag associated with that string
However, I was trying to implement something similar with an xml file in Classic ASP and the only way i can think of was using GetElementByTagName and looping through all items until it matched the search string.
my xml was pretty much structured like
<data name ="word 1">
<data name ="word 2">
and so i had to do getelementbytag("data") and loop from there
It seems like the GetString method for .Net just finds that exact item you need thus cutting down search time
Jul 30, 2008 12:29 PM|dinoboy|LINK
As far as I know, with built-in resource managers, a class is built on top of the resource file. When class is initialized, the underlyng resource is read and cached into hashtable.
I think the framework will also cache the resource manager to speed things up even more.
Also from .resx files there will be compiled strongly-typed class containing all the keys and values.
Correct me if I'm wrong :)
Jul 30, 2008 12:33 PM|xavierx|LINK
Ahh that makes a lot of sense why it is almost instant.
Right now i just have a field with the english text and translated text in other fields and just have each label or content wrapped in a function like getstring or getlabel where it will just do a select statement to retrieve the proper translation based
on the language chosen.
I was trying to minimize db call overhead as each label would be a new call to the db. I thought i can do it in an xml which caused another issue of loading the whole file into an object and correct me if i'm wrong but its like 4 times the filesize or something.
In addition with a lot of labels and an iterative loop it would take some time perhaps.
It sucks also because i am in Classic asp . Any suggestions as to how else i can localize my classic asp pages?
Jul 30, 2008 12:48 PM|dinoboy|LINK
I'm not very familiar with classic ASP, but can you just read the file once and cache it in some other more-readable and quicker format?
Jul 30, 2008 12:53 PM|xavierx|LINK
Hmm I was just collaborating with a buddy and thought that maybe i can create a webservice of asp.net and call it from classic, i'm not really sure how i would go about this or if i am talking about some voodoo coding that doesnt exist but it sounds plausible