laraveles/spanish
Spanish language pack for Laravel with ready-made translations for validation, auth, passwords, and pagination messages, plus locale helpers to switch your app to Spanish. Drop-in installation and publishing make it easy to serve fully localized Spanish error and UI text.
Install the translation files into your app, then point Laravel's locale at them:
composer require laraveles/spanish
php artisan vendor:publish --provider="Laraveles\Spanish\SpanishServiceProvider"
On Laravel 5.5+ the service provider is auto-discovered; on 5.4 and below add Laraveles\Spanish\SpanishServiceProvider::class to config/app.php. There are usually two publish tags (one for lang files, one for pagination views) — if the provider command publishes both, fine; otherwise run php artisan vendor:publish and pick the laraveles.spanish / laraveles.spanish.views entries.
Then set the locale:
// config/app.php (Laravel ≤8); on Laravel 9+ use APP_LOCALE / APP_FALLBACK_LOCALE in .env
'locale' => 'es',
'fallback_locale' => 'es',
'faker_locale' => 'es_ES',
Where to look first: after publishing, resources/lang/es/validation.php (or lang/es/... on Laravel 9+) is the file you will actually maintain. attributes.php is the second one — it controls the human-readable field names inside messages.
First use case: submit a registration form and confirm the 422 response returns Spanish. If you see validation.required or English text, the locale isn't being applied or a key is missing (see Gotchas).
Per-request locale instead of a hardcoded default. Keep es as the default and resolve per user/request in middleware early in the stack:
public function handle($request, Closure $next)
{
app()->setLocale($request->user()->locale ?? config('app.locale'));
return $next($request);
}
FormRequest overrides are cheaper than editing the package. Translate field names and one-off messages at the request level:
public function attributes(): array
{
return ['email' => 'correo electrónico', 'password' => 'contraseña'];
}
public function messages(): array
{
return ['email.required' => 'Necesitamos tu correo para contactarte.'];
}
Override a single package line without publishing. Useful when you don't want to own the whole validation.php:
// AppServiceProvider::boot()
Lang::addLines([
'validation.required' => 'El campo :attribute es obligatorio.',
], 'es');
Auth and password flows. auth.php (failed, throttle, locked) and passwords.php (reset, sent, token, user) are used by the PasswordBroker and make:auth scaffolding — no extra wiring needed, just verify the flash messages come out in Spanish.
Pagination. Publish the pagination views and either restyle them for your CSS framework or point at them explicitly: {{ $paginator->links('vendor.pagination.custom') }}. If you're on Laravel 8+, the shipped Tailwind views hardcode "Previous/Next" — edit the published view itself, not pagination.php.
Testing translations. Freeze the locale in setUp and assert on the resolved string rather than on the raw file:
protected function setUp(): void
{
parent::setUp();
$this->app->setLocale('es');
}
$this->assertSame('El campo nombre es obligatorio.', __('validation.required', ['attribute' => 'nombre']));
Factories and seeders. With faker_locale => 'es_ES', fake()->name() and fake()->address() produce Spanish data — no changes to your factories required.
API responses. Send Accept: application/json (or call $request->expectsJson()) so Laravel returns the 422 payload with the translated message keys resolved. Nothing package-specific, but this is where Spanish messages are most visible to clients.
lang/ directory moved to the project root and the publish target may not exist. Publish, then move/copy manually into lang/es/.current_password, password, uuid, ulid, prohibited, declined, mac_address, ascii, plus newer password.letters/numbers/symbols sub-keys — have no Spanish translation. You'll see either the raw key (validation.current_password) or English if fallback is en. Add them to your published validation.php once and keep it under version control.vendor:publish never overwrites. After a composer update your published files are untouched, which is good — but it also means you must delete the target directory or pass --force when you intentionally want the package's newer version.fallback_locale. Leaving it as en silently papers over missing keys with English text in production. For a Spanish-only app set fallback to es in staging so gaps show up as keys during QA.pagination.php is effectively dead on Laravel 8+. The Tailwind paginator views don't read the previous/next keys. Publish and translate the Blade view instead.App::setLocale('es') in a controller after validation has run (or in a view composer) won't retroactively translate already-rendered errors. Use middleware or a service provider's boot.config:cache freezes app.locale. Changing the locale in a deployment usually requires php artisan config:clear/config:cache to take effect.attributes.php supports dot notation — use 'user.email' => 'correo' for nested request payloads; a flat 'email' won't match.vendor/. Changes vanish on the next composer update. Publish, commit, and treat the published files as app code — or fork the package if you need to track upstream.{0}, {1}, [2,*] separated by |. A stray space or a missing segment breaks the rule silently and falls back to the first variant.lang:publish can clobber your Spanish files with English scaffolding. Run it on a fresh project before copying in the Spanish files, never after.__('Some UI string') (Laravel 6+ reads lang/es.json), create it yourself; this package only covers validation, auth, passwords, and pagination.Validator::replacer() for custom placeholders, Lang::addLines() for runtime overrides, and Translator::setFallback() if you need a per-request chain like es_MX → es → en.How can I help you explore Laravel packages today?