我只能更改一次语言(加载页面后第一次)。如果我在第一次选择后选择另一种语言,则语言不会改变。 这是我的代码
localStorage.getItem("prueba");
<select id="selectedLanguageId" onchange="changeLanguage(this.value)">
<option value="ENGLISH" selected="selected" >English</option>
<option value="HINDI">Hindi</option>
<option value="TAMIL">Tamil</option>
<option value="MALAYALALM">Malayalam
答案 0 :(得分:0)
这可能对你有所帮助!
<script type="text/javascript">
// Load the Google Transliterate API
google.load("elements", "1", {
packages: "transliteration"
});
function changelanguage(lan) {
if (lan == 'Arabic') {alert (" لا تنس أن تضغط G+ctrl قبل البدء بكتابة اللغة العربية");}
switch (lan){
case "Hindi":
var options = {
sourceLanguage:
google.elements.transliteration.LanguageCode.ENGLISH,
destinationLanguage:
[google.elements.transliteration.LanguageCode.HINDI],
shortcutKey: 'ctrl+g',
transliterationEnabled: true
};
break;
case "Arabic":
var options = {
sourceLanguage:
google.elements.transliteration.LanguageCode.ENGLISH,
destinationLanguage:
[google.elements.transliteration.LanguageCode.ARABIC],
shortcutKey: 'ctrl+g',
transliterationEnabled: true
};
break;
case "Malayalam":
var options = {
sourceLanguage:
google.elements.transliteration.LanguageCode.ENGLISH,
destinationLanguage:
[google.elements.transliteration.LanguageCode.MALAYALAM],
shortcutKey: 'ctrl+g',
transliterationEnabled: true
};
break;
default:
var options = {
sourceLanguage:
google.elements.transliteration.LanguageCode.ENGLISH,
destinationLanguage:
[google.elements.transliteration.LanguageCode.ENGLISH],
shortcutKey: 'ctrl+g',
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(['stdTextArea']);
}
</script>