Home > Uncategorized > Resource files for Classic ASP

Resource files for Classic ASP

I was looking to localize a classic ASP website, and was considering upgrading it to ASP.NET, but it seemed way too much work, so I decided to look to see if it was possible to create a localization framework for classic ASP. using the same type of resx files that are used for asp.net
So, given a simple piece of xml in semi-typical resx format:
 <data name="Hello!">
I then wrote an include file in classic asp, to handle translations in the form
(Precursed by a initResources("strings-it.xml"))
 Dim xmlResx
 Function initResources(ResourceFile)
  Set xmlResx=Server.CreateObject("Microsoft.XMLDOM")
 End Function
 Function Translate(english)
  Set objLst = xmlResx.getElementsByTagName("data")
  For i = 0 to (objLst.length -1)
    EnglishText = objLst.item(i).attributes.getNamedItem("name").text
 If english=EnglishText Then
  Translate= objLst.item(i).text
  Exit For
 End If
 End Function
20 Lines of code, prevented an overhaul of my application to .NET.
Ultimately, I plan this to be used for a spanish version of www.openmerchantaccount.com
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: