<< Click to Display Table of Contents >> Navigation: Create a PDF Editor > Delphi Example > Localization |
Due to the scripting the localization can be done easily.
Simply load a translated action XML file before the menus and actions are created.
To retrieve the original XML file use this code:
xmlstring := WPViewPDF.CommandGetStr(COMPDF_ACTION_READ,'xml',0);
to assign new XML data use this:
WPViewPDF.CommandStr(COMPDF_ACTION_WRITE,xmlstring);
It is also possible to update the caption of existing menus and actions. This code will update the main menu and the action list:
// The code only processes Actions and Menus with a certain prefix in the name
procedure TForm1.DoUpdateLanguage(Sender : TObject);
var i : Integer;
ac : TAction;
men : TMenuItem;
begin
for I := 0 to ActionList1.ActionCount-1 do
begin
ac := TAction( ActionList1.Actions[i] );
if (Copy(ac.Name, 1, Length(_ActionNamePrefix))=_ActionNamePrefix)
and (ac.Tag<>0) then
begin
ac.Caption := WPViewPDF1.CommandGetStr(COMPDF_ACTION_READ,
'caption', ac.Tag);
ac.Hint := WPViewPDF1.CommandGetStr(COMPDF_ACTION_READ,
'hint', ac.Tag);
ac.Update;
end;
end;
// Read kcaption - thats the caption of a action group.
// Only menus which a name which starts with _MenuNamePrefix are updated!
for I := 0 to MainMenu1.Items.Count-1 do
begin
men := TMenuItem( MainMenu1.Items[i] );
if (Copy(men.Name, 1, Length(_MenuNamePrefix))=_MenuNamePrefix)
and (men.Tag>0) then
begin
men.Caption := WPViewPDF1.CommandGetStr(COMPDF_ACTION_READ,
'kcaption', men.Tag-1);
end;
end;
end;