Tutorials Forums
     Tutorials Videos
        Sign Up Now For FREE
Welcome, Guest
Username Password: Remember me

Bing Translator
(1 viewing) (1) Guest
A programming language that evolved in part from Microsoft C++, C# was designed for building enterprise-level applications that run on the .NET Framework. C# is simple, modern, type safe, and object oriented. Whether you’re new to the language or an old pro, you’ll find articles in this section that will help you get your projects done.
  • Page:
  • 1

TOPIC: Bing Translator

Bing Translator 04 May 2010 02:44 #373

Introduction
In this article we will see how we can create a simple Desktop Translator which uses the Bing Translator API. Next time when you want to translate a text, you do not have to open a new web browser and head to Bing or Google Translator. Just use this simple Translator I demonstrate here.

Let’s get started:
Step 1:Start Visual studio and create a new Windows Forms Application
Step 2: Add 2 TextBoxes and name them ‘txtTraslateFrom’ and ‘txtTranslatedText’ and set their ‘MultiLine’ property to ‘True’
Step 3:Add a Button to the form and name it ‘btnTranslate’ and ComboBox (cmbfrom and cmbto)
Step 4:Right Click the project and add a ‘Service Reference’ to api.microsofttranslator.com/V1/SOAP.svc with Namespace as TranslatorService
Step 5:To use Bing Translator Web Service you will need an AppID. Go to www.bing.com/developer and create a new AppID for our Desktop Translator.
Step 6: Add the following code to the Button’s Click Event
 TranslatorMode.ModeFrom from = (TranslatorMode.ModeFrom)Enum.Parse(typeof(TranslatorMode.ModeFrom), cmbfrom.SelectedItem.ToString());
TranslatorMode.ModeTo to = (TranslatorMode.ModeTo)Enum.Parse(typeof(TranslatorMode.ModeTo), cmbto.SelectedItem.ToString());
 
//
//
//
TranslatorMode.SetTranslatorMode(from, to);
TranslatorService.LanguageServiceClient Client = new TranslatorService.LanguageServiceClient();
Client = new TranslatorService.LanguageServiceClient();
translatedText = Client.Translate("Your App ID",
this.txtTraslateFrom.Text,
TranslatorMode.GetModeFrom(),
TranslatorMode.GetModeTo());
this.txtTranslatedText.Text = translatedText;

The ‘Translate’ method takes in 4 parameters - ‘appid, text, from and to’. In the above code we are calling the Translate method with the AppID we created in Step 5 and also passing the Text from Textbox.




This attachment is hidden for guests. Please log in or register to see it.
Attachments:
  • Attachment This attachment is hidden for guests. Please log in or register to see it.
  • CE
  • OFFLINE
  • Administrator
  • Posts: 197
  • Karma: 78
CodersEngine

Re: Bing Translator 27 Jun 2010 03:52 #378

How To Use Bing Translator in CSharp

  • CE
  • OFFLINE
  • Administrator
  • Posts: 197
  • Karma: 78
  • Page:
  • 1
Moderators: mnjon
Time to create page: 0.31 seconds