blumewas / laravel-locale-fallbacks
Opiniated variant on how localizations should be resolved
Package info
github.com/blumewas/laravel-locale-fallbacks
pkg:composer/blumewas/laravel-locale-fallbacks
dev-main
2026-01-12 18:55 UTC
Requires
- php: ^8.4||^8.3
- illuminate/contracts: ^11.0||^12.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0||^3.0
- pestphp/pest-plugin-arch: ^4.0||^3.0
- pestphp/pest-plugin-laravel: ^4.0||^3.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
This package is auto-updated.
Last update: 2026-03-30 16:42:06 UTC
README
Opiniated variant on how localizations for an app should be loaded.
Installation
You can install the package via composer:
composer require blumewas/laravel-locale-fallbacks
You can publish the config file with:
php artisan vendor:publish --tag="laravel-locale-fallbacks-config"
This is the contents of the published config file:
return [ /** * Define the fallback chain for each locale. * The keys are the locale codes, and the values are arrays of fallback locales. * For example, if 'de' falls back to 'en', you would set: * 'de' => ['en']. * This means that if a translation is not found in 'de', it will look for * the translation in 'en'. * You can define multiple fallbacks for a locale. * For example, 'de' => ['en', 'fr'] means it will first * try 'en', and if not found, it will try 'fr'. * A fallback chain is also composed. E.g. if 'de' falls back to 'en', * and 'de-DE' falls back to 'de', we will first try 'de-DE', * then 'de', and finally 'en'. This would be equivalent to: * 'de-DE' => ['de', 'en'], * 'de' => ['en']. */ 'fallbacks' => [ 'de' => ['en'], ], /** * Whether to automatically add two-letter language codes as fallbacks. * This is useful for apps that have regional variations of languages * (e.g., 'en-US' and 'en-GB') and want to ensure that * the two-letter code ('en') is always available as a fallback. */ 'autofallback_two_letter_codes' => true, ];
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.