Potsky\LaravelLocalizationHelpers\Factory\TranslatorInterface::translate PHP Метод

translate() публичный Метод

public translate ( $word, $toLang, $fromLang = null )
    public function translate($word, $toLang, $fromLang = null);

Usage Example

 /**
  * @param string $word
  * @param string $to
  * @param null   $from
  *
  * @return mixed
  */
 public function translate($word, $to, $from = null)
 {
     if (is_null($this->translator)) {
         $translator = Config::get(self::PREFIX_LARAVEL_CONFIG . 'translator');
         $this->translator = new Translator('Microsoft', array('client_id' => Config::get(self::PREFIX_LARAVEL_CONFIG . 'translators.' . $translator . '.client_id'), 'client_secret' => Config::get(self::PREFIX_LARAVEL_CONFIG . 'translators.' . $translator . '.client_secret'), 'default_language' => Config::get(self::PREFIX_LARAVEL_CONFIG . 'translators.' . $translator . '.default_language')));
     }
     $translation = $this->translator->translate($word, $to, $from);
     if (is_null($translation)) {
         $translation = $word;
     }
     return $translation;
 }
TranslatorInterface