Laravel Localization and Translations
January 16, 2026
•
1 min read
•
44 views
Table of Contents
Localization in Laravel:
Translation Files
// lang/en/messages.php
return [
'welcome' => 'Welcome, :name!',
];
// lang/ar/messages.php
return [
'welcome' => 'مرحباً، :name!',
];
Use Translations
__('messages.welcome', ['name' => 'John']);
@lang('messages.welcome', ['name' => 'John'])
Set Locale
App::setLocale('ar');
$locale = App::getLocale();
Middleware
public function handle($request, $next)
{
App::setLocale(session('locale', 'en'));
return $next($request);
}
Related Posts
Laravel Sanctum API Authentication Complete Guide
Build secure API authentication with Laravel Sanctum for SPAs and mobile apps.
Laravel Rate Limiting: Protect Your Application
Implement rate limiting to protect your Laravel application from abuse.
Laravel Blade Components: Build Reusable UI
Create powerful reusable components with Laravel Blade.
Comments (0)
No comments yet. Be the first to comment!