Best way to make website for multiple languages

后端 未结 3 1768
星月不相逢
星月不相逢 2020-12-30 11:13

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 su

相关标签:
3条回答
  • 2020-12-30 11:56

    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?

    0 讨论(0)
  • 2020-12-30 12:01

    For dynamic content a thrid party plugin or a adding something such as Google translate would do it;

    http://translate.google.com/translate_tools

    FYI; Google Chrome has built in auto-translate and Chrome's popularity is growing fast... wow imagine a web where regardless of language you have access to ALL content this isn't that but I though I would share my thoughts

    0 讨论(0)
  • 2020-12-30 12:02

    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");
                }
            }
    

    Blog Article: How to create multilanguage website in Asp.net C#

    0 讨论(0)
提交回复
热议问题