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

Does it working in controllers? #130

Open
SerikK opened this issue Feb 27, 2018 · 4 comments
Open

Does it working in controllers? #130

SerikK opened this issue Feb 27, 2018 · 4 comments

Comments

@SerikK
Copy link

SerikK commented Feb 27, 2018

Hi. Thanks for good extension. Does it working in controllers and models? What I am trying to do
trans('app.updated') not working. But following works:
trans('app.updated', [], UriLocalizer::localeFromRequest()).
I use files as translation source.

@Nizari
Copy link

Nizari commented Feb 27, 2018

He SerikK,

Do you use the localize middleware? In there it automatically sets the default locale and you wouldn't need to explicitly define UriLocalizer::localeFromRequest().

It's the file Waavi\Translation\Middleware\TranslationMiddleware. You can use it like:

Route::group(['prefix' => UriLocalizer::localeFromRequest(), 'middleware' => 'localize'], function () {
    Route::get('/', ['as' => 'home', 'uses' => 'PublicController@index']);
});

@SerikK
Copy link
Author

SerikK commented Feb 27, 2018

Yes, I use that in routes/web.php.

@AnasSafi
Copy link

AnasSafi commented Aug 5, 2018

I think you use "POST" route not GET

Waavi dose not work with POST

@sildraug
Copy link
Contributor

It does work with POST requests if it's not the first request the user makes and their language preference has been set in a cookie. However, this would not work in API.

We are considering making POST requests optional, would that work for you?

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

No branches or pull requests

4 participants