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

Persistent Locale #44

Closed
Krato opened this issue Jun 8, 2016 · 2 comments
Closed

Persistent Locale #44

Krato opened this issue Jun 8, 2016 · 2 comments
Assignees
Labels

Comments

@Krato
Copy link

Krato commented Jun 8, 2016

Hi, i just install this package. But I'm a little confused.

I have config/app.php with:

'locale' => 'es',

And config/localization.phpas:

'supported-locales'      => ['en', 'es'],

    'accept-language-header' => true,

    'hide-default-in-url'    => false,

    'facade'                 => 'Localization',

    /* ------------------------------------------------------------------------------------------------
     |  Route
     | ------------------------------------------------------------------------------------------------
     */
    'route'                  => [
        'middleware' => [
            'localization-session-redirect' => true,
            'localization-cookie-redirect'  => false,
            'localization-redirect'         => true,
            'localized-routes'              => true,
            'translation-redirect'          => true,
        ],
    ],

I have and admin panel without routes translates. And In my views if I call dump(\App::getLocale()), allways get en neveres. But es is the default language. If I call dump(\App::getLocale()) in routes.php file shows es.

But If I call Localization::getCurrentLocale()shows correctly es.

My route is for example: blog/new. And Route is not in localization middleware:

Route::group(['prefix' => 'admin', 'middleware' => 'role:admin'], function() 
{
    Route::get('/blog/new', '\App\Blog\Controllers\PostController@create');
});

Why locale is set to en? How can I do it?

Thanks!

@arcanedev-maroc
Copy link
Member

Honestly, i can't see what is exactly your issue (and i can't reproduce it).

But, if you want to force the locale (Single locale for the admin panel), set a default locale inside a constructor of your Base Admin Controller and extend it to your Controllers (Use the Localization::setLocale() method).

Or use the Localization::getCurrentLocale() instead of App::getLocale().

@Krato
Copy link
Author

Krato commented Jun 9, 2016

Sure, I can use Localization::getCurrentLocale(). But the problem is that APP load lang files using App::getLocale(). So I need to fix it.

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

No branches or pull requests

2 participants