Laravel 5 And His F*cking non-persistent App SetLocale

Laravel 5 And His F*cking non-persistent App SetLocale

Hey! Looking for a more SEO Friendly way to manage a multilingual application with Laravel5 ?Check this tutorial!

Edit: This article have been updated to match Laravel 5.2 architecture.

If you ever have worked already with Laravel 5 (if not, you should), and that you needed a decent way to switch language into your application, well good luck.

The thing is, it was really easier with Laravel 4.

Ok I'm not going to explain why and how and all, because you know that I mainly use my website to store snippets and reminder about HOW I SOLVED THIS NIGHTMARE OF A PROBLEM.

Relax.

In most of my applications, I don't really like having the language in the URI, because it messes with my Route file, and I have to update all my links.. Anyway, here's how I managed to build a simple Language Switcher, that will just update the localization of your application, and refresh the page.

First, create a new controller "LanguageController". You can use this command : php artisan make:controller LanguageController