![]() |
Image by Tobias Mikkelsen |
Internally, this is implemented in Form Runner with:
- A special XForms instance, fr-form-resources, which holds an XML document with the resources in one or more languages.
- Logic to pick the current language based on a number of factors (such as whether a specific language was requested with a URL parameter, or was already stored in the session, or was selected by the user).
- XForms logic which points to the current resources according to the current language and makes them available to all controls via an XForms variable called $form-resources.
One issue with this approach is that the logic must be duplicated, in particular within XBL components (including section templates).
So in Orbeon Forms 4.2, we introduce a new function called simply r (for "resource"), which you typically call with xxf:r('resource.name'). The function name is short as it might be used very often!
This function removes the need for the boilerplate logic in each form and XBL component (the resources instance, of course, remains). Here is a simple example:
<xf:item>With Orbeon Forms 4.2, this function is only used by a few XBL components. In the future we plan to update all XBL components as well as Form Runner and Form Builder to use this mechanism.
<xf:label value="xxf:r('year')"/>
<xf:value/>
</xf:item>
No comments:
Post a Comment