How to Use Google Translate API?
How to use google translate api for change the text of textview i开发者_开发技巧n whole application?
Translate.setHttpReferrer("http://da.riidr.com/konto/signup/");
String translatedText = null;
try {
translatedText = Translate.execute("Du skal skrive det samme kodeord hver gang.",
Language.DANISH, Language.ENGLISH);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Translated page...."+translatedText);
note: add google translate api jar i.e google.api.translate-java-0.95.jar
namespace Google\Cloud\Samples\Translate;
// [START translate_translate_text]
use Google\Cloud\Translate\TranslateClient;
// your text
$text = 'The text to translate.';
// Which language to translate to? language code.
$targetLanguage = 'ja';
$translate = new TranslateClient();
$result = $translate->translate($text, [
'target' => $targetLanguage,
]);
print("Source language: $result[source]\n");
print("Translation: $result[text]\n");
google translate api for website!
check this and follow the steps - https://translate.google.com/manager/website/
精彩评论