I’m mucking around today with some internationalization code in a control that is meant to take over localization instead of the standard resource providers pulling data from a database. I have most of this functionality working but now I’m trying to figure out some better ways to integrate this into the localization scheme.
Hooking up the functionality is not difficult thanks to the provider model that ASP.NET 2.0 has introduced which allows me to replace the existing ResourceManager with my own custom one. This makes it easy to hook up custom processing to any calls to Page.GetLocalResourceObject()/GetGlobalResourceObject() as well as the parsing of <%$ Resources:LinkButton1Resource1.Text %> expressions which gets a me a long way there.
However, one very cool feature that ASP.NET provides is the ability to use this construct:
which allows ASP.NET to automatically map a control and any resource properties. So if TextBox1 exists and has resources defined for TextBox1.Text and TextBox1.ToolTip both of these properties are automatically localized which results in generated code in the BuildControl_ code of the ControlTree:
box1.ToolTip = Convert.ToString(base.GetLocalResourceObject("TextBox1Resource1.ToolTip"),
box1.Text = Convert.ToString(base.GetLocalResourceObject("TextBox1Resource1.Text"),
Great, except that this appears to be a compile time feature with ASP.NET going out at compile time parsing the resource file and source code file and mapping these properties together. The meta: tag is stripped. This means this code is generated at compile time and if the ResourceKey doesn’t exist in the resource file nothing is generated.
Does anybody know if there’s some way to intercept this parsing mechanism in any way or some sort of interface that can be trapped to allow hooking into this and provide ASP.NET with a list of matches here in the same fashion?
I know that custom build providers can be plugged in for things like the <%$ Resources:LinkButton1Resource1.Text %> expressions, but I don’t think this applies to these meta tags.
Anybody have any idea where to look for this?