0

My question is We can type in english a textbox and on pressing space or enter key we can transliterate it into hindi(other language). But the requirement is that the output should be in another textbox.

How is that possible?

Here is my code which transliterates into same textbox

<div>
 <asp:TextBox runat="server" Height="30px" ID="TextBox1" Width="200px" />
</div>

<script>
   attachControlgglTransliterate("TextBox1");
 </script>

This is the js(translt.js file) code provided by google.

function loadGoogle() {
    try {
        if (google) {
            // Load the Google Transliterate API
            google.load("elements", "1", {
                packages: "transliteration"
            });
        }
        else setTimeout(function () { loadGoogle() }, 100);
    } catch (e) {
        setTimeout(function () { loadGoogle() }, 100);
    }
}
loadGoogle();

var gglTrnsLitrt = null;
// Create an instance on TransliterationControl with the required
// options.
var control = null;



function attachControlgglTransliterate(ctrl,language) {
  //  alert(1);
   // alert(ctrl.id);
 //   alert(language);
    try {
        if (control == null) {
            if (google.elements.transliteration != null) {

                if (language == "0") {
                    gglTrnsLitrt = {
                        sourceLanguage:
                        google.elements.transliteration.LanguageCode.ENGLISH,

                        destinationLanguage:
                        [google.elements.transliteration.LanguageCode.HINDI],


                        shortcutKey: 'ctrl+g',
                        transliterationEnabled: true

                    };


                    control = new google.elements.transliteration.TransliterationControl(gglTrnsLitrt);

                }

 }
            else { setTimeout(function () { attachControlgglTransliterate(ctrl,language) }, 1000); }
        }
    } catch (e) {
        setTimeout(function () { attachControlgglTransliterate(ctrl,language) }, 1000);
    }

    var listControls = ctrl.split("~");
    for (i = 0; i < listControls.length; i++) {
        control.makeTransliteratable([listControls[i]]);


    }
BenMorel
  • 34,448
  • 50
  • 182
  • 322

1 Answers1

0

https://developers.google.com/translate/v2/getting_started#workingWithData You Need To Have License Bought From Google to use Google translation API.

'https://www.googleapis.com/language/translate/v2?key=YOUR-API-KEY&source=en&target=de&callback=translateText&q=' + sourceText;