by Dominic Zukiewicz
13. July 2007 14:54
Yesterday and today, the project I was working on required catering for Mandarin and English.
On my machine, the one I build the project on, the multi-lingual features worked fine, but after using the WDP (Web Deployment Projects) found that the site was always defaulting to English, even if the browser was configured as Chinese.
I worte a test page, which too confirmed the website was picking up the correct culture, but for some reason ASP .NET wasn't changing it.
After hours of torment, I found that 2 steps have to take place. One which I forgot to code (oops!) and one which sorted the problem once and for all.
1) Change web.config to automatically configure the language
<globalization culture="auto" uiCulture="auto"/>
2) Force the ResourceManager to use the correct language
For some reason, with the WDP this wasn't happening, so I have to specify it explicitilly:
protected override void InitializeCulture()
{
Resources.ProjectResources.Culture = Thread.CurrentThread.CurrentUICulture;
base.InitializeCulture();
}
It now works absolutely fine.
a1a82cc3-cf81-4009-9fb0-c09ec54ec1d9|0|.0
Tags: