Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When i change lang in login page, not working. #9

Open
hh0210 opened this issue May 22, 2020 · 3 comments
Open

When i change lang in login page, not working. #9

hh0210 opened this issue May 22, 2020 · 3 comments

Comments

@hh0210
Copy link

hh0210 commented May 22, 2020

Code i had run

composer require laravel-admin-extensions/multi-language

edited config/admin.php with this 2 parts

'extensions' => [
    'multi-language' => [
        'enable' => true,
        // the key should be same as var locale in config/app.php
        // the value is used to show
        'languages' => [
            'en' => 'English',
            'zh-CN' => '简体中文',
        ],
        // default locale
        'default' => 'zh-CN',
        // if or not show multi-language login page, optional, default is true
        'show-login-page' => true,
        // if or not show multi-language navbar, optional, default is true
        'show-navbar' => true,
        // the cookie name for the multi-language var, optional, default is 'locale'
        'cookie-name' => 'locale'
    ],
],

'auth' => [
'excepts' => [
'auth/login',
'auth/logout',
'locale',
'handle_action',
],
],

Screenshot (45)

keoy7am added a commit to keoy7am/multi-language that referenced this issue Apr 27, 2021
@keoy7am
Copy link
Contributor

keoy7am commented Apr 27, 2021

You can try to do these things:

  1. Find auth.excepts in config/admin.php And add 'locale' .
    Looks like this
'excepts' => [
        'auth/login',
        'auth/logout',
        'locale',
],
  1. Open MultiLanguageMiddleware.php and add the code below in the first line of handle() function
config(['admin.auth.excepts' => ['auth/login','locale']]);

Same as PullRequest#12

  1. If it still doesn't work,
    Please check whether the current URL follows the https protocol
    If yes, Find https in config/admin.php .
    Make sure its value is true .

@kai890707
Copy link

Hi, @hh0210 .
I had this problem today too.
Sorry my English is not very good, but I hope to answer your question.
Maybe you can try this.

  1. find app/Http/Kernel.php And in this file search to middlewareGroups array.
  2. add this code to in side, \KevinSoft\MultiLanguage\Middlewares\MultiLanguageMiddleware::class.
    Look like this
    protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
            // add this line.
            \KevinSoft\MultiLanguage\Middlewares\MultiLanguageMiddleware::class
        ],

        'api' => [
            // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
            'throttle:api',
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],
    ];

I am not sure if this method is suitable for your project, but I can run it successfully !!!

kevin1018 added a commit that referenced this issue Oct 19, 2022
fix laravel-admin-extensions/multi-language/ #9
@blackcolt
Copy link

@kai890707 this fixed the translation for me, thanks. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants