Library for free use Google Translator. With attempts connecting on failure and array support.

Overview

GoogleTranslateForFree

Packagist: https://packagist.org/packages/dejurin/php-google-translate-for-free

version downloads travis StyleCI

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 = 'ru';
$attempts = 5;
$text = 'Hello';

$tr = new GoogleTranslateForFree();
$result = $tr->translate($source, $target, $text, $attempts);

var_dump($result); 

/* 
	string(24) "Здравствуйте" 
*/

Array

$source = 'en';
$target = 'ru';
$attempts = 5;
$arr = ['hello','world'];

$tr = new GoogleTranslateForFree();
$result = $tr->translate($source, $target, $arr, $attempts);

var_dump($result); 

/*
	array(2) {
	  [0]=>
	  string(24) "Здравствуйте"
	  [1]=>
	  string(6) "Мир"
	}

*/

License

This source code is distributed under MIT license.


Sponsors

https://currencyrate.today

https://fx-w.io/

You might also like...
🔡 Portable ASCII library - performance optimized (ascii) string functions for php.

🔡 Portable ASCII Description It is written in PHP (PHP 7+) and can work without "mbstring", "iconv" or any other extra encoding php-extension on your

PHP library to parse urls from string input

Url highlight - PHP library to parse URLs from string input. Works with complex URLs, edge cases and encoded input. Features: Replace URLs in string b

Text - Simple 1 Class Text Manipulation Library

Text - Simple 1 Class Text Manipulation Library Do you remember PHP's string functions? If not, just wrap you text with Text! It will save a minute on

The Hoa\Ustring library.

Hoa is a modular, extensible and structured set of PHP libraries. Moreover, Hoa aims at being a bridge between industrial and research worlds. Hoa\Ust

PCRE wrapping library that offers type-safe preg_* replacements.

composer/pcre PCRE wrapping library that offers type-safe preg_* replacements. If you are using a modern PHP version you are probably better off using

A language detection library for PHP. Detects the language from a given text string.

language-detection Build Status Code Coverage Version Total Downloads Minimum PHP Version License This library can detect the language of a given text

Extensive, portable and performant handling of UTF-8 and grapheme clusters for PHP

Patchwork UTF-8 for PHP Patchwork UTF-8 gives PHP developpers extensive, portable and performant handling of UTF-8 and grapheme clusters. It provides

Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way.

String Component The String component provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a un

php-crossplane - Reliable and fast NGINX configuration file parser and builder
php-crossplane - Reliable and fast NGINX configuration file parser and builder

php-crossplane Reliable and fast NGINX configuration file parser and builder ℹ️ This is a PHP port of the Nginx Python crossplane package which can be

Comments
  • Can I be denied access or a captcha?

    Can I be denied access or a captcha?

    I really liked the project I was wondering is it guaranteed not to stop? Like blocking google, captcha check, or… Because I found it doesn't use an official api image

    opened by borma425 1
  • Consider using mb_strlen instead of strlen

    Consider using mb_strlen instead of strlen

    Consider using mb_strlen instead of strlen here:

    https://github.com/dejurin/php-google-translate-for-free/blob/532af5a2b0cef228f382e53d0ebba4f8db66cdac/GoogleTranslateForFree.php#L84

    opened by artshevtsov 1
  • Размер текста

    Размер текста

    Здравствуйте. Спасибо за такой хороший скрипт. Всё работает. Но есть один нюанс. Я перевожу русский тест на английский. Тексты примерно все одного размера 3-3,5 тысячи символов. Выдает ошибку о превышении допустимого предела в 5к символов. При увеличении ограничения в скрипте до 10 тысяч символов. Всё равно выдаёт эту же ошибку. А вот при увеличении до 15 000 - проходит и срабатывает. Как считает символы? Могу выслать пример текста.

    opened by druid82 1
  • Look like not working anymore...

    Look like not working anymore...

    is it possible for you to check and fix the issue

    the url https://translate.google.com/translate_a/single?client=at&dt=t&dt=ld&dt=qca&dt=rm&dt=bd&dj=1&hl=uk-RU&ie=UTF-8&oe=UTF-8&inputm=2&format=text&otf=2&iid=1dd3b944-fa62-4b55-b330-74909a99969e

    return result :

    1. Це помилка.

    На цьому сервері запитану URL-адресу не знайдено. Це все, що нам відомо.

    opened by hfrance 0
Releases(1.0.0)
Owner
Yurii De
Software engineer.
Yurii De
A PHP string manipulation library with multibyte support

A PHP string manipulation library with multibyte support. Compatible with PHP 5.4+, PHP 7+, and HHVM. s('string')->toTitleCase()->ensureRight('y') ==

Daniel St. Jules 2.5k Jan 3, 2023
:accept: Stringy - A PHP string manipulation library with multibyte support, performance optimized

?? Stringy A PHP string manipulation library with multibyte support. Compatible with PHP 7+ 100% compatible with the original "Stringy" library, but t

Lars Moelleken 144 Dec 12, 2022
A fast PHP slug generator and transliteration library that converts non-ascii characters for use in URLs.

URLify for PHP A fast PHP slug generator and transliteration library, started as a PHP port of URLify.js from the Django project. Handles symbols from

Aband*nthecar 667 Dec 20, 2022
👮 A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect

Agent A PHP desktop/mobile user agent parser with support for Laravel, based on Mobile Detect with desktop support and additional functionality. Insta

Jens Segers 4.2k Jan 5, 2023
Generate Heroku-like random names to use in your php applications.

HaikunatorPHP Generate Heroku-like random names to use in your PHP applications. Installation composer require atrox/haikunator Usage Haikunator is p

Atrox 99 Jul 19, 2022
The Universal Device Detection library will parse any User Agent and detect the browser, operating system, device used (desktop, tablet, mobile, tv, cars, console, etc.), brand and model.

DeviceDetector Code Status Description The Universal Device Detection library that parses User Agents and detects devices (desktop, tablet, mobile, tv

Matomo Analytics 2.4k Jan 5, 2023
PHP library to detect and manipulate indentation of strings and files

indentation PHP library to detect and manipulate the indentation of files and strings Installation composer require --dev colinodell/indentation Usage

Colin O'Dell 34 Nov 28, 2022
ColorJizz is a PHP library for manipulating and converting colors.

#Getting started: ColorJizz-PHP uses the PSR-0 standards for namespaces, so there should be no trouble using with frameworks like Symfony 2. ###Autolo

Mikeemoo 281 Nov 25, 2022
A PHP library for generating universally unique identifiers (UUIDs).

ramsey/uuid A PHP library for generating and working with UUIDs. ramsey/uuid is a PHP library for generating and working with universally unique ident

Ben Ramsey 11.9k Jan 8, 2023
🉑 Portable UTF-8 library - performance optimized (unicode) string functions for php.

?? Portable UTF-8 Description It is written in PHP (PHP 7+) and can work without "mbstring", "iconv" or any other extra encoding php-extension on your

Lars Moelleken 474 Dec 22, 2022