foodineers / locale
Laravel Package for handling multicountry and multilanguage websites
Requires
- php: ^8.5
- illuminate/contracts: ^11.0||^12.0||^13.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- foodineers/laravel-devtools: dev-main
- orchestra/testbench: *
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-03 17:02:25 UTC
README
Laravel package for multicountry, multilanguage sites. URLs look like /en-it/about or /en/about. A locale middleware reads that prefix, and LocaleRedirector sends unprefixed requests to one.
Installation
composer require foodineers/locale php artisan vendor:publish --tag=locale-config
Usage
config/locale.php:
return [ 'countries' => ['it'], // ISO 3166-1 alpha-2. One entry is the default country. 'languages' => ['en', 'it'], ];
Register prefixed routes before the redirector. The redirector appends /{lang} or /{lang}-{country} to the current path, so it must not match an already-prefixed URL.
use Foodineers\Locale\Http\Controllers\LocaleRedirector; use Illuminate\Support\Facades\Route; Route::middleware('locale') ->prefix('{locale}') ->where(['locale' => '[a-z]{2}(-[a-z]{2})?']) ->group(function () { Route::get('/about', AboutController::class); }); Route::get('/{path?}', LocaleRedirector::class) ->where('path', '^(?![a-z]{2}(-[a-z]{2})?(/|$)).*');
The locale middleware alias is registered by the package. app()->setLocale() receives the language only.
Agent skill
Apps that sync skills with llm/skills get foodineers-locale. The instructions live in resources/skills/foodineers-locale/SKILL.md.
Testing
composer test
Changelog
See CHANGELOG.
License
MIT. See LICENSE.