c# - How to transliterate english text(input in textbox1) into hindi text(output in textBox2) using google transliterate API -
my question can type in english textbox , on pressing space or enter key can transliterate hindi(other language). requirement output should in textbox.
how possible?
here code transliterates same textbox
<div> <asp:textbox runat="server" height="30px" id="textbox1" width="200px" /> </div> <script> attachcontrolggltransliterate("textbox1"); </script>
this js(translt.js file) code provided google.
function loadgoogle() { try { if (google) { // load 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 instance on transliterationcontrol 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("~"); (i = 0; < listcontrols.length; i++) { control.maketransliteratable([listcontrols[i]]); }
https://developers.google.com/translate/v2/getting_started#workingwithdata need have license bought google use google translation api.
'https://www.googleapis.com/language/translate/v2?key=your-api-key&source=en&target=de&callback=translatetext&q=' + sourcetext;
Comments
Post a Comment