uretral/多语言

多语言

安装: 9

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 0

分支: 18

语言:Blade

dev-master 2023-11-04 09:55 UTC

This package is auto-updated.

Last update: 2024-09-04 16:35:55 UTC


README

安装

composer require uretral/multi-language

配置

首先,添加扩展配置

config/admin.php

        'multi-language' => [
            'enable' => true,

            'cookie-locale' => 'locale',
            'default_locale' => 'ru',
            'languages' => [
                'en' => 'English',
                'ru' => 'Русский',
            ],

            'cookie-country' => 'country',
            'default_country' => 'ru',
            'countries' => [
                'ru' => [
                    'title_ru' => 'Россия',
                    'title_en' => 'Russia',
                    'flag' => 'assets/admin/img/flags/ru.svg'
                ],
                'ae' => [
                    'title_ru' => 'Эмираты',
                    'title_en' => 'Emirates',
                    'flag' => 'assets/admin/img/flags/ae.svg'
                ],
                'tr' => [
                    'title_ru' => 'Турция',
                    'title_en' => 'Turkey',
                    'flag' => 'assets/admin/img/flags/tr.svg'
                ],
            ],

            'cookie-module' => 'module',
            'default_module' => 'tenant',
            'modules' => [
                'tenant' => [
                    'ru' => 'Жилец',
                    'en' => 'Tenant',
                ],
                'my' => [
                    'ru' => 'Собственник',
                    'en' => 'Landlord',
                ]
            ],

            'show-navbar' => true,
            'show-login-page' => true,


        ],

然后,添加除外路由到认证

config/admin.php 中,将 locale 添加到 auth.excepts

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