Highlighted

How to localize LiveCycle Form in different languages ?

tarekahf

21-09-2008

Dear All,

I want to localize the captions of the fields in PDF Form developed using Adobe LiveCycle Designer 7.1.

In order to do that, I figured out that have to prepare XML Data Source of all Captions and related text in the target language.

The languages are English, Arabic and French. For each Language, there must be one XML File which will be the Data Source of the required captions, and the captions on the form will be bound to that XML Data Source.

I need to find automated way (programmatic or any other way) to generate the XML in a special format using input for a Table in any Database, say MS Access/SQL, as follows:

I have input table of Captions in all languages that looks like the following (see the Excel Sheet below for a sample input table):

http://spreadsheets.google.com/pub?key=pDk9OsF0emb5zxEhSunL3UQ

Note: I am sorry as I do not know the French translation.

Using the above input table, I need to generate 3 separate XML Text Files as follows:

---- For Arabic ---


الاسم
العنوان
تاريخ الميلاد
عدد افراد الاسرة
الجنسية



---- For English ---


Name
Address
Date of Birth
Family Members
Nationality



---- For French ---


xxx
yyy
xxx
xxx
yyy


----

The Input Table above is relatively huge, and it may change from time to time, therefore, it will be very important to generate XML using programmatic approach.

I was able to use Dynamic Property Biding to bind the captions and the tool tip text to such XML Data Source, but I am still facing some difficulties.

So, after generating the above XML Files one for each language, and do all the binding in LiveCycle Desinger, then before publishing the forms LIVE, I will create 3 copies of the PDF form, one for each language, and use Acrobat to import the Resource XML File (using Import Form Data Menu Option) of the related resource language file in the related PDF File, and save the PDF file.

To summarize:
============

1. Is this the correct approach for localization, or there is better one ?

2. How I can generate the above XML in an easy way from the input table shown in the link above ?

3. Can I control the direction the the PDF From so that I can make it From Right to Left for Arabic instead of from Left to Right ? I want to avoid making a new separate PDF specially form Arabic Language. The direction will affect the reading order and the Tab Order of the Fields and the location of the Objects on the Form.

4. I figured out how to change the field alignment, caption location, and locale using javascript, but is there an easy way to change such properties using JavaScript for all fields in one go, because the form has 14 pages, and each page has many subforms which are nested up to 3 levels.

Please help.

Tarek.

Replies

Highlighted

Patrick_Leckey

22-09-2008

I haven't put a lot of thought into 1 and 2 ... it's a Monday morning! 😉 As for 3 and 4:



3> This cannot be controlled at runtime, although it would be an excellent idea. You should log this as an enhancement request with Adobe.



4> You can use collections of fields. For example, name a field on page 1 "TextBox1[1]" and on page 2 "TextBox1[2]". You can then use a SOM notation with resolveNodes (note the 's' on Nodes, this is different from resolveNode) and make a call like:



var coll = xfa.resolveNodes("xfa.form.form1.#subform[*].TextBox[*]");



This will return an array of field object into 'coll' that you can loop through.



There is more detailed documentation on SOM wildcard notation in the following document under the "Reference Objects in Calculations and Scripts" heading:



http://www.adobe.com/devnet/livecycle/articles/lc_designer_scripting_basics/lc_designer_scripting_ba...
Highlighted

tarekahf

22-09-2008

