Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
Laravel

Localization in Laravel

Translate UI strings with language files and switch locales for multilingual apps.

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.

Leave a reply

Your email address will not be published. Required fields are marked *