开发者

How to Use Google Translate API?

开发者 https://www.devze.com 2023-03-01 00:58 出处:网络
How to use google translate api for change the text of textview i开发者_开发技巧n whole application?Translate.setHttpReferrer(\"http://da.riidr.com/konto/signup/\");

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/

How to Use Google Translate API?

0

精彩评论

暂无评论...
验证码 换一张
取 消