Use array for resourcestrings
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
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
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)].
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