Question

I would to internationalize my web app for multiple locales.

I've found several examples, like this.

They work, but in that cases it is displayed always the same page (that is if the user changes the language in any page, he/she is redirected to the home page for example).

I would that if the user clicks on a country flag (the html:link code is in a jsp file included by all the others jsp), the page (in which the user is) is reloaded. How could I do?

Was it helpful?

Solution

Your example link is clear: When the country flag is selected, the link goes to your "LanguageAction", set the Locale like this:

request.getSession().setAttribute(Globals.LOCALE_KEY, Locale.FRANCE);

Finally, redirect the page back to the last viewed page. This will require you get the request URL before changing Locale.

I hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top