Skip to content

Commit

Permalink
TypeError: Tanmuhittin\LaravelGoogleTranslate\Api\StichozaApiTranslat…
Browse files Browse the repository at this point in the history
…e::translate(): Return value must be of type string, null returned (Most recent call first)
  • Loading branch information
itsrexb committed Dec 9, 2022
1 parent 25b08cd commit e160f88
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Api/StichozaApiTranslate.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public function translate(string $text, string $locale, string $base_locale = nu
$this->handle->setSource();
else
$this->handle->setSource($base_locale);
$this->handle->setTarget($locale);
$this->handle->setTarget($locale);
try {
return $this->handle->translate($text);
return $this->handle->translate($text) ?? "";
} catch (\ErrorException $e) {
return false;
return "";
}
}
}

1 comment on commit e160f88

@itsrexb
Copy link
Owner Author

@itsrexb itsrexb commented on e160f88 Dec 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed for tanmuhittin#45 issue:

TypeError: Tanmuhittin\LaravelGoogleTranslate\Api\StichozaApiTranslate::translate(): Return value must be of type string, null returned.
I'm running the following environment:
PHP 8.1
Laravel 8

Please sign in to comment.