PHP Classes

PHP Google and Yandex Translate API: Translate texts with Google or Yandex APIs

Recommend this page to a friend!
  Info   View files Documentation   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 57 All time: 10,523 This week: 524Up
Version License PHP version Categories
gytranslate 1.0.0MIT/X Consortium ...8Localization, PHP 5, Web services
Description 

Author

This class can translate texts with Google or Yandex APIs.

It can take a given text and translate it from one language to another.

The class provides separate functions to perform the translations by sending HTTP requests to either the Google Translate API or the Yandex Translate API.

Picture of Mateo
  Performance   Level  
Name: Mateo <contact>
Classes: 23 packages by
Country: Peru Peru
Age: ???
All time rank: 20834 in Peru Peru
Week rank: 11 Up1 in Peru Peru Up
Innovation award
Innovation award
Nominee: 10x

Winner: 3x

Documentation

Guide use

1. Use with composer

require 'path/to/vendor/autoload.php';

use Mateodioev\Translate;
$tr = new Translate;

Google

$res = $tr->google('Your text to translate', 'source_lang', 'target_lang');

Yandex

$key = 'YOUR_API_KEY'; // see: https://translate.yandex.com/developers/keys
$res = $tr->yandex($key, 'Your text to translate', 'source_lang', 'target_lang'),

Another formats

$tr->setText('Hello world!')->setInputLang('en')->setOutputLang('es');

$res = $tr->yandex($key);
$res = $tr->google();
# Use any of the above methods

Get translate text

$tr->getText();

Get lang name

$dir = 'input or output';
$tr->getLangName($dir);

Details

Translate text

Github:

git clone https://github.com/Mateodioev/translate
cd translate
composer install

Composer:

composer require mateodioev/translate

Usage

See examples


  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file examples.md Doc. Documented examples
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file Translate.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:57
This week:0
All time:10,523
This week:524Up