Translates the received text using various services
- MyMemory
- Offline transliteration
- Offline bijective transliteration
composer require abeliani/string-translator
Online drivers need to pass implemented psr7 client and request instances
$driver = new MyMemoryDriver('token', $psr7Client, $psr7Request);
$translator = new TextTranslator($driver);
// set text and it languge code
$translator->setSource('some text', 'en')
// Here will be the translated text
print $translator->translate('ge');
Translate the text to many languages
print $translator->translate('fr');
// ...
print $translator->translate('tr');
Chain of driver calls. We can pass the driver into the chain, which will be called if the previous one does not complete the translation.
$driver = new OneDriver($apiKey, $psr7Client, $psr7Request, new TwoDriver($apiKey, $psr7Client, $psr7Request));
$translator = new TextTranslator($driver);
Feel free to request the creation of a new dictionary, service, or send a pull request for your dictionary or service of online translator.
Package homepage