Skip to content

abeliani/string-translator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StringTranslator

Translates the received text using various services

Supported services

  • MyMemory
  • Offline transliteration
  • Offline bijective transliteration

Install

composer require abeliani/string-translator

Usage

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

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages