-
-
Save esfand/8abf9498c92cfcee86ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.memetix.mst.language.Language; | |
import com.memetix.mst.translate.Translate; | |
public class ExampleTranslation { | |
public static void main(String[] args) throws Exception { | |
//Replace client_id and client_secret with your own. | |
Translate.setClientId("CLIENT_ID_HERE"); | |
Translate.setClientSecret("CLIENT_SECRET_HERE"); | |
// Translate an english string to spanish | |
String englishString = "Hello World!"; | |
String spanishTranslation = Translate.execute(englishString, Language.SPANISH); | |
System.out.println("Original english phrase: " + englishString); | |
System.out.println("Translated spanish phrase: " + spanishTranslation); | |
/* | |
OUTPUT: | |
Original english phrase: Hello World! | |
Translated spanish phrase: ¡Hola mundo! | |
*/ | |
} | |
} | |
/* | |
NOTE: | |
A) Add the following maven dependency to your code for this to work: | |
<dependency> | |
<groupId>com.memetix</groupId> | |
<artifactId>microsoft-translator-java-api</artifactId> | |
<version>0.6.1</version> | |
<type>jar</type> | |
</dependency> | |
Or | |
B) If you don't use maven, add the following jar to your class path: | |
https://code.google.com/p/microsoft-translator-java-api/downloads/list | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment