locked
can i change the language of any thing? RRS feed

  • Question

  • hi
    i want change the language of textBox or any thing in my form. how can i do?
    i want change the language automalically when the form is load
    (C# programming)
    Friday, February 9, 2007 7:28 AM

Answers

  • I think he needs to see the UI in some other language than english and also use some other language while TextBox or some input control has focus.

    You need to localize your application, See MSDN for localization.

    A quick guide:

    1. Create your application
    2. Put all needed controls to your Form
    3. Set their texts properly in english
    4. Now Change the Localizable property of Form to true.
    5. Next Change the Language property of your Form to the language you want.
    6. Now set text of each control of your applicaion again for new selected language.
    7. When done, set Form's Langauge property back to (Default)

    Your application is ready to be viewed in language of your choice but you need to set the culture of applicaiotn threads to the lenagugage you need.

    For example to use German langauge in my application I need to Add these lines to the start of the main Function:

    CultureInfo ci = new CultureInfo("de-DE");
    System.Threading.Thread.CurrentThread.CurrentCulture = ci;
    System.Threading.Thread.CurrentThread.CurrentUICulture = ci;

    Run the applicaiton, and its ready...

    Now the other part to use input language, I think for this you need to set input language from Windows:

    Regional and Language Options..

    There are also many things, I recomend you to do some study. Search Web "Localization in .Net" etc

    I hope this will help.

    Best Regards,

    Rizwan aka RizwanSharp

    Friday, February 9, 2007 5:14 PM

All replies

  •  

    What happens when you change the Culture of the current running thread. Is it able to get the language which is specified by current thread culture?

    Friday, February 9, 2007 9:34 AM
  • You need resource files (.resx) containing all the required strings for each language (one for English, one for Portuguese etc.) and then you need to access via your class.

    You'll need the System.Resources and the System.Reflection references.

    The actual resource file should be named in the following style: MyResources.[Language Culture code] in order to identify which language they are:

    Example: MyResources.fr-FR.resx is a french language resource file.

    Create a resource manager in your class (as follows):

    private ResourceManager resourceManager = new ResourceManager("MyNameSpace.MyResources", Assembly.GetExecutingAssembly());

    When retrieving a string from the resourceManager use:

    resourceManager.GetString("StringName", CultureInfo.CurrentCulture);

    ...and depending on the current culture of the machine (language settings in Windows) the correct language file is chosen to populate your controls.

    If you need anymore help, check out "String Localization" in the MSDN pages, or re-post here.

    Good luck,
    Paul
    Friday, February 9, 2007 9:35 AM
  • Hi

    What exactly do you want to change, is it the text in the textbox when the from loads or the language from english to other?

    Friday, February 9, 2007 9:35 AM
  • I think he needs to see the UI in some other language than english and also use some other language while TextBox or some input control has focus.

    You need to localize your application, See MSDN for localization.

    A quick guide:

    1. Create your application
    2. Put all needed controls to your Form
    3. Set their texts properly in english
    4. Now Change the Localizable property of Form to true.
    5. Next Change the Language property of your Form to the language you want.
    6. Now set text of each control of your applicaion again for new selected language.
    7. When done, set Form's Langauge property back to (Default)

    Your application is ready to be viewed in language of your choice but you need to set the culture of applicaiotn threads to the lenagugage you need.

    For example to use German langauge in my application I need to Add these lines to the start of the main Function:

    CultureInfo ci = new CultureInfo("de-DE");
    System.Threading.Thread.CurrentThread.CurrentCulture = ci;
    System.Threading.Thread.CurrentThread.CurrentUICulture = ci;

    Run the applicaiton, and its ready...

    Now the other part to use input language, I think for this you need to set input language from Windows:

    Regional and Language Options..

    There are also many things, I recomend you to do some study. Search Web "Localization in .Net" etc

    I hope this will help.

    Best Regards,

    Rizwan aka RizwanSharp

    Friday, February 9, 2007 5:14 PM