Skip to content

Bing / MS Translator API – Java Wrapper

December 16, 2011

One of my colleague wanted to know about the Google Translator API. Later we found that it is a paid service and it is not available for testing either.

Then, we bounced on this Java Wrapper. MS / Bing Translator API is a paid service. Used the subscription license to test the sample.

Steps to follow

Following are the steps one has to follow to use the MS / BING Translator API.

  • Create a new application at – http://www.bing.com/developers/createapp.aspx
  • You need to have live id to create an application
  • Once the application is created, you will get an application ID. Store this, it is needed for the JAVA application
  • Get the latest JAR file from the Maven Repo using

           <dependency>

                  <groupId>com.memetix</groupId>

                  <artifactId>microsoft-translator-java-api</artifactId>

                  <version>0.4</version>

                  <type>jar</type>

            </dependency>

import com.memetix.mst.language.Language;

import com.memetix.mst.translate.Translate;

public class MicrosoftTranslatorTest {

    public static void main(String[] args) throws Exception {
Translate.setKey(“ID From STEP-3 here”);

String french2English = Translate.execute(“Quel est votre nom”,
Language.FRENCH, Language.ENGLISH);

String english2Spanish = Translate.execute(“Welcome…”,
Language.ENGLISH, Language.SPANISH);

System.out.println(french2English);
System.out.println(english2Spanish);

}

}

  • And here are the translated texts
  • What is your name
  • Bienvenidos…
  • Languages Supported as of now
  • Language AUTO_DETECT
  • Language ARABIC
  • Language BULGARIAN
  • Language CHINESE_SIMPLIFIED
  • Language CHINESE_TRADITIONAL
  • Language CZECH
  • Language DANISH
  • Language DUTCH
  • Language ENGLISH
  • Language ESTONIAN
  • Language FINNISH
  • Language FRENCH
  • Language GERMAN
  • Language GREEK
  • Language HATIAN_CREOLE
  • Language HEBREW
  • Language HUNGARIAN
  • Language INDONESIAN
  • Language ITALIAN
  • Language JAPANESE
  • Language KOREAN
  • Language LATVIAN
  • Language LITHUANIAN
  • Language NORWEGIAN
  • Language POLISH
  • Language PORTUGUESE
  • Language ROMANIAN
  • Language RUSSIAN
  • Language SLOVAK
  • Language SLOVENIAN
  • Language SPANISH
  • Language SWEDISH
  • Language THAI
  • Language TURKISH
  • Language UKRANIAN
  • Language VIETNAMESE

 

Advertisements
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: