dev-master
9999999-dev http://github.com/bradreed/googleTranslateFree Laravel package for Paid Google Translate REST API
MIT
The Requires
- php >=5.5.9
- guzzlehttp/guzzle ^6.1
The Development Requires
by Brad Reed
laravel php google translate
Free Laravel package for Paid Google Translate REST API
Package allows to work with Google Translate API, (*2)
Package can be installed using composer by adding to "require" object, (*3)
"require": { "ddctd143/google-translate": "dev-master" }
or from console:, (*4)
composer require ddctd143/google-translate dev-master
You should publish config file to be able to add your Google API key. To publish config you should do:, (*5)
php artisan vendor:publish \ --provider="Dedicated\GoogleTranslate\GoogleTranslateProvider" --tag=config
After config is published, you will have it in config\google-translate.php
of your Laravel project directory, (*6)
You should change only one line:, (*7)
... /** * Google key for authentication */ 'api_key' => 'YOUR-GOOGLE-API-KEY-GOES-HERE', ...
To translate text with given source language and target language:, (*8)
$translator = new Dedicated\GoogleTranslate\Translator; $result = $translator->setSourceLang('en') ->setTargetLang('ru') ->translate('Hello World'); dd($result); // "Привет мир"
, (*9)
By default language detection is turned on, so you can translate text without specifying source language., (*10)
This will make 2 requests to google API:, (*11)
$translator = new Dedicated\GoogleTranslate\Translator; $result = $translator->setTargetLang('ru') ->translate('Hello World'); dd($result); // "Привет мир"
You can also use function to only detect text's source language:, (*12)
$result = $translator->detect('Hello World'); dd($result); // "en"
This repository code is open-sourced software licensed under the MIT license, (*13)
Free Laravel package for Paid Google Translate REST API
MIT
laravel php google translate