PHP code example of prihod / promt-translate

1. Go to this page and download the library: Download prihod/promt-translate library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

prihod / promt-translate example snippets



Prihod\Translate\Translator;
use Prihod\Translate\Exception;

try {
  $translator = new Translator($key);
  $translation = $translator->translate('Hello world', 'en','ru');

  echo $translation; // Привет мир
  echo $translation->getSource(); // Hello world;
  echo $translation->getSourceLanguage(); // en
  echo $translation->getResultLanguage(); // ru
  
} catch (Exception $e) {
  // handle exception
}