@gianmarx You still need to tell your provider where to find that class.. so you need to either use the full namespace, or import it at the top of the class:
use Day4\SwitchLocale\SwitchLocale;
or:
new \Day4\SwitchLocale\SwitchLocale([
//...
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
i installed this package on laravel nova https://github.com/u12206050/switch-locale.
after following the instructions to the letter I get the following error as soon as I load the following code into the provider:
public function tools()
{
return [
new SwitchLocale([
"locales" => [
"en" => "English",
"de" => "German"
],
"useFallback" => false,
"customDetailToolbar" => false //optional
])
];
}
the interesting thing is that I always get the same error. whether it has the package installed or not the thing that triggers the error is that you load that code into the provider
this following error:
Error Class 'App\Providers\SwitchLocale' not found
Sorry, that was a typo.. should be new \Day4\SwitchLocale\SwitchLocale([.. I'll update the snippet
Getting yourself a coding editor that automatically resolves the namespace can help in these situations.
Please or to participate in this conversation.