M
M
maxim_VV2015-09-03 18:05:27
JavaScript
maxim_VV, 2015-09-03 18:05:27

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>


How to do it without reboot?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anton, 2015-09-03
@SPAHI4

https://github.com/wikimedia/jquery.i18n

V
Vyacheslav Plisko, 2015-09-03
@AmdY

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.

D
Deodatuss, 2015-09-04
@Deodatuss

unload immediately in all languages ​​and then show and hide with a script?)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question