awkaw/laravel-translations

Translate service for Laravel


README

Installation

The library can be installed with Composer and is available on packagist under awkaw/laravel-translations:

composer require awkaw/laravel-translations:^2.1

Run the migrations

php artisan migrate

Install Google Chrome browser

docker run -p 9222:9222 --name your_name_for_image --restart always -d awkaw/chrome

Usage

Usage GoogleChromeBrowser


use LaravelTranslations\Services\GoogleTranslateService;
use LaravelTranslations\Services\GoogleTranslate\Providers\GoogleChromeBrowser;

$sourceLocale = 'en';
$targetLocale = 'ru';

$googleChromeAddress = '127.0.0.1:9222'; // enter your address

$sourceText = 'Test translation';

$options = [
    "provider" => GoogleChromeBrowser::class,
    "googleChromeAddress" => $googleChromeAddress,
    "debug" => false,
];

$service = new GoogleTranslateService($sourceLocale, $targetLocale, $options);

$resultText = $service->translate($sourceText);