Translate TextBox Text using Google Translate API in ASP.Net

Last Reply on Apr 17, 2014 08:58 AM By Azim

Posted on Apr 17, 2014 08:42 AM
Respected Sir,
I want use Google API to Translate  the English to Marathi and vice-versa.

this below code successfully run .but i want to the use a  TextBox control to

 <textarea id="transliterateTextarea" style="width:600px;height:100px"></textarea>

replce the this code like wise

<asp:TextBox ID="transliterateTextarea" runat="server"></asp:TextBox>

 Please help me

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="googleAPI.aspx.cs" Inherits="WebApplication1.googleAPI" %>

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

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <script type="text/javascript" src="https://www.google.com/jsapi">
    </script>
    
      <%--<script type="text/javascript">--%>
      <%--<script type="text/javascript" src="google.js"></script>--%>
 <%--   </script>--%>
    <script type="text/javascript">
        // Load the Google Transliterate API
        google.load("elements", "1", {
            packages: "transliteration"
        });

        function onLoad() {
            var options = {
                sourceLanguage:
                google.elements.transliteration.LanguageCode.ENGLISH,
                destinationLanguage:
                [google.elements.transliteration.LanguageCode.MARATHI],
                shortcutKey: 'ctrl+e',
                transliterationEnabled: true
            };

            // Create an instance on TransliterationControl with the required
            // options.
            var control =
            new google.elements.transliteration.TransliterationControl(options);

            // Enable transliteration in the textbox with id
            // 'transliterateTextarea'.
            control.makeTransliteratable(['transliterateTextarea']);
          

        }
        google.setOnLoadCallback(onLoad);
    </script>    
  </head>
  <body>  
    <span> English to Marathi</span><br>
    <textarea id="transliterateTextarea" style="width:600px;height:100px"></textarea>
  </body>
</html>
Posted on Apr 17, 2014 08:58 AM

HTML:

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="https://www.google.com/jsapi">
    </script>
    <script type="text/javascript">
        // Load the Google Transliterate API
        google.load("elements", "1", {
            packages: "transliteration"
        });

        function onLoad() {
            var options = {
                sourceLanguage:
                google.elements.transliteration.LanguageCode.ENGLISH,
                destinationLanguage:
                [google.elements.transliteration.LanguageCode.MARATHI],
                shortcutKey: 'ctrl+e',
                transliterationEnabled: true
            };

            // Create an instance on TransliterationControl with the required
            // options.
            var control =
            new google.elements.transliteration.TransliterationControl(options);

            // Enable transliteration in the textbox with id
            // 'transliterateTextarea'.
            control.makeTransliteratable(['transliterateTextarea']);


        }
        google.setOnLoadCallback(onLoad);
    </script>
</head>
<body>
    <span>English to Marathi</span><br>
    <form runat="server">
    <div>
        <asp:TextBox ID="transliterateTextarea" runat="server" TextMode="MultiLine" Rows="5"
            Columns="50" />
    </div>
    </form>
</body>
</html>

Image:

Thank You.

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html