Thank you PDL,<br /><br />With regards to localizing the Text and Captions, I worked out a model using MS Excel Sheet, Pivot Table, and Linking to MS Access, and now I have a working model with semi-automated method to generate the XML Data Source of the Caption Text. I will post the details later.<br /><br />With regards to controlling the object layout during runtime, I started with this script on the Layout Ready Event of the "untitled subform" (page 1):<br /><br />var cnt = this.nodes.length;<br />for(var i = 0; i<cnt; i++) {<br /><br /> var elm = this.nodes.item(i);<br /><br /> if (elm.className == "field") {<br /><br /> switch (Language.rawValue)<br /> {<br /> case "&#8207;&#1593;&#1585;&#1576;&#1610;&#8206;": // Arabic<br /> elm.locale = "ar_SA";<br /> elm.para.hAlign = "right";<br /> elm.caption.placement = "right";<br /> elm.caption.para.hAlign = "right";<br /> break;<br /> case "English":<br /> elm.locale = "en_GB";<br /> elm.para.hAlign = "left";<br /> elm.caption.placement = "left";<br /> elm.caption.para.hAlign = "left";<br /> break;<br /> }<br /> }<br />//app.alert(elm.name + " - " + elm.className);<br />}<br /><br />---<br /><br />The above scripted is only working on the first subform of and only for the fields in "this" subform.<br /><br />And also, this code you prvided:<br /><br />>var coll = xfa.resolveNodes("xfa.form.form1.#subform[*].TextBox[*]"); <br /><br />will not give me a collection of all Required Fields (such as Text Field and Radio Button Fields and all others).<br /><br />Perhaps the question should be:<br /><br />1. How to get a collection of (or be able to loop through) all required fields (all Labels and any field that has a caption, placement, and alignment) in all pages and all subforms and the nested subforms ???<br /><br />2. With regards to the direction issue, I was reading the Adobe_XML_Form_Object_Model_Reference.pdf for version 8.0 and it seems there is a Direction Tag for the subform but not sure if this will be useful for my requirement.<br /><br />Just to make sure you understand what I am talking about, imagine that I want to flip the PDF Layout horizontally, so that all objects that were located on the left side, should be relocated on the opposite side starting from the right. I was thinking I could use the x,y coordinates of the field object to relocate the position during runtime using javascript. But this requires some complex formula to calculate the relative dimension in relation to the parent object. Can you help me on this ?<br /><br />Any feedback will be appreciated.<br /><br />Tarek.
Highlighted

tarekahf

22-09-2008

Just a small correction, I was refering to



XML Forms Architecture (XFA)

Specification

Version 2.6



not "Adobe_XML_Form_Object_Model_Reference.pdf"



In this document XFA Specs 2.6, page 192, I found a clear reference to direction of Text Flow for Arabic Language. It says that XFA before version 2.4, did not support Right-to-Left Text Flow.



How do I know the XFA Version I am using ?



Which LiveCycle Desinger I need to get XFA Version 2.4 and above ?



Can some one let me know how this will work ? I meas is it controlled via scripting or by property setting ..etc, how ?



Tarek.
Highlighted

tarekahf

24-09-2008

I managed to develop a working script to flip (reverse direction

/order of object placement) on a given subform, during runtime.



However, it seems that if you have a Table, it will be impossible to change the order/placement of cells in the table (meaning to flip table horizontally) during runtime.



Please correct me if I am wrong.



Tarek.
Highlighted

tarekahf

27-09-2008

Almost all of the above problems have been solved, and I managed to write javascript to flip all 17 pages and sub-forms horizontally and recursively to make the direction from Right to Left. Also, all field captions are now bound to XML Data Source for each language.



However, I am still facing the following problems:



1. I could not flip Tables. Table cells and columns seem to have Static Layout during runtime, and you cannot revers the order of such cells/columns. Any idea how to flip tables (make them from Right to Left).



2. When I flip the subform recursively and dynamically during run-time, all affected fields in a subform will loose there tab order settings and reset to the default. Can you control Tab Orders during run-time ?



3. Static Text (text objects) cannot be bound to Dynamic Captions. So, I changed them to Text Fields, and reduced the size of the Entry Part to minimum, but during runtime, when tabbing, the cursor will stop on such fields, and looks a bit confusing. How I can skip the Tab Orders for such fields ?



4. I downloaded LiveCycle Designer 8.2 trial, and tried to use the new Followed Text Setting of Subforms to be Right to Left, and Top to Bottom "layout = rt-tb". As per the book, it should work, but it is not working. When I use such setting, the form will generate errors in runtime, and the layout will be messed up. Any idea what is going on ?



Please help.



(Note: I will post the script I developed if needed).



Tarek.
Highlighted

tarekahf

27-09-2008

I just discovered another problem !!



When I bind the caption of an element in a repeating subform, and during runtime, when I add a new instance of the subform, only the first element will be bound to the translation, and the other instances are reverted back to the caption text from the design.



Please help.



Tarek.
Highlighted

tarekahf

05-10-2008

I have nearly completed the form automated localization logic using JavaScript.



I would like to know if there is a way to protect the JavaScript code inside the Adobe LiveCycle Designer Form. Basically, I do not want it to be easily accessible to any one who opens the form using Adobe LiveCycle Designer.



Is this possible ?



Tarek.