承接 byteflick/laravel-domain-localization 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

byteflick/laravel-domain-localization

最新稳定版本:v1.0.2

Composer 安装命令:

composer require byteflick/laravel-domain-localization

包简介

A Laravel package facilitating efficient locale determination based on domain names, simplifying multi-language website development.

README 文档

README

Domain-Based Localization for Laravel

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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.

Installation

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.
    ]
];

Usage

Step 1: Publish the Config File

Publish the config file via the command below and configure it according to your needs.

php artisan vendor:publish --provider="ByteFlick\LaravelDomainLocalization\LaravelDomainLocalizationServiceProvider"

Step 2: Apply the Middleware

On Specific Routes Only

You can add the middleware to individual routes or apply it via a route group.

Globally For Laravel 11

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);
})

Globally For Laravel 10

Add the middleware to your default middlewares into your App\Http\Kernel.php via the code below.

protected $middleware = [
    \ByteFlick\LaravelDomainLocalization\Middlewares\HandleLocalizationViaDomain::class,
];

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.

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-17