I'm trying to translate a page (and only one). My problem is that the translation of the page works correctly, but validation errors remain in the default locale.
In my page controller :
public function globalPage($locale = 'en')
{
$page = Page::where('slug', 'global')->firstOrFail();
$this->data['title'] = $page->title;
$this->data['content'] = $page->content;
$this->data['page'] = $page->withFakes();
App::setLocale($locale);
return view('pages.global', $this->data);
}
In my route :
Route::get('{locale}/global', ['as'=>'page.global', 'uses'=> 'PageController@globalPage']);
Route::post('post-global', ['as'=>'page.post-global', 'uses'=> 'GlobalController@store']);
In my store function :
public function store(GlobalcontestRequest $request, $locale = 'en')
{
$global = new Globalcontest();
$global->firstname = $request->input('firstname');
$global->lastname = $request->input('lastname');
$global->email = $request->input('email');
$global->phone = $request->input('phone');
$global->lang = $request->input('lang');
$global->q1 = $request->input('q1');
$global->q2 = $request->input('q2');
$global->q3 = $request->input('q3');
$global->q4 = $request->input('q4');
$global->q5 = $request->input('q5');
$global->save();
App::setLocale($locale);
return redirect()->to(route('page.global'));
}
How to make validations errors in the same language as the locale I defined with App::setLocale()?