Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Spanish Laravel Package

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...

View on GitHub
Deep Wiki
Context7

Getting Started

  1. 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.

  2. Set the application locale in config/app.php (or .env):

    'locale' => 'es',
    'fallback_locale' => 'en',
    
  3. 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/.

  4. 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.

  5. 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."
    

Implementation Patterns

  • Publish-and-own. Publish once, commit 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.
  • Selective override. You do not have to republish everything. Copy only the file you need (validation.php, auth.php) into lang/es/; the application's copy takes precedence over the package's for matching keys.
  • Use it without publishing. The service provider registers translations via loadTranslationsFrom/loadJsonTranslationsFrom, so __('validation.required') resolves to the package's Spanish string as long as locale is es.
  • Per-request locale switching. Combine with a middleware that sets app()->setLocale($user->locale) so multi-language apps can use es for Spanish users and fall back to en for others.
  • JSON vs. PHP keys. Use 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.
  • FormRequest customization. Override specific rules rather than the whole file:
    public function messages(): array
    {
        return ['email.required' => 'Necesitamos tu correo electrónico.'];
    }
    
  • Attribute names. Populate the attributes array in lang/es/validation.php so messages say "El campo correo electrónico" instead of "El campo email".
  • Testing. Assert translations directly to catch regressions when you tweak the files:
    $this->assertSame('El campo nombre es obligatorio.', __('validation.required', ['attribute' => 'nombre']));
    

Gotchas and Tips

  • 1.1.1 is a path fix, not a feature release. The publish/load path moved from 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.
  • Custom lang paths. If your app calls Application::useLangPath() (or uses a non-standard lang directory), verify where the package published. The 1.1.1 behaviour assumes the default lang_path().
  • Republishing does not overwrite. 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.
  • Clear caches after any lang change. php artisan optimize:clear (or config:clear + view:clear). Cached configs and compiled views can make it look like the package is not working.
  • Precedence order. Application files in lang/es/ override package files. If a Spanish string is not updating, check for a leftover published copy shadowing the package.
  • Fallback surprises. With fallback_locale => 'en', any key the package does not cover will silently render in English. Grep lang/es/ before assuming full coverage.
  • JSON translations are separate. lang/es.json is not merged into the PHP arrays; a missing JSON key falls back independently.
  • Do not edit vendor/. Customizations there are wiped on composer update. Always publish.
  • Locale is per-request. Setting config(['app.locale' => 'es']) at runtime does not always propagate through cached config; prefer app()->setLocale('es') in tests and middleware.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin