我使用以下js代码在django应用程序中将本地语言转换为英语。
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
// Load the Google Transliteration API
google.load("elements", "1", {
packages: "transliteration"
});
function onLoad() {
var options = {
sourceLanguage: 'en',
destinationLanguage: ['ml'],
shortcutKey: 'ctrl+m',
transliterationEnabled: true
};
// Create an instance on TransliterationControl with the required options.
var control = new google.elements.transliteration.TransliterationControl(options);
// Enable transliteration in the textfields with the given ids.
var ids = [ "lang", "langu", "language" ];
control.makeTransliteratable(ids);
// Show the transliteration control which can be used to toggle between
// English and Hindi and also choose other destination language.
// control.showControl('translControl');
}
google.setOnLoadCallback(onLoad);
控制台上的错误是
Uncaught Error: Exception in makeTransliteratable: Invalid element id lang
at Yy (transliteration.I.js:178)
at Xy.Q.ij (transliteration.I.js:323)
at onLoad ((index):551)
提前感谢您的帮助。