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