This question already has an answer here:
If my website is working with multiple languages, when registering an article for example, there will be two fields for the title for example, suppose to be Portuguese and English, how I should create the logic to register and display based on the current language set by locale/route/{?}
With this I will can read my default laravel files and change the language with the rote:
Route
Route::get('locale/{flag}', 'App\LocaleController@setLanguage');
Controller
class LocaleController extends AppBaseController
{
public function setLanguage($flag)
{
if (in_array(strtolower($flag), config('app.locales'))) {
Session::put('lang', $flag);
}
return redirect()->back();
}
}
Edit
In my table I can have the same text in two or more languages, example: post_title_pt-br
and post_title_en
, how can I get the right title based in the current set language?
</div>