views:

126

answers:

1

How do I programmatically change the language used in WinXP using .Net 2.0 (or a pInvoke). The user does not have access to the task bar in the application I'm working on so the input method needs to reflect the application's selected language. I need to be able to swap the language from a left-to-right to a right-to-left and back again without restarting the application. Controls can be re-created though.

A: 

The language should be installed in the system, check the following code it's to change the language into Arabic in C#:

public void ToArabic()
 {
  string CName= "";
  foreach(InputLanguage lang in InputLanguage.InstalledInputLanguages) 
  {
   CName = lang.Culture.EnglishName.ToString();

   if(CName.StartsWith("Arabic"))
   {
    InputLanguage.CurrentInputLanguage = lang;
   }
  }

 }

to return it back into English

public void ToEnglish()
     {
      string CName= "";
      foreach(InputLanguage lang in InputLanguage.InstalledInputLanguages) 
      {
       CName = lang.Culture.EnglishName.ToString();

       if(CName.StartsWith("English"))
       {
        InputLanguage.CurrentInputLanguage = lang;
       }
      }

     }

you can use this code in your application to change the input language. Also the user can press alt + shift to change between the defined language in the system.

Wael Dalloul