Administrator
|
Internationalization is requirement for a number of applications, and
the question "how is internationalization handled with PresentationServer?" is often asked. I will in this email suggest a standard way to implement internationalization using XForms. We have also added an example showing this in the latest "unstable builds", and since this is a mailing list, all of this is up for discussion. The basic idea is have the resources in the appropriate language for the current user in an XForms instance. (We will see later how they get in there.) The instance is assigned an id (i18n) and has a flat structure with "id" of the resources encoded in the element name: <resources> <web>Web</web> <images>Images</images> <news>News</news> <search>Search</search> </resources> The above instance is the one for the English locale. For another locale, the structure and name of the elements are the name, only the content of the elements change. To insert the word "Web" in the page, you use <xforms:output ref="instance('i18n')/web"/>. To generate a button with a "Search" label, you write <xforms:trigger><xforms:label ref="instance('i18n')/search"/></xforms:trigger>. Now, how do you get the instance with the appropriate localized text? In the XForms model for the page, you put <xforms:instance id="i18n" src="i18n-resources"/>. That will load "i18n-resources", relative the current URL. Say your form is on http://e.org/app/page, then this will load http://e.org/app/i18n-resource. Now you have to make this URL return the XML file with the appropriate resources for the current user. You map this URL to an XPL file in the page flow, with something like <page path-info="i18n-resources" model="i18n-resources.xpl"/>. In your resources, create multiple static XML files, one for each locale, with the structure we have seen earlier. Name those en_US.xml, ja_JP.xml, etc. Then in the XPL file (i18n-resources.xpl) determine what the appropriate locale for the current user is, for instance based on his preferences that you might have loaded and stored in the session on login, and select the appropriate file to output. If you get one of the latest "unstable builds", you can see this in action. Start by running the "internationalization" example. First you will be asked to select a language. This will just store in the session a locale. In a system where users login, you would typically store this information in the session on login based on the user preferences. The rest of the example works as presented above. Alex -- Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Free forum by Nabble | Edit this page |