Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Report template translations

edited May 2007 in General
I'm using Delphi 7 and RB 9.02.

I need to create report templates for different languages (English, Russian
and Hungarian). By setting the TppReport template format to ftASCII I can
save the files and extract the strings that need to be translated into an
excel spreadsheet. These are then translated and inserted back into the
file. I don't really want to deploy the rtm files in this format as the file
size is quite large and can easily be edited. Is there a command line
compiler option to convert the files from ftASCII to ftBinary ?

I am using this approach because if I manually change the strings in the
report designer to be Russian, they look correct under English Windows but
are incorrect when run under Russian Windows. I guess this is due to the
different code pages. Is there another way to approach this ? I've not seen
anything on translating the report templates, only the designer / preview
dialogs.

Ian Munro

Comments

  • edited May 2007
    Hi Ian,

    Rather than trying to translate your template on the fly, I would suggest
    creating three different templates, each pre-translated. Then load each
    template based on which language you would like to display. If you have a
    translation app that you need to send strings into, you can create a report
    object loop and loop throught each text component inside the report after
    the template has loaded and translate the text.

    ----------------------------------------------
    Tech Tip: Loop Thru All Objects in a Report
    ---------------------------------------------

    A ReportBuilder report is composed of a set
    of components. The basic structure is

    Reports.Bands[].Objects[]

    The bands and objects within the report can
    be accessed directly by object name or
    via the Bands and Objects array properties.

    Below is an example of using the Bands and
    Objects array properties to change the font for
    all objects on a report.


    uses
    ppClass;


    procedure AssignFontToReport(aFont: TFont; aReport: TppCustomReport);
    var
    liBand: Integer;
    liObject: Integer;
    lObject: TppComponent;

    begin

    for liBand := 0 to aReport.BandCount-1 do

    for liObject := 0 to aReport.Bands[liBand].ObjectCount-1 do
    begin
    lObject := aReport.Bands[liBand].Objects[liObject];

    if lObject.HasFont then
    lObject.Font := aFont;

    end;

    end;


    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2007
    Hello,

    I'm using your "AssignFontToReport" function as shown below and have
    written a small program that opens an Excel spreadsheet and dumps the
    reports strings into it. The problem I have now is accessing some hard coded
    strings in the RAP code. I saved the report template in the ftASCII format
    so that I could open it up in notepad. Would I be right in saying that the
    RAP code is held at the end of the file in the "TraCodeModule" section ? If
    so, Is there a way to access this using a similar method to the
    "AssignFontToReport" function ? The only other way I though of getting round
    the problem was to place these hard coded strings on the report (and make
    them invisible) and then access them from the RAP functions.

    Ian




  • edited June 2007
    I should just clarify that I have modified the original function so it now
    looks like this :

    procedure TForm1.AddToSheet ;
    var
    liBand : Integer ;
    liObject : Integer ;
    lObject : TppComponent ;
    iCnt : integer ;

    begin
    iCnt := 1 ;

    for liBand := 0 to m_RptCtrl.BandCount - 1 do
    begin
    for liObject := 0 to m_RptCtrl.Bands [liBand].ObjectCount - 1 do
    begin
    lObject := m_RptCtrl.Bands [liBand].Objects [liObject] ;

    if lObject.Caption <> '' then
    begin
    XLSheet.Cells.Item [iCnt, 2].Value := lObject.Caption ;
    inc (iCnt) ;
    end ;
    end ;
    end ;
    end ;

    As you can see, I'm grabbing the lObject Caption.


  • edited June 2007
    Hi Ian,

    Take a look at the following example on accessing and modifying the RAP code
    present within a template. This should get you on the right track to
    accessing any RAP code you may need to.

    http://www.digital-metaphors.com/tips/RAPModifyPrograms.zip

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2007
    Hello,

    After a few hours work I have now created some code that extracts all
    the report strings that need to be translated into an Excel spreadsheet. I
    also have some code that takes the translated strings from the spreadsheet
    and inserts them back into the report file. The problem I am seeing now is
    that when I try my "translated" report under Russian Windows, all the text
    is displayed as question marks, eg "???????? ??? ??????" etc. I'm assuming
    that this is because when I save the report the Report Builder code is
    manipulating the data. Is there anyway to change this ?

    Ian



  • edited June 2007
    Hi Ian,

    This can be caused by a number of items. The article below may offer some
    insight to the issue.

    1. ReportBuilder does not currently contain any support for Unicode. We are
    hopeful that Borland will add Unicode support to the VCL in a future
    release - to make this a manageable task for us.


    2. It is our understanding that Unicode is not required to display a
    language properly. Any language can be displayed properly by configuring the
    Windows regional settings properly. However, if an application needs to
    display multiple languages, then Unicode is required. As an example, below
    is a tip from a customer for configuring a computer for Japanese.


    Note: RB also does not contain any support for Right to Left languages.


    -------------------------------
    Tech Tip: Configure XP for Japanese
    -------------------------------


    Please try the following steps:

    1. Install MS XP with Japanese support
    2. Change the value of Non Unicode Application setting to Japanese (in
    Advance tab of Control Panel's Countries and Language)
    3. For RB, you can set charset of ppLabel/ppDBEdit to SHIFTJIS_CHARSET or
    DEFAULT_CHARSET (for Multi-Lanugage application).
    4. For Paradox db file, you can set the LANGDRIVER of Paradox (in BDE) to
    Paradox 'japan' or 'ascii' ANSI (for Multi-Lanugage application).

    This method works for me.

    Contributed by Earnest Tse (ReportBuilder customer)

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.