【发布时间】:2014-03-10 10:09:03
【问题描述】:
我的问题是我们可以在文本框中输入英文,然后按空格或输入键,我们可以将其音译成印地语(其他语言)。但要求是输出应该在另一个文本框中。
这怎么可能?
这是我的代码,它转写到同一个文本框
<div>
<asp:TextBox runat="server" Height="30px" ID="TextBox1" Width="200px" />
</div>
<script>
attachControlgglTransliterate("TextBox1");
</script>
这是google提供的js(translt.js文件)代码。
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]]);
}
【问题讨论】:
标签: c# javascript api google-api transliteration