Answer the question
In order to leave comments, you need to log in
How to change languages on a website in Laravel 5 without reloading the page?
Hello. Need help )
It is necessary to implement a language change on the site without reloading the page. Now everything works, but the page is reloading.
Now the code looks something like this:
<div class="language-selector">
<div type="button" id="langUsers" data-lang="{{ $langUser }}" data-toggle="dropdown">{{ upper($langUser) }}</div>
<ul class="dropdown-menu" role="menu">
<li><a id="en" data-token="{{ csrf_token() }}" href="javascript:void(0)">EN</a></li>
<li><a id="ru" data-token="{{ csrf_token() }}" href="javascript:void(0)">RU</a></li>
<li><a id="de" data-token="{{ csrf_token() }}" href="javascript:void(0)">DE</a></li>
</ul>
</div>
Answer the question
In order to leave comments, you need to log in
This is not a laravel level issue. Done via jvascript. You were offered an option with jquery, you can pervert with an ajax request of the entire page and replace the entire body, which is fraught with bugs.
Although the best option is to reload the page, especially since the language will be saved in the url so that you can easily add it to bookmarks or send via Skype email.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question