PHP code example of yaraku / translate-api

1. Go to this page and download the library: Download yaraku/translate-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yaraku / translate-api example snippets




use YarakuTranslate\TranslateApiV2\Client

/*
 * Create a new client, which can be used in multiple requests.
 * 
 * The Authorization key can be found in:
 * Yaraku Translate -> Settings -> API -> TranslateAPI V2.
 * 
 * The url will be the API endpoint you are using, for example:
 * https://translate.yaraku.com/api/translate/v2
 */
 
$client = new Client($authkey, $url);

/*
 * Call translate with an array of texts you want to translate.
 * Set the text (source) and translation (target) languages.
 */
$result = $client->translate(
    ['This is a test.', 'Add your texts here.'],
    'en',
    'ja'
);