Introducing "Domain-Based Localization for Laravel" – a powerful Laravel package designed to streamline the localization process for multi-language web applications. With seamless integration, this package empowers developers to effortlessly assign locales based on domain names, simplifying the management of language variations across diverse web environments. Experience streamlined localization management and enhanced user experiences with Domain-Based Localization for Laravel.
You can install the package via composer:
composer require byteflick/laravel-domain-localization
You can publish the config file with:
php artisan vendor:publish --provider="ByteFlick\LaravelDomainLocalization\LaravelDomainLocalizationServiceProvider"
This is the contents of the published config file:
Note: If you set the mode to strict
then if the middleware cannot find a locale it aborts the request.
return [
'mode' => 'loose', // strict or loose
'locales' => [
'en' => ['name' => 'English', 'domain' => 'localhost.com'],
// 'es' => ['name' => 'Spanish', 'domain' => 'localhost.com.tr'],
// 'tr' => ['name' => 'Turkish', 'domain' => 'localhost.com.es'],
// ... More locales can be added here.
]
];
Publish the config file via the command below and configure it according to your needs.
php artisan vendor:publish --provider="ByteFlick\LaravelDomainLocalization\LaravelDomainLocalizationServiceProvider"
You can add the middleware to individual routes or apply it via a route group.
Append the middleware to your default middlewares into your bootstrap/app.php
via the code below.
->withMiddleware(function (Middleware $middleware) {
$middleware->append(\ByteFlick\LaravelDomainLocalization\Middlewares\HandleLocalizationViaDomain::class);
})
Add the middleware to your default middlewares into your App\Http\Kernel.php
via the code below.
protected $middleware = [
\ByteFlick\LaravelDomainLocalization\Middlewares\HandleLocalizationViaDomain::class,
];
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.