0

I'm able to change the language only once(First time after loading the page). If i select another language after the first selection , language is not changing. Here is my code

 <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

function changeLanguage(val) {
    var data = val;
    $("#stdTextArea").html("");
var options = {
       sourceLanguage: google.elements.transliteration.LanguageCode.ENGLISH,
       destinationLanguage: [google.elements.transliteration.LanguageCode[data]],
       shortcutKey: 'ctrl+g',
        transliterationEnabled: true
     };
var control = new google.elements.transliteration.TransliterationControl(options);
            control.makeTransliteratable(['stdTextArea']);
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
Munavar Fairooz
  • 219
  • 1
  • 3
  • 10

1 Answers1

0

This may help you!

<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>
Benjith Kizhisseri
  • 2,311
  • 2
  • 13
  • 24