Wednesday 17 April 2013

Hindi Textbox [Multilingual Infact] Using Google Transliteration in ASP.Net


Hindi Textbox [Multilingual Infact] Using Google Transliteration in ASP.Net


Today I am going to show you how to create a textbox which will take input in any language using Google Transliteration API... This is how we can do this:



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Transliterate.aspx.cs" Inherits="Transliterate" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
    <title></title>
    <script src="https://www.google.com/jsapi" type="text/javascript">
    </script>
    <script type="text/javascript" language="javascript">
    google.load("elements", "1", {
    packages: "transliteration"
    });
     
    function onLoad() {
    var options = {
    sourceLanguage: google.elements.transliteration.LanguageCode.ENGLISH,
    destinationLanguage: [google.elements.transliteration.LanguageCode.HINDI],
    shortcutKey: 'ctrl+g',
    transliterationEnabled: true
    };
     
    var control = new google.elements.transliteration.TransliterationControl(options);
    control.makeTransliteratable(['TextBox1']);
    //TEXT1 is the id of the control which you will use for the transliteration.
    }
    google.setOnLoadCallback(onLoad);
    </script>
    </head>
    <body >
    <form id="form2" runat="server">
    <div>
    <div class="Google-transliterate-Way2blogging">
    
        <asp:TextBox ID="TextBox1" TextMode="MultiLine" Width="600" Height="200" runat="server"></asp:TextBox>
     
    </div>
    </div>
    </form>
    </body>
    </html>



4 comments:

  1. it works very nice sir.... thanks

    ReplyDelete
  2. really good post.but i need this transliteration for multiple text boxes .I will enter in one text box the transliteration should come on another text box.I searched on google i got only for one text box but i need multiple text boxes.
    Thanks
    Please if possible for you than please post that code.

    ReplyDelete
  3. Hi Sayyed, For Multiple textboxes you need to pass the name of the various textbox controls for which you need to implement transliteration like as shown below:

    var control = new google.elements.transliteration.TransliterationControl(options);
    control.makeTransliteratable(['TextBox1','TextBox2']);

    Where Textbox1 and Textbox2 are two controls in the same form. Thanks

    ReplyDelete

Thank You for Your Comments. We will get back to you soon.

back to top