F
Filament6mo ago
Aminne

How i can translate the validation error message

I use filament language switcher plugin.
No description
Solution:
You can check a package like Laravel Lang: https://github.com/Laravel-Lang/lang...
GitHub
GitHub - Laravel-Lang/lang: List of 126 languages for Laravel Frame...
List of 126 languages for Laravel Framework, Laravel Jetstream, Laravel Fortify, Laravel Breeze, Laravel Cashier, Laravel Nova, Laravel Spark and Laravel UI. - Laravel-Lang/lang
Jump to solution
11 Replies
Dennis Koch
Dennis Koch6mo ago
Those should be default Laravel validation messages
Solution
Dennis Koch
Dennis Koch6mo ago
You can check a package like Laravel Lang: https://github.com/Laravel-Lang/lang
GitHub
GitHub - Laravel-Lang/lang: List of 126 languages for Laravel Frame...
List of 126 languages for Laravel Framework, Laravel Jetstream, Laravel Fortify, Laravel Breeze, Laravel Cashier, Laravel Nova, Laravel Spark and Laravel UI. - Laravel-Lang/lang
Aminne
AminneOP6mo ago
Thank you so much i will check it. I use the plugin filament switcher it's useful for this case ?
Dennis Koch
Dennis Koch6mo ago
Filament switcher just switched the locale. You still need the translations
Aminne
AminneOP6mo ago
okay i understand now, thank you. It works with this library, thank you this help so much .
Dennis Koch
Dennis Koch6mo ago
You're welcome
Aminne
AminneOP6mo ago
I have a quickly question how i use eager loading for avoid N+1 problem this's my code
public function index(ListPostRequest $request)
{
$validated = $request->validated();
$posts = Post::with(['comments.user', 'categories', 'user'])
->where('status', 'published')->get();
return PostResource::collection($posts);
public function index(ListPostRequest $request)
{
$validated = $request->validated();
$posts = Post::with(['comments.user', 'categories', 'user'])
->where('status', 'published')->get();
return PostResource::collection($posts);
public function toArray(Request $request): array
{ 'categories'=> $this->categories,
'author' => [
'id' => $this->user->id,
'name' => $this->user->name,
'email' => $this->user->email
] }
public function toArray(Request $request): array
{ 'categories'=> $this->categories,
'author' => [
'id' => $this->user->id,
'name' => $this->user->name,
'email' => $this->user->email
] }
My eager loading is correct ?
Dennis Koch
Dennis Koch6mo ago
Not sure why you need comments.user but apart from that it looks good.
Aminne
AminneOP6mo ago
I'm didn't provide all the code. Thank you for your help.
problemli
problemli3mo ago
Hey @Aminne How did you install the lang package? My normal translations work, but i want to use their premade messages for validation rules, and they are not used. Did you copy any files? Would be very grateful for any pointers... 🙂
Dennis Koch
Dennis Koch3mo ago

Did you find this page helpful?