Re: Problem with RtlVclOptimize and resourcestring
- From: "Jaakko Salmenius" <jaakko.salmenius@xxxxxxxxxxxxxxxxxx>
- Date: Sun, 27 Apr 2008 18:24:29 +0900
Hi Salvatore,
The reason for this is that RtlVclOptimize caches resources strings. If you take a look at source code there is an array.
var
LastResStringRecs: array[0..64 - 1] of TResStringRecCache;
It contains the cached resource strings. If you change the resource module (e.g. by loading a new resource DLL) cached module handle and resource strings do not clear. The solution is simple: you have to clear the cache and module. Add the following function to RtlVclOptimize.pas
procedure ClearResourceStringCache;
var
i: Integer;
begin
LastResStringModule := 0;
LastResModuleInst := 0;
for i := Low(LastResStringRecs) to High(LastResStringRecs) do
LastResStringRecs[i].Res := nil;
end;
Call this function from your application after you have loaded a new resource DLL. Here is a sample that will be in tomorrow build of Sisulizer (I noticed that you use Multilizer. Sisulizer is similar but more advanced and stable tool).
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
DescriptionLabel: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
procedure Initialize;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses
RtlVclOptimize,
LaDialog; // This is a Sisulizer unit that enables runtime language switch
procedure TForm1.Initialize;
resourcestring
SOne = 'One';
STwo = 'Two';
begin
// Assing values for dynamic strings (e.g. strings set by run time)
Label1.Caption := SOne;
Label2.Caption := STwo;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
// Set the initial values for the dynamic strings
Initialize;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
// Prompt the user to select a new language and reload the new resource DLL
// and translates the form(s)
if SelectResourceLocale('EN') then
begin
// Clear the resource string cache
ClearResourceStringCache;
// Update the dynamic strings value by using new resource strings
Initialize;
end;
end;
end.
You can ask more information about Delphi localization from our support forum.
http://forum.sisulizer.com/
Best regards,
Jaakko Salmenius
http://www.sisulizer.com - Three simple steps to localize
.
- Follow-Ups:
- Re: Problem with RtlVclOptimize and resourcestring
- From: Salvatore Besso
- Re: Problem with RtlVclOptimize and resourcestring
- References:
- Problem with RtlVclOptimize and resourcestring
- From: Salvatore Besso
- Problem with RtlVclOptimize and resourcestring
- Prev by Date: Re: Paying for Unicode upgrades
- Next by Date: A not cool thing of TCoolBar
- Previous by thread: Re: Problem with RtlVclOptimize and resourcestring
- Next by thread: Re: Problem with RtlVclOptimize and resourcestring
- Index(es):