Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Best practice for i18n/locale selection?

Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,
I want to add locale (language) selection to my Servlet/JSP-based web site and like to hear about any i18n best practices or pointers there.
- If the user visits for the first time, the Accept-Language header of the servlet request should be used for determining a default locale. The user can either keep that default or make another selection on the web page.
- If the user selects another locale, he does so be clicking on a link that is present on any page of the web site. This action should only switch the locale, not the user location on the site map. For example, if the user was reading a specific entry in the guestbook, he should continue reading that entry but the navigational controls should appear in the newly selected language.
- The selected locale should be persistant:
* If the user is logged in, the user selected locale should be stored and loaded from the user database.
* If the user is not logged in, the selected locale should be stored and loaded from the session context.
* If the client cannot handle sessions, it looks like there is no way to persist the locale.
- I want to make extensive use of the JSTL (Java Standard Tag Library) for localizing my web pages:
* <fmt:bundle> should work without prior initialization.
* A construct like <c:if test="${locale == 'xx'}"> should also work (is there any better alternative?).
- Of course, the implementation has to be robust, performant, scalable, ...
I'd like you to share any thoughts about how you would implement these requirements.
More specifically,
- would you implement a servlet filter that is invoked prior to any resource in the web application, persisting the locale? Do any standard implementations of such a filter exist?
- is it a good idea to create an action Servlet/JSP with a backurl for selecting the locale? (/locale_selection?locale=xx&backurl=<came from this page> The action servlet could do the necessary modifications and then silently redirect the user to the "backurl".
girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic