I was looking into the support that Webcenter provides for internationalization. I have assets in English and Spanish to be displayed on web-page based on the user selection of locale. The method used in FirstSite is to have a page for every language. i.e. if I have 5 languages then I have 5 home-pages each of which has assets in different languages to be displayed. Locales can be set as a session variable and changed by the user.
I would like to use an approach similar to Struts where I have strings in a property file, one file for each language. I can achieve this by using a TLD having a java class that reads the strings from the property files and then translates them at runtime from the JSP. Thus we have only 1 page for all the languages.
Are there any other methods to achieve internationalization and specifically is there any built-in support from Webcenter to achieve this using one page only as I have done?
You can actually do that without a property file -
In the single page model it's the content that gets translated instead of every page - This means that EVERY item that is to be displayed should be encapsulated in an asset - this might be a bit cumbersome - but if you did it it would be like this:
On a page called Home - you would associate the default (or in Sites speak Master) assets and just create translated copies and then by using a Dimension set that meets your business rules you could display the page in English or French etc -
Your template would 'talk to the Page asset' , get the list of 'default items' then get the appropriate translated copies and render
If you have lots of 'strings' on your pages this might be cumbersome as each 'string' needs to be translated as well - however, (having taken both routes before) it's actually the same amount of work to translate - one can just be updated on the fly (content route) and the other needs a deploy (property file route)
Hope that helps
The guide has no code examples on implementing the Locale filter. How does one go about it?
I can associate the master assets(say English) with the page but how do I render the translated assets (say French) if the user chooses French. Do you use seachstates? Is locale a field in the asset as well? I would not like to hard-code the asset IDs or the locale IDs in the template... Any code would be helpful, thanks.