Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Best practice for i18n/locale selection?

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
Requirements:
- 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".
Regards,
Andreas
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic