dejurin / php-google-translate-for-free
Library for free use Google Translator. With attempts connecting on failure and array support.
Installs: 31 681
Dependents: 2
Suggesters: 0
Security: 0
Stars: 135
Watchers: 9
Forks: 48
Open Issues: 0
Requires
- php: >=5.4
This package is auto-updated.
Last update: 2024-11-29 18:09:08 UTC
README
Packagist: https://packagist.org/packages/dejurin/php-google-translate-for-free
Library for free use Google Translator. With attempts connecting on failure and array support.
Installation
Install this package via Composer.
composer require dejurin/php-google-translate-for-free
Or edit your project's composer.json
to require dejurin/php-google-translate-for-free
and then run composer update
.
"require": { "dejurin/php-google-translate-for-free": "^1.0" }
Usage
require_once ('vendor/autoload.php'); use \Dejurin\GoogleTranslateForFree;
Single
$source = 'en'; $target = 'ro'; $attempts = 5; $text = 'Hello'; $tr = new GoogleTranslateForFree(); $result = $tr->translate($source, $target, $text, $attempts); var_dump($result); /* string(24) "Salut" */
Array
$source = 'en'; $target = 'ro'; $attempts = 5; $arr = ['hello','world']; $tr = new GoogleTranslateForFree(); $result = $tr->translate($source, $target, $arr, $attempts); var_dump($result); /* array(2) { [0]=> string(24) "salut" [1]=> string(6) "lume" } */
License
This source code is distributed under MIT license.