google-translate-php
google-translate-php copied to clipboard
Error: Class "Stichoza\GoogleTranslate\GoogleTranslate" not found in file
when it runs on the local server there is no issue at all its working perfect .. but when i test it on liver server this error shows i tried many changes but no use
use Stichoza\GoogleTranslate\GoogleTranslate;
private function translateProducts($products, $targetLanguage) { $translator = new GoogleTranslate();
// Set the target language
$translator->setTarget($targetLanguage);
if (is_array($products))
{
$translatedProducts = [];
foreach ($products as $product) {
$translatedProducts[] = $translator->translate($product);
}
}
else
{
$translatedProducts = $translator->translate($products);
}
//print_r($translatedProducts); die();
return $translatedProducts;
}`
this is my function
Do you have your composer configured correctly? Seems like an issue with autoloader
yes i have
"autoload": { "psr-4": { "App\\": "app/", "Database\\Factories\\": "database/factories/", "Database\\Seeders\\": "database/seeders/", "Stichoza\\GoogleTranslate\\" : "vendor/stichoza/google-translate/src)" } },
I cannot reproduce this bug, can you list steps for it?
is there any restrictions for live server ?
There are no restrictions. Make sure you're deployment is correct
I encountered the same error after installation, but after a few minutes, it worked fine (I believe it's a vscode issue).