• Post Reply Bookmark Topic Watch Topic
  • New Topic

Internationalize using URL's subpath  RSS feed

 
David Kireev
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody!
I have a single page JSF application configured to use several languages (in faces-config/application/locale-config), but I want it to be more SEO-friendly - once user/robot opens //host/page.xhtml (or //host/) I want him to be redirected to //host/loc/page.xhtml (or //host/loc/), where "loc" is viewRoot's locale, but of course the same page must be shown. I suppose WebFilter should be a solution but I did not have any luck with it yet. Can you suggest any solutions, please?
 
Stephan van Hulst
Saloon Keeper
Posts: 7737
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think you should perform automatic redirection. Instead, use <link rel="alternate" hreflang="loc" href="loc/page.xhtml"/> in your head element, and search engines should then offer the most appropriate page to the user first. Once on your site, allow users to change language manually. It would be really annoying if the site redirected the user to some specific language, even if the user wants to view the page in another one.
 
Tim Holloway
Bartender
Posts: 18663
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan has a good point. My browser allows me to select what language(s) to display web pages in and what priority to use when selecting a language.
 
David Kireev
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the hreflang clue. Sure thing users will be able to change language. But the main problem is how to tell the jsf-engine to use a specific locale by analyzing page's subpath:
/ or /index.xhtml - use default mechanism (consider Accept-Language from client and faces-config/application/locale-config)
/loc1 or /loc1/ or /loc1/index.xhtml - use locale loc1 (still returning /index.xhtml - I used request dispatcher's forward method from WebFilter passing a HttpServletRequestWrapper with overridden getLocales method)

Currently my web filter appears to be working, but I hope you can suggest other approaches.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!