pixxet/google-translate
Larablocks Analysis
pixxet/google-translate works with any PHP project: the latest release (1.0.0, Mar 20, 2017) doesn't depend on Laravel.
Recommendation checks
Not advisedNot advised: no release or commit in over 2 years.
- No release or commit in over 2 years
- No release in the last 12 months (last: Mar 20, 2017)
- 0 downloads a month (needs 10,000)
- 2 GitHub stars (needs 100)
State
Likely abandoned- No release or commit in over 2 years.
- Last stable release: Mar 20, 2017.
- No releases in the last 12 months.
- First released: Mar 20, 2017.
- 0 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Dec 1, 2026.
| Install | |
|---|---|
composer require pixxet/google-translate |
|
| Latest Version: | 1.0.0 |
| PHP: | >=5.5.9 |
| License: | MIT |
| Last Updated: | Mar 20, 2017 |
| Links: | GitHub · Packagist |
Laravel package for Google Translate REST API
Package allows to work with Google Translate API
Installation
Package can be installed using composer by adding to "require" object
"require": {
"pixxet/google-translate": "dev-master"
}
or from console:
composer require pixxet/google-translate dev-master
Configuration
You should publish config file to be able to add your Google API key. To publish config you should do:
php artisan vendor:publish --provider="Dedicated\GoogleTranslate\GoogleTranslateProvider"
After config is published, you will have it in config\google-translate.php of your Laravel project directory
You should change only one line:
...
/**
* Google key for authentication
*/
'api_key' => 'YOUR-GOOGLE-API-KEY-GOES-HERE',
...
Usage
To translate text with given source language and target language:
$translator = new Dedicated\GoogleTranslate\Translator;
$result = $translator->setSourceLang('en')
->setTargetLang('ar')
->translate('Hello World');
dd($result); // "مرحبا بالعالم"
By default language detection is turned on, so you can translate text without specifying source language.
This will make 2 requests to google API:
- First request will go to /detect URL and get source language name
- Second request will make actual translate request and give out result.
$translator = new Dedicated\GoogleTranslate\Translator;
$result = $translator->setTargetLang('ar')
->translate('Hello World');
dd($result); // "مرحبا بالعالم"
You can also use function to only detect text's source language:
$result = $translator->detect('Hello World');
dd($result); // "en"
License
This repository code is open-sourced software licensed under the MIT license
Related Packages
Auth guard for Laravel that completely relies on Google Login and doesn't persis...
Random is a simple helper package designed to make it easy to generate a range o...
Version History
| Version | Released | PHP | License |
|---|---|---|---|
| 1.0.0 | >=5.5.9 | MIT |