Laravel localization for multi-language apps

Carlos Mendez Jan 2026
4 tabs
<?php

return [
    'welcome' => 'Welcome to our application!',
    'greeting' => 'Hello, :name',
    'posts' => [
        'created' => 'Post created successfully',
        'updated' => 'Post updated successfully',
        'deleted' => 'Post deleted successfully',
    ],
    'items_count' => '{0} No items|{1} One item|[2,*] :count items',
    'time_ago' => ':time ago',
];
4 files · php Explain with highlit

Localization enables applications to support multiple languages. Translation strings live in lang/ directories organized by locale. I use the __() helper or @lang directive for translations. The trans_choice() function handles pluralization rules. Laravel determines locale from requests, user preferences, or config. The App::setLocale() method changes language dynamically. Translation files support arrays, parameters, and pluralization. For database-driven translations, packages like laravel-translatable work well. Validation messages auto-translate via language files. Date/time localization uses Carbon with setLocale(). This architecture makes adding languages trivial—just add translation files without touching code.