laravel-lang/locales
Locale data package for Laravel Lang. Provides up-to-date locale definitions you can use across your Laravel apps, with documentation for installation and contribution guidelines. MIT licensed.
__(), trans()), and configuration management. Aligns with Laravel’s i18n patterns (e.g., app() helper, Blade directives).LocaleData objects (vs. raw arrays/strings) for type safety and consistency, reducing runtime errors (e.g., invalid locale codes).laravel-lang/locale-list, allowing updates without package version bumps (critical for compliance/regional changes).config/locales.php). No database migrations or schema changes required.trans() and JSON locale files (e.g., resources/lang/). Can act as a source of truth for locale metadata (e.g., native names, scripts, currencies).mix.js('flags/' + locale + '.svg')).Locales::getCurrent() and Locales::info() enable dynamic locale detection for APIs or CLI tools (e.g., artisan about).| Risk Area | Mitigation Strategy |
|---|---|
| Locale Data Staleness | External repo (laravel-lang/locale-list) allows community-driven updates. Monitor for major version bumps. |
| Laravel Version Lock | Supports LTS versions (11–13). Test against your target Laravel version pre-release. |
| RTL/Edge Cases | Limited testing for complex scripts (e.g., Arabic, Thai). Validate with real user flows. |
| Customization Limits | Forkable MIT license, but deep customization may require extending core classes. |
| Dependency Bloat | Minimal (~50KB). Audit for conflicts with other Laravel packages (e.g., spatie/laravel-translation-loader). |
en-US, fr-FR) or niche regions (e.g., az-Latn-AZ, sr-Latn-RS)?fr-CA → fr → en)? The package supports this but requires config.LocaleData object to map locales to asset paths.Locales::available() if your app has many locale checks.phpunit with laravel-lang/locales assertions.trans() with locale metadata (e.g., trans('greeting', [], null, 'fr-CA')).Locales::getCurrent() to set user-specific locales (e.g., via cookies/session).Rule::in(Locales::available()->pluck('code'))).{{ Locale::getCurrent()->native }} for dynamic UI labels./api/locales) for SPAs.Accept-Language header parsing).artisan commands with locale-aware output (e.g., --locale=fr).composer require laravel-lang/locales.Locales::get() in a single feature (e.g., language switcher).config/app.php to include the package’s service provider.config/app.php locale config to config/locales.php.LocaleData objects.Locales::available() if performance is critical.LocaleData for custom properties (e.g., holidays, timezones).| Component | Compatibility Notes |
|---|---|
| Laravel 11–13 | Officially supported. Test against your version pre-release. |
| PHP 8.1+ | Required for typed properties (LocaleData). |
| Translation Packages | Works with laravel-lang/translation-manager, spatie/laravel-translation-loader. |
| Asset Pipelines | No direct integration; use metadata to build custom pipelines (e.g., Vite/Webpack). |
| Databases | No ORM changes, but can store LocaleData as JSON in DB columns. |
| Third-Party APIs | Complements APIs like Google Translate by providing locale metadata. |
Locales::get().direction property).LocaleData for custom properties (e.g., timezone, holidays).laravel-lang/locale-list for updates.laravel-lang/locales for breaking changes (e.g., Laravel version drops).^2.11) unless new features are needed.laravel-lang/locale-list) reduces maintenance burden.LocaleData requires testing with each Laravel update.Locales::available()->pluck('code') for validation).direction property).config/locales.php).Locales::info() for runtime inspection.artisan about for package metadata.Locales::raw().Locales::available() in Redis.Locales::set() per tenant or use middleware to set the default locale.// TenantMiddleware.php
How can I help you explore Laravel packages today?