<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<div>
<asp:updatepanel id="UpdatePanel12" runat="server">
<ContentTemplate>
<div style="position: relative;width: 324px; margin-left: 20px; margin-top:20px;
margin-bottom:20px;">
<asp:Label ID="lblInstructions" runat="server" Width="400px" Text="Enter some text for the language
you want translated:"></asp:Label>
</div>
<!-- Input for the text we want translated -->
<div style="position: relative; width: 324px; margin-left: 20px; margin-bottom:10px;">
<asp:TextBox ID="txtInput" runat="server" Width="359px" Height="200px"
TextMode="MultiLine"></asp:TextBox>
</div>
<!-- Button to call the translate method through the SOAP API -->
<div style="position: relative; width: 167px; margin-left: 20px; margin-bottom:20px;">
<asp:Button ID="btnTranslate" runat="server" Text="Translate Text"
onclick="btnTranslate_Click" />
</div>
<!-- Label to output the translated text -->
<div style="position: relative; width: 324px; margin-left: 20px; margin-bottom:20px;">
<asp:Label ID="lblOutput" runat="server" Width="602px"></asp:Label>
</div>
<fieldset>
<legend>Results</legend>
<table>
<tr>
<td>
Translating text is also avilable through Microsoft's Translator SOAP API, it is
achieved through a SOAP call to the translate method. The language to translate
to and from need to be included in as method parameters along with the text. In
the example above you will see in the Code-Behind that the to and from languages
have been hard coded as English to French, this can be set dynamically through
your own culture code parameters.
</td>
</tr>
<tr>
<td>
Enter some text in the box above and click the 'Translate Text' button and the
translated text will be displayed. Click the Code-Behind tab above to see
exactly how this is done in c#.
</td>
</tr>
</table>
</fieldset>
</ContentTemplate>
</asp:updatepanel>
</div>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace InteractiveSDK.SOAP
{
public partial class SOAPDemo2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
// Click event for the button to to the translation
protected void btnTranslate_Click(object sender, EventArgs e)
{
// Create an instance of the translator service
TranslatorService.LanguageServiceClient client =
new InteractiveSDK.TranslatorService.LanguageServiceClient();
// Call the translated method and parse the appId, text to be translated
// and the language to translate from and to (culture codes)
// This method is hardcoded to translate for English to French
lblOutput.Text = client.Translate("yourAppId", txtInput.Text, "en", "fr");
}
}
}