Springboot internationalization multiple pages


This is my first time i am working with springboot and thymeleaf. I got 2 pages on my application. A page with all cars and a config page for a specific car.



In my header i got a select box where the language can be changed. This appears on both pages. When i change the language i got a localeResolver that changes the language. I got 2 message.properties files for the 2 languages.



If i for example choose english the page is reloading with the english language. Then when i click on a car to go the that specific car config page he still remembers what language to use. But on the config page you can change the language aswell in the header. If i click on for example dutch it is working also.



But if i go to the previous page it still has the old url with localhost:9000/locale?lang=en_GB instead of localhost:9000/locale?lang=nl_NL.



When i return a view from a controller i want it to return it with the language.



This is my webMvcConfig



This is my controller that returns the view search.html



How do i return the view with a language parameter. So for example : localhost:9000/locale?lang=en_GB



I think you press go back button (←) of the browser. If that's the case it's not a problem at all.
Just remember to avoid providing too much functionality for your program.
You will just clutter your application with unnecessary code.



How often would a user choose a language in page 1, then goes to page 2, chooses another language there and then presses go back button of the browser?!



However, if you really need to add query parameters yourself, you should redirect to a new page as stated in this answer (which causes the client browser to send a new request to you):



You can also get the current locale in your controller method if that helps:






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

The Dalles, Oregon

“Thánh nhọ” Lee Kwang Soo chúc thi tốt, sĩ tử Việt Nam... có dám nhận hay không?

眉山市