Last active
September 4, 2017 00:00
-
-
Save amsanjeev/bf07ebd17aa62a12bf4e7cdb5d8c1d6e 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
private void translate(String textToTranslate, String targetLanguage, TranslateCallback callback) { | |
try { | |
TranslateOptions options = TranslateOptions.newBuilder() | |
.setApiKey( < api_key >) | |
.build(); | |
Translate trService = options.getService(); | |
Translation translation = trService.translate(textToTranslate,TranslateOption.targetLanguage(targetLanguage)); | |
callback.onSuccess(translation.getTranslatedText()); | |
} | |
catch(Exception e) { | |
callback.onFailure(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment