Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to make website for multiple languages

I have made a website using(Asp.net, c#) and its content in English. Now i have a requirement to make this website in such a way that is support multiple languages ie (German,French). Lable/Textbox/ string all values will display respective selected languages While searching i came to know there are some ways like

  • Using localization
  • Use resource file.
  • Database(every thing is saved in database for different language).

frankly speaking I am not agree with 3rd option.

I want to know which is the best way to go or is there any other better way?

Note:Current Website was built using .NET framework 4.0/ vs 2010.

Thanks

like image 828
Satinder singh Avatar asked May 10 '12 11:05

Satinder singh


People also ask

Can a website have multiple languages?

A multi-lingual website is a website where the content is written in more than one language. The information displayed in different languages is often the same, but maybe tailored for different audiences. Booking.com is an example of a multi-lingual website as its content is available in 35 different languages.

Can WIX do multiple languages?

Wix Multilingual supports over 100 languages, making it easy for site visitors from all over the world to engage with you. Click here to learn how to add Wix Multilingual.


2 Answers

Resx:

http://msdn.microsoft.com/en-us/library/ms227427.aspx

http://dreamdotnet.blogspot.com/2007/01/tutorial-translating-aspnet-web.html

You can use resx files for multiple languages and use the ResXResourceWrite to update them (if you want users to be able to update the files: http://msdn.microsoft.com/en-us/library/system.resources.resxresourcewriter.aspx)

This solution is only good for static content. If you want to be able to translate content from the database (for example if you have products stored in your database, and you want that the description of the product to be multilingual too). In this case you'll need to change you DB Scheme in order to support multilingual content.

PS you can use GetLocalResourceObject("key") in order to retrieve values without using web controls.

If you're using MVC, see the following question: How to localize ASP.NET MVC application?

like image 118
Standard Toaster Avatar answered Nov 07 '22 21:11

Standard Toaster


Sample code i have done using resource file add global.asax

 void Application_BeginRequest(Object sender, EventArgs e)
        {
            // Code that runs on application startup
            HttpCookie cookie = HttpContext.Current.Request.Cookies["CultureInfo"];
            if (cookie != null && cookie.Value != null)
            {
                System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(cookie.Value);
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(cookie.Value);
            }
            else
            {
                System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en");
                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en");
            }
        }
like image 38
Satinder singh Avatar answered Nov 07 '22 21:11

Satinder singh