← Back to Course

Adding Localization and Translations

Localization lets a single Laravel application serve content in multiple languages, rather than maintaining separate codebases per language.

How Laravel Organizes Translations

Translation strings live in language files under the lang directory (or resources/lang in older versions), organized by locale.

lang/
├── en/
│   └── messages.php
├── es/
│   └── messages.php

Setting the Application Locale

App::setLocale('es');

The default locale is set in config/app.php, and can be changed per-request based on user preference, URL segment, or browser headers.

A Simple Translation File

// lang/en/messages.php
return [
    'welcome' => 'Welcome back!',
];

With the structure in place, the next step is actually pulling these translated strings into views and application logic.

Ready to master Laravel Training Course?

Join Uncodemy's hands-on Laravel program and build real, production-ready applications.

Explore Course