This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of DevSecOps Adventures: A Game-Changing Approach with Chocolate, LEGO, and Coaching Games and have Dana Pylayeva on-line!
See this thread for details.
  • 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
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Struts Internationalization: Translate descriptive action paths defined in struts config .xml file

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am working with Struts 1.2 for the first time, trying to make an existing website available in multiple languages. While I have already achieved multiple-language support by using language-specific property files (e.g. messages.properties, messages_de.properties, messages_it.properties and so on), there is one problem I simply could not solve: The website makes use of descriptive URLs such as www.domain.com/buy-this-thing, for which the action mapping is defined like so in the struts-config.xml file:



Now I am meant to also translate these URLs (the customer thinks this is more SEO- & user-friendly), i.e. for the German locale the URL www.domain.com/kaufe-diese-sache should map to the same action as www.domain.com/buy-this-thing for the English locale. I know that I can simply add a new entry to struts-config.xml, e.g:



This works fine, but is not very maintainable in my opinion. Instead, I would prefer to define the paths via variables the values of which are looked up in the language-specific property files. For example, the struts-config.xml should look like this:



Then I would like to add respective entries to all language-specific messages.properties. For example, messages_de.properties would contain a key-value pair url.buy.this.thing/kaufe-diese-sache whereas messages_it.properties would contain url.buy.this.thing/compra-questa-cosa. Unfortunately, I could not find any tutorials, examples or whatsoever in which the URLs were actually translated. Mostly, people simply use an approach without translating the URL, e.g. www.domain.com/en/buy-this-thing, www.domain.com/de/buy-this-thing, www.domain.com/it/buy-this-thing and so on.

Please let me know if you have any idea of how to solve this issue - or simply let me know if it is a stupid idea to translate the URL at all.

Cheers,
Stefan
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stefan Kolling wrote:
I am working with Struts 1.2 for the first time,



Welcome to the JavaRanch. If it is at all possible, do not use Struts 1. It is past "end of life", unsupported and has intractable architectural problems.
Looking around, it seems like other people have faced the issue you have. Here is a relevant discussion. Yes, it's Struts 2. I don't know if Struts 1 has comparable functionality.
 
Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic