Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Iljido's avatar

validation error messages are in english even if the page is in french

Hello, i'm working on making my website muti lang' (eng and french), but i don't know how to translate error validation messages , here's my controller

 public function store()
    {
        request()->validate([
            'title' => 'required',
            'body' => 'required',
            'channel_id' => 'required|exists:channels,id',
            'wilaya' => 'required',
            'type' =>'required',


$thread = Thread::create([
            'user_id' => auth()->id(),
            'channel_id' => request('channel_id'),
            'wilaya' => request('wilaya'),
            'title' => request('title'),
            'body' => request('body'),
            'type' =>request('type')
        ]);

        if (request()->wantsJson()) {
            return response($thread, 201);
        }

        return redirect($thread->path())
            ->with('flash', 'Your thread has been published!');
    }

so the problem is , if i set to french, and try to create a thread, the error message is displayed in english, i know i view for example we need to write

trans('file.smth')

is it the same in controller ? because when i did this, nothing changed, please help

0 likes
6 replies
Iljido's avatar

the default is eng in app.php and yes i user that link nd put all the files in eng and frensh

Iljido's avatar

so putting those files were useless ? xD , i thought it's like in blade where you juste put for exemple trans(validation.required) and it will display according to the language selected

Ishra's avatar

I am a little confused, does the translations work for you when you use trans() in blades, but not in your model? Do you get the french translation in your blade? Please attach an example of the code that is working in your blades.

Have you added the french translations in resources/lang?

If the language in config/app.php is english then all your translated messages will also be in english, if you want them in french you have to change the language to french.

You can do this in either the configuration file or during runtime using the App::setLocale method, link to relevant part of the documentation: https://laravel.com/docs/7.x/localization#configuring-the-locale

MisstypingMeerkat's avatar

Hi, i'm having the same issue where my error pages are not translated.

My default language is english. The main pages and error messages use translation strings and resources/lang/ files for the translation. If i switch to french, the main application works and displays everything in french.

However if i enter a invalid url or trigger any of the error pages, the correct resources/views/errors/404.blade.php is pulled up, but it uses the default app.locale ("en") instead the previously choosen "fr" language, and translates the error page with the (default) lang/en.json instead of the lang/fr.json.

The whole page including menu and footer is then displayed in english, but back to french as soon as i click a valid link from the menu. I seems like Laravel temporarily forgets or ignores the language setting as soon as it gets onto any error page...

Can someone please let me know what i'm doing wrong?

Please or to participate in this conversation.