Click here to Skip to main content
Click here to Skip to main content

TextBox Accepting Regional Language Input (Malayalam)

, 20 Jun 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
Making a TextBox accept Regional Language Input (Malayalam)

Introduction

My attempt here is to give a tip to one of the most asked questions by beginners, "How to make language XXXXX as the input type to a Windows Form control?"

Background

I was developing a Windows Form application where the user input is in my mother tongue "Malayalam", but the issue is the user is not aware of Malayalam keyboard, so he wants a Google Transliteration type input... means the user will type the Malayalam words in English but the system will convert it to the Malayalam format. So I cannot simply set a font to the textbox. I downloaded and installed the Microsoft indic tool for malyalam.

Using the Code

Step 1: First create a Windows Form application with a textbox control in it.

Step 2: The Inputlanguage of the textbox must be Malayalam when the user starts typing and must change back to English when the user input is over. So create two events for Enter and Leave.

private void textBox2_Enter(object sender, EventArgs e)
{
           
}
private void textBox2_Leave(object sender, EventArgs e)
{
           
}

Step 3: Then, create a function to get the installed language:

public static InputLanguage GetInputLanguageByName(string inputName)
{
    foreach (InputLanguage lang in InputLanguage.InstalledInputLanguages)
    {
        if (lang.Culture.EnglishName.ToLower().StartsWith(inputName))
            return lang;
    }
    return null;
}

This function will get all the Inputlanguage which has the Name starting with the parameters given to the function.

Step 4: Create a function to set the keyboadlayout to the input language selected.

public void SetKeyboardLayout(InputLanguage layout)
{
    InputLanguage.CurrentInputLanguage = layout;
} 

Step 5: Finally, call the function inside the Enter and Leave event of the Textbox.

private void textBox2_Enter(object sender, EventArgs e) 
{
    SetKeyboardLayout(GetInputLanguageByName("mal"));
}
private void textBox2_Leave(object sender, EventArgs e)
{
    SetKeyboardLayout(GetInputLanguageByName("eng"));
}

Points of Interest

Here, I had used only one textbox control, we can use this in any Winform controls and also many other keyboards are available for free download over the web. So keeping this as a class and passing controls and the inputlanguagename as parameter will help in reducing code irrespective of control and language.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

SREENATH GANGA
Software Developer
United Arab Emirates United Arab Emirates
No Biography provided

Comments and Discussions

 
GeneralMy vote of 5 Pinmemberdeshjibon15-Jul-14 10:36 
GeneralMy vote of 5 Pinmemberishihidul14-Jul-14 15:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150327.1 | Last Updated 20 Jun 2014
Article Copyright 2014 by SREENATH GANGA
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid