It's easy to localize images for ASP.NET applications, yet I seem to find this a common question / issue on newsgroups, localization articles, etc.
You can localize images for ASP.NET applications simply by using string resources in your .resx files. Your resource values can represent the paths to your images.
You should also have a directory structure that supports your language specific content. For example:
$webapproot/content/<language>
Here's a more fully blown example:
$webapproot/content/en-CA/
/images/
$webapproot/content/fr-CA/
/images/
Etc.
The rest is just simply a matter of creating your string resources in your .resx files and then you can use implicit / explicit localization expressions. Here is an example of an image with an explicit localization expression:
<asp:image id="Image1" runat="server" imageurl="">" alt="<%$ Resources:Glossary, Instructions %>" />
The expression above shows how to use a resource entry for your ImageUrl and also the "alt" text for the image. You can also use implicit resources to do the same.
With the example above you would need to have .resx files called Presentation.resx and Glossary.resx (normally under /App_GlobalResources/). The files would need to have a string resource for the key Page_TestTaker_Instructions_InstructionsTitleImage. The value for the keys would be like so:
In Presentation.en-ca.resx:
~/Content/en-ca/images/someimage.jpg
In Presentation.fr-ca.resx:
~/Content/fr-ca/images/someimage.jpg
You're not stuck with using the
<img src="http://www2.blogger.com/%3Casp:localize%20runat=" text="" />" />" alt="<asp:localize runat="server" text="">" />" />
As you can see it gets a little messy looking but it's doable.
Here are some good resources on localization. Michèle Leroux Bustamante has written some excellent localization articles.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/ASP2local.asp
http://msdn2.microsoft.com/en-us/library/aa905797.aspx
http://www.theserverside.net/tt/articles/showarticle.tss?id=LocalizationPractices
Finally, I tend to disagree with Ted Pattison's comments on image localization at http://msdn.microsoft.com/msdnmag/issues/06/08/BasicInstincts/#S6. I think that he wrote his article coming more from a windows application development perspective which is why he took the approach that he did.
Happy Localizing!
January 30, 2007
ASP.NET 2.0 Image Localization Strategies
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment