Unanswered Translate api is not working, which was working previously.

  • Tuesday, April 24, 2012 5:39 AM
     
      Has Code

    HI,

    I am getting the following error while calling Translate method.

    exception is : _mste1("ArgumentOutOfRangeException: 'contentType' must be valid\u000d\u000aParameter name: contentType : ID=3644.V2_Json.Translate.3F48C196");

    please check my code.

    <html>
       <head>
          <title>Translate Text Demo</title>
          
          <script type="text/javascript" 
                     src="http://api.microsofttranslator.com/V1/Ajax.svc/Embed?appId=970174A695AA1EF4698A0360D66541E3AB0C4096">
          </script>
          
          <script type="text/javascript">
          
          var currentLanguage = "en";
          
          function translateElement(element, lang)
          {
    	              Microsoft.Translator.translate(element.innerText,
                                                                currentLanguage, 
                                                                lang, 
                                                                function(translation) { 
                                                               element.innerText = translation;  
                                  }); 
          }
          
          </script>
       </head>
       <body>
          <table>
               <tr>
                   <td id="firstParagraph">
                       Text explaining that we can translate single elements via their Id.
                   </td>
               </tr>
               <tr>
                   <td>
                       Translate first paragraph into German 
                        <input type="button" value="OK" 
                            onclick="translateElement(document.getElementById('firstParagraph'), 'de');" />
                   </td>
               </tr>
           </table>
         </body> 
       </html>


    govardhan

All Replies

  • Tuesday, April 24, 2012 3:35 PM
     
     
     Hi Govardhan,

    Could this be related to

    http://social.msdn.microsoft.com/Forums/en-US/microsofttranslator/thread/02054a7c-090c-46a0-a8d1-2d57e236eb4d?

    Would you take a look?  Thanks.  Takako (Microsoft Translator Team)

  • Wednesday, April 25, 2012 5:14 AM
    Moderator
     
     

    What is your contentType set to?

    It should be text/html or text/plain

    If using text/html, the html should be well-formed.

    I see you are using a function Microsoft.translation.translate() -- where does this come from? What is the library you are using? Can you send me a copy of that?


    //Laurence Moroney: www.netnavi.tv // Author of 'Introducing Silverlight' series and much more // @lmoroney