Laravel

Laravel Localization: Build Multi-Language Apps

January 16, 2026 1 min read 20 views

Build multilingual applications:

Translation Files

// lang/en/messages.php
return [
    'welcome' => 'Welcome to our application',
];

// lang/ar/messages.php
return [
    'welcome' => 'مرحباً بك في تطبيقنا',
];

Using Translations

echo __( 'messages.welcome');
echo trans('messages.welcome');

Set Locale

App::setLocale('ar');

Middleware

public function handle($request, $next)
{
    App::setLocale($request->segment(1));
    return $next($request);
}
Share this post:

Related Posts

Comments (0)

Please log in to leave a comment. Log in

No comments yet. Be the first to comment!