PHP Classes

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

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 59 All time: 10,526 This week: 45Up
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
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 (4)  
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 (4)  /  src  
File Role Description
  Plain text file Translate.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:59
This week:0
All time:10,526
This week:45Up