Please disable your adblock and script blockers to view this page

Search this blog

Showing posts with label Translator. Show all posts
Showing posts with label Translator. Show all posts

Thursday 20 June 2013

Bing language Translation API integration with Java- microsoft-translator-java-api

Google Translation is very popular and widely used for language translation as it is now paid service,
so i  came to know about Microsoft Translator (Bing Translator), it is providing free API up to 2000,000 character/Month to translate.

Key features and point-
  • Provides java wrapper around microsoft translator (Bing Translator)
  • Developed as alternative of Google Translator
  • Follow coding standard, naming, functionality and usage patterns of widely used google translation API
This is very very simple to use -Follow steps




  • First Download JAR for API- http://code.google.com/p/microsoft-translator-java-api/  with all dependencies
  • Now obtain client secret key and client id in order to access API , see this http://msdn.microsoft.com/en-us/library/hh454950.aspx
  • After this create a simple java class and just write this code-
  • Don't forget to add JAR in your project's class path

  • package translation;
    
    import com.memetix.mst.language.Language;
    import com.memetix.mst.translate.Translate;
    
    public class MicrosoftTranslator {
        public static void main(String[] args) throws Exception {
            
            Translate.setClientId("secret client id");
            Translate.setClientSecret("secret key");
    
    
            String translatedText = Translate.execute("hello", Language.ENGLISH, Language.FRENCH);
            System.out.println(translatedText);
        }
    }
    

  • Enter your key and id in code, you can change language with available list, and run this code
  • To use this in web application , you must handle SSL certificate