PHP code example of atran / translate

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

    

atran / translate example snippets


"guzzlehttp/guzzle": "^7.0.1",
"tebru/gson-php": "^0.7.3"

composer 

php artisan vendor:publish

AZURETRAN_KEY=Azure Cognitive Services API SUBSCRIPTION KEY

composer 

'providers' => [
    // ...
    ATran\Translate\\ATranServiceProvider::class,
]

php artisan vendor:publish --force --provider="ATran\Translate\ATranServiceProvider"

AZURETRAN_KEY=Azure Cognitive Services API SUBSCRIPTION KEY

Accept: application/json

KEY     TEXT
text    Hello

{
    "language": "en",
    "score": 1,
    "isTranslationSupported": true,
    "isTransliterationSupported": false,
    "alternatives": [
        {
            "language": "de",
            "score": 1,
            "isTranslationSupported": true,
            "isTransliterationSupported": false
        },
        {
            "language": "fr",
            "score": 1,
            "isTranslationSupported": true,
            "isTransliterationSupported": false
        }
    ]
}

Accept: application/json

{
    "ar": {
        "name": "Arabic",
        "nativeName": "العربية",
        "scripts": [
            {
                "code": "Arab",
                "name": "Arabic",
                "nativeName": "العربية",
                "dir": "rtl",
                "toScripts": [
                    {
                        "code": "Latn",
                        "name": "Latin",
                        "nativeName": "اللاتينية",
                        "dir": "ltr"
                    }
                ]
            },
            {
                "code": "Latn",
                "name": "Latin",
                "nativeName": "اللاتينية",
                "dir": "ltr",
                "toScripts": [
                    {
                        "code": "Arab",
                        "name": "Arabic",
                        "nativeName": "العربية",
                        "dir": "rtl"
                    }
                ].............

use ATran;

ATran::detectTextInformation($text);