laravel-latam/spanish
Laravel Latam Spanish supplies Spanish localization files for Laravel, covering validation, authentication, pagination, passwords, and other framework messages. It helps Spanish-speaking teams ship localized apps faster, with easy installation and customizable translations for Latin American project...
Install the package:
composer require codericlatam/laravel-spanish
Laravel's package discovery registers the service provider automatically. On older skeletons, add CodericLatam\LaravelSpanish\LaravelSpanishServiceProvider to config/app.php.
Set the application locale in config/app.php (or .env):
'locale' => 'es',
'fallback_locale' => 'en',
Publish the language files (recommended so you can edit them):
php artisan vendor:publish --provider="CodericLatam\LaravelSpanish\LaravelSpanishServiceProvider"
As of 1.1.1, files land in lang/es/ (the Laravel 9+ location), not resources/lang/es/.
Look first at lang/es/validation.php — that is where 90% of day-to-day use happens. Also check auth.php, passwords.php, and pagination.php.
First use case: trigger any validation failure and confirm the message renders in Spanish:
$request->validate(['email' => 'required|email']);
// "El campo correo electrónico es obligatorio."
lang/es/ to your repo, and treat it as application code. You get Spanish defaults plus the ability to adjust tone (e.g., formal usted vs. neutral) without fighting the package.validation.php, auth.php) into lang/es/; the application's copy takes precedence over the package's for matching keys.loadTranslationsFrom/loadJsonTranslationsFrom, so __('validation.required') resolves to the package's Spanish string as long as locale is es.app()->setLocale($user->locale) so multi-language apps can use es for Spanish users and fall back to en for others.lang/es.json for flat app strings (__('Welcome back')) and the PHP arrays for framework keys (validation.*, auth.*, passwords.*). Keep the two worlds separate to avoid surprises.public function messages(): array
{
return ['email.required' => 'Necesitamos tu correo electrónico.'];
}
attributes array in lang/es/validation.php so messages say "El campo correo electrónico" instead of "El campo email".$this->assertSame('El campo nombre es obligatorio.', __('validation.required', ['attribute' => 'nombre']));
resources/lang to lang. This is the correct location for Laravel 9+, but it can break projects on older skeletons that still expect resources/lang. Pin ^1.1.1 on Laravel 9+ and ^1.1.0 on Laravel 8 or older.Application::useLangPath() (or uses a non-standard lang directory), verify where the package published. The 1.1.1 behaviour assumes the default lang_path().vendor:publish skips existing files. After upgrading the package, run with --force only if you are sure you have not customized those files — otherwise you will silently keep stale translations.php artisan optimize:clear (or config:clear + view:clear). Cached configs and compiled views can make it look like the package is not working.lang/es/ override package files. If a Spanish string is not updating, check for a leftover published copy shadowing the package.fallback_locale => 'en', any key the package does not cover will silently render in English. Grep lang/es/ before assuming full coverage.lang/es.json is not merged into the PHP arrays; a missing JSON key falls back independently.vendor/. Customizations there are wiped on composer update. Always publish.config(['app.locale' => 'es']) at runtime does not always propagate through cached config; prefer app()->setLocale('es') in tests and middleware.How can I help you explore Laravel packages today?