- The Case for Control Adapters
- Making a Control Adapter
- Building the TranslationControlAdapter
- Understanding Translation
- Configuring Your Control Adapter
- Conclusion
- Further Resources
Configuring Your Control Adapter
Once we’ve created the TranslationControlAdapter, we need to bind it to various controls on a page. Keep in mind that the TranslationControlAdapter is designed to support any control that has a Text property. Therefore, the TranslationControlAdapter can be used with TextBox, Label, Button, or LinkButton controls, as well as for the SimpleText control that we used as a preliminary demo sample earlier in this article. Remember from our description above that you bind a control adapter to a control by way of the application’s .browser file(s). Listing 9 shows the contents of the FireFox.browser file that’s part of the sample code for this article. FireFox.browser contains the configuration that adapts the TranslationControlAdapter to TextBox, Label, Button, LinkButton, and SimpleText web controls.
Listing 9 This .browser file tells Firefox to apply the TranslationControlAdapter to web controls.
<browsers> <browser refID="MozillaFireFox"> <controlAdapters> <adapter controlType="System.Web.UI.WebControls.TextBox" adapterType="CogArtTech.Web.ControlAdapters.TranslationControlAdapter"/> <adapter controlType="System.Web.UI.WebControls.Label" adapterType="CogArtTech.Web.ControlAdapters.TranslationControlAdapter"/> <adapter controlType="System.Web.UI.WebControls.Button" adapterType="CogArtTech.Web.ControlAdapters.TranslationControlAdapter" /> <adapter controlType="System.Web.UI.WebControls.LinkButton" adapterType="CogArtTech.Web.ControlAdapters.TranslationControlAdapter"/> <adapter controlType="CogArtTech.Web.Controls.SimpleText" adapterType="CogArtTech.Web.ControlAdapters.TranslationControlAdapter"/> </controlAdapters> </browser> </browsers>
Once you’ve configured the .browser file(s), you’re set to go.
Opportunities for Improvement
The TranslationControlAdapter provides useful functionality at a version 1 level. Yet there are enormous opportunities for improvement:
- The TranslationControlAdapter has a strong dependency that the BabelFish site be accessible and running. Clearly, the next version of the TranslationControlAdapter needs to be more robust in terms of accommodating and reporting system failures related to BabelFish access.
- The present version of the TranslationControlAdapter does a roundtrip callback for each control on a page. The number of callbacks required to accommodate all the controls on a page creates serious performance issues. This issue should be addressed in the next version.
- To be really useful, the next version of the TranslationControlAdapter should accommodate all web controls that render output text—not just controls that have a Text property.