Aris Scripting Tutorial - Part 5 - Object Attributes - All Output Formats and Multilanguage
It is time for the next tutorial. This time we will enhance again our report a bit, but also I am going to introduce the Multilanguage capability.
The main new features to be discussed are:
- Full output format support, including PDF, Word, RTF
- Multilanguage support via String Tables
Let's begin with the first.
Full output format support, including PDF, Word, RTF
Our previous result (see Part 4) has already covered PDF a bit, but if you run it, the output will show a preconfigured error message. There aren't many steps to enable the report for the additional formats:
1. Remove the warning from code lines 77 to 80.
2. Enhance the code to print a title also in PDF
It seams to me that only the PDF generator cannot work with merged cells. Therefore we keep a condition for them, but in all other cases we leave the current output.
3. Remove further PDF conditions
There are some more conditions in the code to handle specific PDF output. To enable all code pieces please remove these conditions on line 150 and 155 completely, but for sure keep the EndTable and BeginTable statements below.
Now, switch on the additional output formats like Word and RTF. In all cases the printout should work and create an accurate layout.
Multilanguage Support via String Tables
Note: This section belongs also to reports created with the Wizard!
To show the string table, activate the check box in the upper rigth window area:
In case you work with German, Portuguese and English, your table might look like this:
General Procedure when working with String Tables
To add elements, please perform the following steps:
2. Right mouse click, then choose "Selected text into string table ..."
This step will move the text into your string table, but also replace automatically the text in your Java Code by a function getString.
3. Update the Identifier
Usually you do not keep the given identifier; you make it a little bit more specific. Keep in mind that the Wizard creates identifiers like ID_DEFAULT_FONT, ID_REPORTDEFx and ID_STYLE_RD_xxxx. It is also suggested to use a kind of a prefix, followed by a more content specific word plus another to identify the details.
In my case I am going to name the first ID_META_DATABASE_NAME.
4. Move all textual Elements
Using this procedure, I am moving all textual elements out of my code into the string table.
There is one more feature I like to address. If you have the string "Database" twice in your code, the replacement will be done for both places automatically. This might be correct, but does not have to. Please review your code afterwards to make sure that all string table references are from logical and textual perspectives correct.
5. And also the Font Name
One more entry I like to add, it is the font name. Here I am using for the identifier the same as the wizard default (ID_DEFAULT_FONT). In this case it is really nice that the auto replacement will change the word "Arial" in all places on the fly:
The final string table will then look like this:
Enhancing a string table for Multilanguage
This step is quite strait forward, allows you to add more languages to the string table. Here are the steps:
1. Enable the string table
2. Right click in the header
3. Choose "Add language (copy text)" (my preference).
4. Select a language to add
This way you receive another tab for this language. Click on the additional tab and change the entries accordingly.
Hint: Use the key F2 to start editing an entry; by using a double click sometimes I am loosing my previous word.
Note: I would not translate the style formats, although these elements are also text. But as this text will not be presented to someone, there is no need for translation.
Please run a test and validate that your translations are correct. Sometimes your translated word or phrase is a little bit longer compared to the original, in this case you might tailor your layout a bit.
Please download the report file from here
Our report is now much more complete; we are supporting all common formats and are also able to create the layout in Multilanguage. Concerning the layout, a header and footer is still missing, we are going to cover this soon by introducing shared code management.
In the next article we will further enhance the code by adding a custom dialog.