locked
Resource files - Multilingual app RRS feed

  • Question

  • Can somebody show me a very basic implmentation of using resource files for my UI, based of user preference.

    Note: Ive never worked with resources files before for creating a multi-lingual app.

    Wednesday, December 8, 2010 8:50 PM

Answers

  • Hi,

    Visual Studio will create a default Resources.resx file in your project's properties folder. You can use the strongly typed resource created to access the strings, images, audio, files, ect in the resx. Here is a snippet:

    private void LocalizeStrings(string configuredCulture)
        {
          //configureCulture should be the name of your desired culture, such as en-US, de-DE, ect.
          Thread.CurrentThread.CurrentUICulture = new CultureInfo(configuredCulture);
    
          string value = Tester.Properties.Resources.MyApplicationDescription;
    
          //localize other strings, images, ect.
        }
    You can read Localizing Applications and Packing and Deploying Resources for more information.

    Let me know if I am not making sense and good luck!

    -Scosby

    • Edited by Scosby Wednesday, December 8, 2010 9:18 PM Added CurrentUICulture to snippet
    • Marked as answer by eryang Monday, December 20, 2010 4:51 AM
    Wednesday, December 8, 2010 9:14 PM

All replies

  • Hi,

    Visual Studio will create a default Resources.resx file in your project's properties folder. You can use the strongly typed resource created to access the strings, images, audio, files, ect in the resx. Here is a snippet:

    private void LocalizeStrings(string configuredCulture)
        {
          //configureCulture should be the name of your desired culture, such as en-US, de-DE, ect.
          Thread.CurrentThread.CurrentUICulture = new CultureInfo(configuredCulture);
    
          string value = Tester.Properties.Resources.MyApplicationDescription;
    
          //localize other strings, images, ect.
        }
    You can read Localizing Applications and Packing and Deploying Resources for more information.

    Let me know if I am not making sense and good luck!

    -Scosby

    • Edited by Scosby Wednesday, December 8, 2010 9:18 PM Added CurrentUICulture to snippet
    • Marked as answer by eryang Monday, December 20, 2010 4:51 AM
    Wednesday, December 8, 2010 9:14 PM
  •  

    We temporarily mark a reply since the thread idle for a long time, please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.


    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, December 20, 2010 4:50 AM