Language is set in config/app.php :
'locale' => 'en',
Just add your language pack in resources/lang. You can find it there.
If I well understand what you mean.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Laravel 5 how I can change language at Auth, Password Reminders & Reset ? When I open:: http://localhost/password/email/ http://localhost/auth/register/ http://localhost/auth/login/
I can see a default EN forms and errors messages! When I try Middleware set RU language its not help! How I can set different languages Auth, Password Reminders & Reset ?
Language is set in config/app.php :
'locale' => 'en',
Just add your language pack in resources/lang. You can find it there.
If I well understand what you mean.
I need dynamic change the language for multilang site with setLocale! When I make this URL http://localhost/ru/password/email/ , I can change lang the blade template, but errors or other messages still by EN
You want this probably: http://nielson.io/2014/05/easy-route-localization-in-laravel-using-filters/
In Laravel 5, you need to change the filter to a middleware
In the lang file, you should make an "ru" folder and translate all the messages in the "en" folder.
I created ru folder and all the massage translated! I try to middleware, but its don't work! How I can run middleware here:
Route::controllers([ 'auth' => 'Auth\AuthController', 'password' => 'Auth\PasswordController', ]);
This route control all auth and password urls
If you use for example a "lang" middleware, just create group in routes :
Route::group(['middleware' => 'lang'], function()
{
Route::controllers([ 'auth' => 'Auth\AuthController', 'password' => 'Auth\PasswordController', ]);
});
I've written a package to handle multi language routes / views in Laravel 5. It's relatively new so it can probably be improved much... but maybe it can be of use?
I created a global middleware for all routes ($middleware property app/Http/Kernel.php class)
<?php namespace App\Http\Middleware;
use Closure;
class SetLangMiddleware {
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (strlen($request->segment(1))=='2')
{
$request->setLocale($request->segment(1));
}
print $request->segment(1)."!!!";
return $next($request);
}
}
and when I'm opened URL for example http://localhost/ru/ - I saw EN blade template!
But, if I write code
if (strlen(Request::segment(1))=='2')
{
App::setLocale($request->segment(1));
}
into a routes.php - I successfully change the language!
I will try to explain my problem:
How I can explain it: after click Button http://localhost/ru/password/email/ my page was reloaded to default page http://localhost/password/email/ and e-mail was send, and then I redirect back to http://localhost/ru/password/email/ but with EN errors/status messages.
It's a rough workaround, but maybe you can try this:
views/ru/emails/password.blade.php
views/en/emails/password.blade.php
views/emails/password.blade.php
That last one will be loaded by default, so you could replace its content with this:
@include( App::getLocale() . '.emails.password')
Now it should load the correct language... You might want to check somewhere if the locale is valid (you have views for it)...
For error messages you'll have to create a language file in resources/lang/ru. You can just copy and translate the ones from the resources/lang/en folder.
@armix your code seem fine. Are you sure the middleware is run ? What happends if you put dd() in the handle method does it kill the app ?
Are you sure you put a ru subfolder in resources/lang ? With the correct files like https://github.com/caouecs/Laravel4-lang/tree/laravel5 ? Because if it doesnt exist it will put the en translations.
@ivanv please don't post ugly workaround. This thread will probably be read by other people and we don't want to mislead them by making them create a subfolder in view for each locale. The correct approach for internationalization is to set the locale through a middleware so we will get this to work.
@pmall How would you translate static views if they have alot of content? It's not very handy to put it all in a language file... Wouldn't you achieve the same result with the middleware (load the correct translated view)?
I decided my problem, when used into POST a hide form element with language parameter!
I used DB for save and fetch static content!
Please or to participate in this conversation.