简体   繁体   中英

how to make multilingual site in asp.net

I am developing a site in asp.net in multiple languages but i didn't understand how this can be done because we can manage multilingual language by using resource files. we did this, but my major problem is that how we can change globalization at run time for a particular user. if A user choose English language then he/she can view this i English and if B user choose Spanish then he/she can view this site in Spanish. How we can do this? or how we can choose a particular language resource file???

use this code

protected override void InitializeCulture() 
{ 
    Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); //'en-US' these values are may be in your session and you  can use those
    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");//'en-US' these values are may be in your session and you  can use those
    base.InitializeCulture(); 
}

I had this same question when i started developing multilingual sites and i found those two articles as the best starting point:

http://www.codeproject.com/KB/aspnet/localization_websites.aspx http://www.codeproject.com/KB/aspnet/LocalizedSamplePart2.aspx

you could try something like this:

string culture = "en-US"; //could come from anything (session, database, control, etc..)

Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(culture);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);

I think it works!

you need to use localization for language and individual resource file. Now when your site is being access at client side you need to check the locale setting on client's machine his date/time setting and the Default language... on the basis of this you can provide language that user wish...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM