Localization in Laravel — a practical guide to Laravel localization with clear examples you can reuse in real projects.
Laravel Tutorial Series (21/27). Prefer one page? Read the complete Laravel tutorial (all 27 topics).
Short description
Localization stores language strings in files and displays the correct language based on the active locale.
Language files
`lang/en/messages.php`:
return [
'welcome' => 'Welcome to our site',
];
`lang/hi/messages.php`:
return [
'welcome' => 'हमारी साइट पर आपका स्वागत है',
];
Use translations
<h1>{{ __('messages.welcome') }}</h1>
Set locale
App::setLocale('hi');
// or in middleware from session/user preference
session(['locale' => 'hi']);
app()->setLocale(session('locale', 'en'));
Tip
Use JSON lang files (`lang/en.json`) for short UI phrases if you prefer key = English text.