承接 badinansoft/nova-language-switch 相关项目开发

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

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

badinansoft/nova-language-switch

最新稳定版本:3.0.0

Composer 安装命令:

composer require badinansoft/nova-language-switch

包简介

A Laravel Nova package to switch language in your application

README 文档

README

Latest Version on Packagist Total Downloads

This Nova tool allows you to:

  • Add a language switcher to the header of the Nova application
  • Handle language switching and cache the current locale across multiple browsers
  • Switch the application direction for RTL-supported languages

Requirements

  • PHP: >=8.0
  • Laravel Nova: ^4.0|^5.0

Note: This package is not compatible with Nova 3

Features

  • Add multiple languages from the configuration
  • Remember locale settings using cache (no database table required)
  • Auto-inject language switcher to the application header
  • Easy 4-step setup

Screenshots

English Arabic
English Screenshot Arabic Screenshot

Installation

Install the Nova tool via Composer:

composer require badinansoft/nova-language-switch

Laravel 10 and Earlier

Register the tool in app/Providers/NovaServiceProvider.php:

public function tools()
{
    return [
        // ...
        new \Badinansoft\LanguageSwitch\LanguageSwitch(),
    ];
}

Register the middleware in app/Http/Kernel.php:

protected $middlewareGroups = [
    'web' => [
        // ...
        \Badinansoft\LanguageSwitch\Http\Middleware\LanguageSwitch::class
    ],
];

Laravel 11

Register the tool in app/Providers/NovaServiceProvider.php (same as Laravel 10):

public function tools()
{
    return [
        // ...
        new \Badinansoft\LanguageSwitch\LanguageSwitch(),
    ];
}

Register the middleware in bootstrap/app.php:

->withMiddleware(function (Middleware $middleware) {
    $middleware->web(append: [
        \Badinansoft\LanguageSwitch\Http\Middleware\LanguageSwitch::class,
    ]);
})

Publish the configuration file:

php artisan vendor:publish --provider="Badinansoft\LanguageSwitch\ToolServiceProvider" --tag="config"

Configuration

Edit the published config file (config/language-switch.php):

return [
    /**
     * Supported languages for your application
     * @var array<string, string>
     */
    'supported-languages' => [
        'en' => 'English',
        'ar' => 'Arabic',
        // Add or remove languages as needed
    ],

    /**
     * Languages that require RTL support
     * @var array<string>
     */
    'rtl-languages' => [
        'ar'
        // Add other RTL language codes
    ],
];

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 416.25k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 26
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 26
  • Watchers: 3
  • Forks: 15
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-10-19