Stefan Cameron on Forms
Building intelligent forms using Adobe LiveCycle Designer

Auto-Localizing Your Forms

A few days ago, I posted about Designer 7.1’s new Dynamic Properties feature. In that post, I explained how this feature could be used to automatically populate a list box or drop down list field with data from a data connection without having to write any script.

Today, I thought I would highlight one of the main advantages to using this feature: localization of your forms!

By using the Dynamic Properties feature to bind the caption of form fields to data nodes in a data connection, you can easily localize your forms without having to write any script!

To illustrate how this would work, I’ve designed a simple little form which has an address block on it (taken from the “Address Block” custom object that ships with Designer, found under the Custom tab in the Library palette). Each field in the address block (which excludes the “Locale” field at the top that’s just there for informational purposes) has its Caption property bound to a specific data node in the data connection I’ve defined, based on some different localized XML Data files. To localize the form at run-time (e.g. in Acrobat), just open the form and then load the XML Data file pertaining to the locale you want to use.

Download Sample [zip]

Minimum Requirements: Designer 7.1, Acrobat Pro 7.0.5.

Note: If you open the form in Acrobat, don’t forget to load a data file into it by using the options under the “File | Form Data” menu.

I should also mention that since it’s possible to have multiple data connections pointing to databases and/or WSDL connections, you could use one connection to localize your form and another to capture the data entered into your form (by binding the field values as usual, using the Binding tab in the Object palette, to data nodes in the second data connection). If you have any questions about this, I’ll be glad to answer them!


Posted by Stefan Cameron on August 2nd, 2006
Filed under Data Binding,Tutorials
Both comments and pings are currently closed.

5 Responses to “Auto-Localizing Your Forms”

  1. Mihai on August 2nd, 2006

    This is not fair!
    I was thinking about something very-very similar!

    But now, that you did it first, maybe you can also use these ideas, if you find them interesting:
    – attach the xml files to the pdf document (so that they are not stand-alone files)
    – have the locale in a combo-box, populated at load-time with the languages in attachments, and update the labels when the user changes the selection

  2. Zack on August 3rd, 2006

    Hi Stefan,

    I’ve got another unrelated question. I’m wondering if it’s possible to track the coordinates of a click inside an image field? What I’m wanting to do is to have something like an interactive pie chart for example, where clicking on one of the areas would change something else on the form. I could do this with a simple if statement inside the click event of the field – if I knew the coordinates of the click.

    A somewhat hack of this that I have more hope of working is to build the image out of multiple image fields and simply put different scripts on the separate image fields. Oh well, if you have any insight or an opinion on this please share. Thanks,

    -Zack

  3. Stefan Cameron on August 5th, 2006

    Zack,

    Your question was very interesting. So much so that I decided to write an entry about it:

    Tracking Mouse Clicks

    Let me know what you think.

  4. Julia on October 3rd, 2007

    Stefan,
    I have a following scenario with regards to the form localization (form is created using Adobe LiveCycle Designer v7.1)
    The labels on the form should change based on the user language selection;
    All the labels reside in the XML file(s), not in the database.
    Do you have an example of the script for this scenario?

    Thanks in advance
    Julia

  5. Stefan Cameron on October 14th, 2007

    Julia,

    It sounds like you’re pretty much wanting to do what my sample form is doing. My sample form has a few XML data files for various languages that you can load in order to change the captions of various fields to the selected language.

    The problem with XML data files is that they’re files. In this case, there’s no way around requiring the user to be part of the process. The best you can do is give them a button on your form which, when clicked, opens the Import Data dialog by using the following statement in the button’s Click event:

    xfa.host.importData();

    This will open the Import Data dialog where the user can find the appropriate XML data file for the language they want and load it into the form in order to change the captions.

    The reason behind this security: Acrobat cannot allow a form to access files on a user’s system without the user’s explicit consent. Requiring the user to choose the XML data file to load into the form implies consent, albeit it doesn’t provide for the best user experience. With Acrobat 8.1, there’s also increased security for ODBC and web service data connections whereby Acrobat will ask the user to allow the connection (by clicking on an “Allow” button in a popup dialog) prior to establishing the data connection.