Support the ongoing development of →
Configuration Views Forms
Last updated 2 years ago.

You need to set the app's locale to the choosen language, e.g.: \App::setLocale($language);

In our applications all urls are prefixed with the language, for instance: /en/user/list And a custom middleware just sets the locale on every request using the first URL segment.


Thanks for the reply. Please break it down for me because I'm not a Laravel or PHP expert.

I want to have two idioms: EN and PT.

Have set the middleware in App/Html/MiddlewareApp.php:

<?php namespace App\Http\Middleware;

use Closure;

class App {

 * Handle an incoming request.
 * @param  \Illuminate\Http\Request  $request
 * @param  \Closure  $next
 * @return mixed
public function handle($request, Closure $next)
       \Session::put('locale', \Config::get('app.locale'));


    return $next($request);


In kernel.php:



<?php namespace App\Http\Controllers;

use App\Http\Requests;

use App\Http\Controllers\Controller; use Auth; use Session; use Input; use Redirect; use Illuminate\Http\Request;

class LanguageController extends Controller {

public function index()
	Session::set('locale', Input::get('locale'));
	return Redirect::back();



Route::post('/language', array(

'before' => 'csrf',
'as'	=>	'language-choose',
'uses'	=>	'LanguageController@choose'


In Config/App.php I have:

'locale' => 'en',

Do I need to add 'pt' ?

Thank you.

Last updated 9 years ago.

You are triying to reinvent the wheel dude. Check out this package:


jartaud said:

You are triying to reinvent the wheel dude. Check out this package:

Yes, have worked on that package since yesterday. It's not fully working but I'm getting there.


Sign in to participate in this thread!


Your banner here too?

Perseus0 perseus0 Joined 23 Feb 2015


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.