tanmuhittin / laravel-google-translate

Translate translation files to other languages using google translate or another translation api
MIT License
424 stars 71 forks source link

Incorrect return type if null translation #45

Open nathanczachur opened 3 years ago

nathanczachur commented 3 years ago

First, thanks for a great package! This has saved me a lot of time!

I have found a bug with incorrect return types. I will look into it myself, but wanted to start the issue here.

File: src/Api/StichozaApiTranslate.php:30

StichozaApiTranslate->translate has a return type of string. But the GoogleTranslate->handle can return null or string (See method return type)

Also, the StichozaApiTranslate->translate returns false in the try catch. This will break at some point too.

Do you think we should go for: If a translation cannot be found for whatever reason, is the expected behaviour to return null instead of a string?

nathanczachur commented 3 years ago

The specific translation I have is an empty string: Screenshot 2021-05-19 at 13 31 50

This is the only line that fails, which is likely why GoogleTranslate returned null instead of a string.