Download the PHP package untoreh/mtr without Composer
On this page you can find all versions of the php package untoreh/mtr. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package mtr
Short Description Multi api translator
License MIT
Homepage https://github.com/untoreh/mtr
Informations about the package mtr
Mtr
Multi language translator api wrapper in PHP, translate or compare strings or arrays of strings with language pairs supported by multiple services.
Install
Dependencies
- APC USer Cache
Using composer composer require untoreh/mtr
on the command line, then include the autoload file in PHP
Usage
Pass source/target language and a string or array of strings
Array keys are preserved.
List of base usable language codes, the priority is to google codes which means if you want
to translate chinese you should use zh-TW
or zh-CN
Choose which services to use
Add a weight to it to specify how many times a service should be chosen over the others
Custom http options
Api keys
Conventions
- It is recommended to not rely on the translation to return consistent punctuation, therefore input text should be as atomic as possible.
- Some services arbitrarily encode/decode html or even add html tags themselves, such aggressive services have active decoding before the output.
Notes
- Requests are limited to
1000~
chars, strings and arrays get split or merged up to this size to try to make uniform requests. - All the parts of a request are run concurrently, pools are not used (yet).
- Default services
weight
is30
for google, bing, yandex and 10 for the rest. - Cached keys start with
mtr_
- Because services may be fickle, they will be dropped as they go down or block access.
- Not all services supports all the languages, the group of services used is transparently trimmed to the ones that support the requested language pair.
TODO/Improvements
In the issues
Credits
- guzzle/guzzle - http client
- Stichoza/google-translate-php - google token generator
- leodido/langcode-conv - base for the language code converter
- joecampo/random-user-agent - user-agent strings