Bing Translator .NET Extension Methods–CodePlex

BingDotNet

Recently, I released an open-source Bing Translator .NET Extension Methods project in CodePlex under the MIT License (MIT).

Both Binary runtime files and the source code file can be downloaded at:

http://bingtranslatorkit.codeplex.com/releases

The idea came when I found out that Google is shutting down it’s Translation API:

image

There is no real answer from Google to why it’s “Deprecating” it’s Translation API, but anyway, looks like Google is in love with it’s deprecation policy. I believe developer community is loosing faith in Google. An example is a comment by Vienna consultant Franz Enzenholder: “why should any developer, any company which wants to build a valuable product for the long term use any of your APIs ever again?

Anyway, Bing offering a similar free Translation APIs, and it’s supporting the following scenarios/protocols:

  1.  AJAX Service: A JavaScript developer friendly version of the APIs.
  2. HTTP Service: A RESTFUL version of the APIs.
  3. SOAP Service: A classic SOAP protocol version of the APIs.

 

Bing Translations Extensions Design:

For consuming any Web Service either it’s based on SOAP,REST or Open Data protocol, the following steps are always required in order to make the consumption done properly:

  1. Generate an application ID for consuming the web services from the provider (Bing App ID, Google API Key, Facebook API key, etc..)
  2. Adding the Web Service API URL as a reference to your project.
  3. When working on server side apps, the IDE will generate a proxy client for the services that makes the web methods more language neutral.
  4. Application (API) ID must be provided on each web service call.

Well, the main goal of this project is to provide an easier developer experience on consuming Bing Translator APIs by providing the following:

  1. Reducing the parameters number by providing the Bing Application ID just for one time during the development.
  2. Providing more language integrated methods that cut the efforts and learning curve of using the APIs through .NET Extension Methods feature.

These objectives are achieved by depending on the .NET Extension Methods feature while designing the Bing Translator APIs Wrapper.

 

How to use this library:

The following steps contains the necessary steps to enable the extension methods in your project:

1- Creating a Bing App ID: You need a windows live account, and by signing in to http://binged.it/1knsS, you will be able to create a new Bing AppID.

image

2- Download the Bing Translator .NET Extension Methods Runtime Files from http://bit.ly/mY6Bze.

image

3- Extract the Zip file and you will find the following files:

  1. app.config: Contains all the configuration of the Bing Translator SOAP EndPoint.
  2. DevoPoint.Framework.Extensions.BingTranslator.dll: Library Runtime File.
  3. DevoPoint.Framework.Extensions.BingTranslator.dll.config: Contains all the configuration of the Bing Translator SOAP EndPoint.

*Please note that you must always includes the app.config file in your project files, otherwise you will run into an error when the .NET CRL tries to locate the Bing Translator Service end point.*

4- Use the namespace of the project: When starting a new project, you should add the following line of code to make the extension methods available at your project code:

using DevoPoint.Framework.Extensions.BingTranslator;

Now the Bing Translator .NET Extension Methods are enabled in your project.

5- Set the Bing App ID for one time in a property:

To avoid using the Bing App ID on each Web Method call, Just set the property BingAppID for one time and you are dong, you don’t need to set it again at anytime, here below an example:

BingTranslationExtension.BingAppID = “YOURBINGAPPID”;

Project Methods and Features:

Below is a list of the features and .NET Extension Methods that a developer can utilize during  development:

* Strong Typed Bing Translator Supported languages through Enum: With Enum,  developer does not have to worry again about writing the culture codes, it’s already available through the Visual Studio IDE intellisense as the following:

image

* Translate method available for all strings: With BingTranslate Extension Method, developer can translate from and to any language easily in one line as the following:

image

image

There are two methods for translation, the first one will auto-detect the language and translate the text into the destination language, while in using the second method, developer must provide the source language as the following:

image

* Language Detect Extension Method: The library will extend strings with the method DetectLanguage, which returns the language of the current text as the following:

image

* Language Speaking Wave File Extension Method: The library will also provide the developer with a method which returns a URL of the wave file contains the speaking audio of the text, as the following:

image

* Language Speaking Support Extension Method: Bing Translator is not supporting the speaking feature for all languages yet, The extension method IsSpeakingSupported will indicate if the language speaking feature supported or not, as the following:

image

GetSpeakingSupportedLanguages extension method returns a list of the speaking supported languages names in specific language as the following:

image

As you can see in the figure above, there are also other two extension methods:

GetLanguageNameTranslation

GetLanguageNamesTranslation

The first method returns the translation of the language name in a specific language which the developer determines by the parameters, the second method will return a list of languages translated to the extended BingLanguage value, in this case It will return all languages names in Arabic.

Future Versions:

In the future versions I am going to support the following features incremently:

  1. Supporting HTTP (REST) APIs instead of SOAP.
  2. Supporting the Array Methods.
  3. Building a WPF/WP7 Bing-Translator Enabled Controls.
  4. Building a JQuery Plugins for Bing Translator.

3 Responses to Bing Translator .NET Extension Methods–CodePlex

  1. Arthur says:

    I tried to use this class, and I did include the app.config and the DevoPoint.Framework.Extensions.BingTranslator.dll.config files but i still get an error that it is unable to find the endpoint. any suggestions?

    • Michael Crawford says:

      If it is a web app you have to add the code from the app.config file into the web.config file. I had the same issue and that fixed it for me.

  2. chobo2 says:

    What parts of the app config do I need. I am using asp.net mvc (so web.config). I think I probably need to move the app.config stuff to it.

    Also there a limitation on the number of calls you can all to Bing?

Leave a reply to chobo2 Cancel reply