0

I am making Multilingual typing tutor and want to change input language from code, but the languages are NOT on the language bar (they are installed in the OS but i only have English showing in language bar) I tried the following code but it didn't work..

System.Globalization.CultureInfo my_culture = new System.Globalization.CultureInfo("fr-FR");
InputLanguage c = InputLanguage.FromCulture(my_culture);
InputLanguage.CurrentInputLanguage = c;

Note that i do not want the end-user to first get those languages in language bar and then work.. In this case, I want to type in french but i'm unable to do so.. PLEASE HELP ME FRIENDS

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Solat Ali
  • 39
  • 1
  • 6
  • 2
    I don't think it's possible. You'll have to first make that language appear in the language bar. – Shadow The GPT Wizard Nov 06 '13 at 09:26
  • But i've seen applications e.g Inpage in which you could type in arabic even if arabic is not showing in language bar.. ANY METHOD? Can you give information about any sort of KEYBOARD MAPPING i could do ? Thanks for reply – Solat Ali Nov 06 '13 at 14:06
  • There are ways to use custom fonts that aren't even installed on the machine, e.g. [this one](http://stackoverflow.com/questions/4411067/c-sharp-how-to-use-a-custom-font-without-installing-it-in-the-system). [Another one](http://www.emoticode.net/c-sharp/load-custom-ttf-font-file-and-use-it-on-any-winform-controls.html) (untested) – Shadow The GPT Wizard Nov 06 '13 at 14:09
  • You said in earlier post to "make language appear in language bar" how to do it PROGRAMMATICALLY?? THANKS – Solat Ali Nov 06 '13 at 14:42
  • I don't know, would have posted it as answer but couldn't find while searching. But if you'll do this, you'll then be able to change input language. – Shadow The GPT Wizard Nov 06 '13 at 14:47

1 Answers1

1

I know its late but I found this code work for me:

    var culture = System.Globalization.CultureInfo.GetCultureInfo("fa-IR");
    var lang = InputLanguage.FromCulture(culture);
    if(InputLanguage.InstalledInputLanguages.IndexOf(lang) >= 0)
    {
        InputLanguage.CurrentInputLanguage = InputLanguage.InstalledInputLanguages[InputLanguage.InstalledInputLanguages.IndexOf(lang)];
        System.Threading.Thread.CurrentThread.CurrentCulture = culture;
    }
    else
    {
        InputLanguage.CurrentInputLanguage = original;
    }

Thanks to Change Language in C#

Community
  • 1
  • 1
Yashar Aliabbasi
  • 2,663
  • 1
  • 23
  • 35