PHP code example of gtran / translate

1. Go to this page and download the library: Download gtran/translate 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/ */

    

gtran / translate example snippets


"guzzlehttp/guzzle": "^7.0.1",

composer 

php artisan vendor:publish

GOOGLETRAN_KEY=Google Cloud API KEY

composer 

'providers' => [
    // ...
    GTran\Translate\\GTranServiceProvider::class,
]

php artisan vendor:publish --force --provider="GTran\Translate\GTranServiceProvider"

GOOGLETRAN_KEY=Google Cloud API KEY

Accept: application/json

KEY     TEXT
query    Hello

{
  "data": {
    "detections": [
      [
        {
          "confidence": 1,
          "isReliable": false,
          "language": "en"
        }
      ]
    ]
  }
}

Accept: application/json

KEY     TEXT
model    base, P.S. you can go for nmt, Neural Machine Translation.
locale   en

{
  "data": {
    "languages": [
      {
        "language": "af",
        "name": "Afrikaans"
      },
      {
        "language": "sq",
        "name": "Albanian"
      },
      {
        "language": "am",
        "name": "Amharic"
      },
      {.................................

use GTran;

GTran::detectTextInformation($query);