locked
Resource files for translation RRS feed

  • Question

  • User628554914 posted

    Hi!

    I'd like to make a site with multiple languages, but I don't have the full Visual Studio suite. I'm using VWD Express. I was wondering if I still can use resource files for translation. It's will probably require some more manual labour, but is it possible to have several resource files and a session variable to decide which resource file to use? On the master page you'd have for example a dropdownlist to choose the language... Or what is another way to do it "manually"?

    Thanks for any replies!

    Thursday, October 21, 2010 9:01 AM

Answers

  • User1266497125 posted

    When you create a web project or web site, you can right click on the project name and choose Add ASP.NET Folder. From the menu select App_LocalResources and/or App_GlobalResources.

    Inside the App_LocalResources you will put the translation of your page. Let's say that you have a page called UserInformation.aspx and you want to localize this page. Right click on App_LocalResources folder and choose Add New Item... When an Add New Item - Resources dialog box appears choose Resource File and name your file as UserInformation.aspx.<language>.resx. For example, <language> can be en-US for US English, en-UK for the UK, fr-FR for French, etc.

    Now fill the Name of the control and its property and enter a translation in the Value part.

    Your next step is to modify the page. For example, to modify the Text property of a label you would declare the label like this <asp:Label ID="lblInfo" runat="server" Text="<%$ Resources:InfoTitle %>

     

    The biggest part of your work will be to specify how to detect language settings. Will you let a user specify the language via a drop-down box or will you let the user specify in the browser the languages that it accepts, or you could set the globalization settings in web.config or by using <%@ Page Culture="" CultureUI="" %>

     

    This is a pretty big subject and you should check MSDN for more information or get a book ASP.NET 3.5 or 4.0 Unleashed by Stephen Walther.

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

    Amazon: http://www.amazon.com/ASP-NET-4-Unleashed-Stephen-Walther/dp/0672331128

    Take care,

    Huske 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 26, 2010 8:31 AM

All replies

  • User1266497125 posted

    When you create a web project or web site, you can right click on the project name and choose Add ASP.NET Folder. From the menu select App_LocalResources and/or App_GlobalResources.

    Inside the App_LocalResources you will put the translation of your page. Let's say that you have a page called UserInformation.aspx and you want to localize this page. Right click on App_LocalResources folder and choose Add New Item... When an Add New Item - Resources dialog box appears choose Resource File and name your file as UserInformation.aspx.<language>.resx. For example, <language> can be en-US for US English, en-UK for the UK, fr-FR for French, etc.

    Now fill the Name of the control and its property and enter a translation in the Value part.

    Your next step is to modify the page. For example, to modify the Text property of a label you would declare the label like this <asp:Label ID="lblInfo" runat="server" Text="<%$ Resources:InfoTitle %>

     

    The biggest part of your work will be to specify how to detect language settings. Will you let a user specify the language via a drop-down box or will you let the user specify in the browser the languages that it accepts, or you could set the globalization settings in web.config or by using <%@ Page Culture="" CultureUI="" %>

     

    This is a pretty big subject and you should check MSDN for more information or get a book ASP.NET 3.5 or 4.0 Unleashed by Stephen Walther.

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

    Amazon: http://www.amazon.com/ASP-NET-4-Unleashed-Stephen-Walther/dp/0672331128

    Take care,

    Huske 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 26, 2010 8:31 AM
  • User628554914 posted

    Thanks! 

    Wednesday, October 27, 2010 1:53 AM