deepcode-tech / laravel-multi-language

适用于laravel的多语言支持扩展

Stars
0

laravel Multi Language

安装

composer require deepcode-tech/laravel-multi-language

发布配置文件

php artisan vendor:publish --provider="Deepcode\MultiLanguage\MultiLanguageServiceProvider"

配置

需要调用中间件 lang:xxx,xxx对应该config/lang.php中每类配置

In config/lang.php

    [
        'enable' => TRUE,
        'middleware'=> 'web',
        'providers' => [
            'default' => [
                'enable' => TRUE,
                'languages' => [
                    'en' => 'English',
                    'zh-CN' => '简体中文',
                ],
                // default locale
                'default' => 'en',
                'is_api' => FALSE,
                'path' => '/',
                'domain' => NULL,
            ],
        ],
    ]

在laravel-admin中的配置

Then, add except route to auth

In config/admin.php, add locale to auth.excepts

    'auth' => [
        ...
        // The URIs that should be excluded from authorization.
        'excepts' => [
            'auth/login',
            'auth/logout',
            // add this line !
            'locale',
        ],
    ],

In laravel-admin/bootstrap.php, 添加语言切换菜单:

Encore\Admin\Facades\Admin::navbar()->add(new LanguageMenu());

登陆界面添加语言选择下拉

复制当前包中 views/login.blade.phpresources/views/vendor/admin/

ScreenShots

login
login1
language