aalfiann / google-translate-api-php
A PHP class library to make your own Google Translate API for free.
1.0.1
2018-09-17 07:57 UTC
Requires
- php: >=5.4
This package is auto-updated.
Last update: 2024-10-20 23:15:21 UTC
README
A PHP class library to make your own Google Translate API for free.
Installation
Install this package via Composer.
composer require "aalfiann/google-translate-api-php:^1.0"
Standar Usage
require_once ('vendor/autoload.php'); use \aalfiann\GoogleTranslate; $lang = new GoogleTranslate(); $lang->source = 'id'; $lang->target = 'en'; $lang->text = 'Selamat datang di kampung halamanku!'; $result = $lang->translate()->getText(); echo $result;
Chain Usage + Make detect source of language automatically
require_once ('vendor/autoload.php'); use \aalfiann\GoogleTranslate; $lang = new GoogleTranslate(); $text = 'Arigatou!'; $result = $lang->setTarget('en')->setText($text)->translate()->getText(); echo $result;
Note:
- If you are not specify the source of language, then Google will detect it automatically.
- You should cache the results, because Google has LIMIT RATE and will block your IP address server if too many request.