Use array for resourcestrings

edited 12:28AM in FastReport 4.0
Hi,

I would like to create a (constant) array that holds the resourcestrings for my report,
and use a function to return the translated string for each label on the report.

Code Example:

{aResStrings: array holding resourcestrings:
Element 0: LanguageID, Element 1: StringID, Element 2: Translation }

const aResStrings[0..nn, 0..2] of String = (
(('EN', 'INV', 'Invoice'), ('NL', 'INV', 'Factuur'), ('FR', 'INV', Facture')),
(('EN', 'QTY', 'Quantity'), ('NL', 'QTY', 'Aantal'), ('FR', 'QTY', 'Quantit?©')),
... )


Function GetResStr(LanguageID, StringID: String): String;
var i: Integer;
begin
Result := StringID;
for i := 0 to ....
if (aResStrings[i,0] = LanguageID) and (aResStrings[i,1] = StringID) then begin {Find the right string }
Result := aResStrings[i,2];
Break;
end;
end;
end;



The problem is that I can't define the constant array in the report. Any help/tips would be appreciated.

Regards, Jan

PS. If anyone knows a better way of creating multilanguage reports, please let me know

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 12:28AM
    work from delphi.
    with your resource string array.
    write a user function or an additional function in fr to passout the 2 integer values and return the string.
    create variables in fr like lid,str1, str2 etc to use in memos you can either give the str variables an expression using the new function or use it directly in a memo.
    [newfuntion(val1,val2)].



























































  • edited 12:28AM
    Dear Gordk,

    I can't work from Delphi because I use stand-alone reports.
    The report engine (and designer) is compiled into a separate dll, which is used for many different applications. So the translations really need to be in the report file itself.

    Thank you for your answer, Jan

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.