Search by

pharaonic / laravel-localization

Pharaonic

Localized routing for Laravel: static locale-prefixed URLs for websites, and an ordered resolver pipeline for APIs.

Package info

github.com/Pharaonic/laravel-localization

Homepage

Documentation

pkg:composer/pharaonic/laravel-localization

Fund package maintenance!

MoamenEltouny

Buy Me A Coffee

Statistics

Installs: 1 195

Dependents: 0

Suggesters: 0

Stars: 4

Open Issues: 0

13.0.0 2026-11-19 07:00 UTC

README

PHP Version : 8.3 | 8.4 | 8.5 Laravel Version : 13.x License Build
Source Packagist Version Packagist Downloads

Localized routing for Laravel: static locale-prefixed URLs for websites, and an ordered resolver pipeline for APIs.


Installation

composer require pharaonic/laravel-localization

The service provider is registered automatically. Publish the configuration when you need to change it:

php artisan vendor:publish --tag=localization-config

Usage

use App\Http\Controllers\ApiProductController;
use App\Http\Controllers\ProductController;

// config/pharaonic/localization.php: 'supported' => ['en', 'ar', 'fr'], with app.locale = 'en'

Route::localized(function (): void {
    Route::get('/products', [ProductController::class, 'index'])->name('products.index');
});
// /products (en), /ar/products, /fr/products; /en/products redirects to /products

Route::middleware('localization')->get('/api/products', [ApiProductController::class, 'index']);
// The locale comes from the user's preferredLocale(), then Accept-Language, then app.locale

locale()->route('products.index', locale: 'ar'); // "https://example.com/ar/products"

Upgrading from 1.x? See UPGRADING.md.

Documentation

Full documentation: Laravel Localization Documentation.

Support & Security

See SUPPORT.md and SECURITY.md. Contributions are welcome; see CONTRIBUTING.md.

License

MIT. See LICENSE.