Image localization in asp.net

爷,独闯天下 提交于 2019-12-22 18:06:50

问题


I have a web application which needs to support multiple languages. We currently have quite a lot of images on the site with text in them. Im trying to find a way to localize these images with the least amount of hassle. What i have come up with so far is to add sub folders to the current /Images folder which relate to the required language. So for example /Images contains the default set of images and /Images/es-MX contains the Spanish-Mexican localised images.

All pretty standard so far i think. Now the issue i have is that in order for this new structure to work i need to add the following to all img tags:

<img ... src="/images/<%= GetGlobalResourceObject("MyResource","IMAGEPATH").ToString() %>image1.gif" ../>

Or in the case of asp:ImageButton i need to programmatically set their ImageURL in codebehind with a utility method that replaces the /Images/ with /Images/es-MX or whatever the culture happens to be.

All of this leaves me with messy markup and lots of codebehind calls just to correct the image path. I ask you dear reader, is there a better way?


回答1:


Here is a good article from MSDN on globalization in ASP.NET. It uses a resource file approach so I am not sure if that will work for you but here is the article:

http://msdn.microsoft.com/en-us/magazine/cc163566.aspx



来源:https://stackoverflow.com/questions/532276/image-localization-in-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!