PHP code example of bluora / laravel-yandex-translate

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

    

bluora / laravel-yandex-translate example snippets


'providers' => [
    ...
    Bluora\Yandex\Providers\YandexTranslateServiceProvider::class,
)

'aliases' => [
    ...
    'YandexTranslate' => Bluora\Yandex\Facades\YandexTranslateFacade::class,
]


return [
    ...
    'yandex-translate' => [
        'key' => env('YANDEX_TRANSLATE_KEY', ''),
    ]
];

echo YandexTranslate::translate('Hello world', 'en', 'ru');
echo YandexTranslate::translate('Hello world!', 'en', 'fr');
echo YandexTranslate::translate('Hello world!', false, 'fr');
echo YandexTranslate::translate('Hello world!', false, 'fr')->getOriginalLanguage();
print_r(YandexTranslate::translate(['Hello world!', 'I love you'], 'en', 'fr'));
print_r(YandexTranslate::translate([22 => 'Hello world!', 30 => 'I love you'], 'en', 'fr'));
print_r(YandexTranslate::translate(['first_word' => 'Hello world!', 'second_word' => 'I love you'], 'en', 'fr'));