awkaw / laravel-translations
Translate service for Laravel
2.2.0
2023-05-03 09:36 UTC
Requires
- php: ^7.4|^8.0
- ext-json: *
- chrome-php/chrome: ^0.10.0
- guzzlehttp/guzzle: ^7.0
- stichoza/google-translate-php: ^4.1
This package is auto-updated.
Last update: 2026-06-29 01:43:10 UTC
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);