How u said, i put:
TWPToolsEditor = class(TWPShadedForm)
But just some menuitens are translated when chaging the language on Wordpad5 demo.
How u said, i put:
TWPToolsEditor = class(TWPShadedForm)
But just some menuitens are translated when chaging the language on Wordpad5 demo.
I see where are the problem Julian.
Into wpDefActions there are wpaXXX and XA_XXX actions.
Open the WordPadDemo, change the language and look at menu items. U will see that some items (wpaXXX) are translated but other no (XA_XXX)!
Sample: File - New (XA_New)
if i change by WpaNew1 the caption is translated.
Why?
I see that some Action like CreateTable are diferents to XA and WPA, then I connot simply chage of action!
Hi,
The menu entries of the 'default editor' are not included in the the XML translation file. To translate it you need to do some extra coding to change the text in the captions.
Julian
Then I will create a new editor for me!
But, What actions I should to use? XA_ or wpa
I think the best is if you open the pascal units for the default editor and the datab´module which hosts the actions and see yourself what the actions do and which you can use.
Julian
Can you give a step by step procedure on how to translate the File|New menu item for example. There is not much documentation for the WPLanguageControl.
Thanks,
Hi,
File-Open is attached to a standard action and will be localized when the new action strings are loaded.
WPLangInterface := TWPLocalizationInterface.Create(WPLanguageControl1);
WPTools_LoadVCLStrings;
WPTools_LoadActionStrings; WPLocalizeLoadForms := TRUE;
see demo in Tasks\Localisation
Regards,
Julian Ziersch
The latest localisation demo does not compile properly in Delphi 5. I get the following error when I load the project:
Invalid property for WPRichText1.WriteObjectMode.
If I ignore this error, I get the following error while compiling:
Undeclared identifier: TWPManageHeaderFooterDlg
Hi,
did you rebuild the package? TWPManageHeaderFooterDlg was added some releases ago.
Julian
Zitat von wpsupportHi,
did you rebuild the package? TWPManageHeaderFooterDlg was added some releases ago.
Julian
I needed to add a uses wpManHeadFoot for it to work. Currently this uses is only added when WPREPORTER is defined (maybe you can fix this in your next demo release).
Now that the localisation demo is working, I still cannot figure out how to tranlate the default actions in wpDefActions. For example how do I translate the default File|New menu item in wpDefActions.pas. The name of the menu item 'New' is New1 is it's action is XA_New. Can you please tell me the exact steps required so that I can translate this menu item to 'Nouveau' in french.
Is there any documentation on how to use the TWPLanguageControl ? A complete documentation of TWPLanguareControl could help me answer these other questions about translation.
1- What are the steps required to translate my own button TButton1 ?
2- Do I need to create an action for this new button for the translation to work properly ?
3- Is there a way to scan all objects on my form so that I only need to enter the translation in the different languages ?
4- What is the meaning of 'C' and 'H' in the XML WPLanguageControl ?
Hi,
The action names are defined in the XML data which has been loaded into the TWPLanguage control:
Example:
<loc> <FR> <!-- This are the captions and hints for the actions and toolbar --> <WPAction> <!-- File Menu --> <wpaClose C="Fermer" H="Fermer"/> <wpaExit C="Quitter" H="Quitter"/> <wpaNew C="Nouveau" H="Nouveau"/>
The XML editor allows it to merge in new data. So it is possible to combine different language information.
The actions are updated when the method
WPTools_LoadActionStrings;
is called. This will load the cpations and hints from the XML data which is currently selected in the active localization interface.
The interface provides the access to the language control and is created like this:
WPLangInterface:=TWPLocalizationInterface.Create(WPLanguageControl1); WPTools_LoadVCLStrings; WPTools_LoadActionStrings; WPLocalizeLoadForms := TRUE;
To save a form you can use the LanguageControl method 'SaveForm'. Of course if you use it you need to save the XML data, too. You can then edit the xml data and load it back agaian. LoadForm will update the language.
Or, easier, you let your form inherit of TWPLocalizeForm.
If the gloabal WPLocalizeSaveForms = true all thise forms will save their strings when they are created. Yozu only need to call WPLanguageControl1.SaveToFile(f).
Example: The Localization demo uses this code to create an XML file with the contents of all dialogs:
procedure TWPTestLocalize.SaveLanguageClick(Sender: TObject);
var
i: Integer;
f : string;
begin
f := ExtractFilePath(Application.EXEName)+'wplang.xml';
try
WPLocalizeSaveForms := TRUE; //WPTOOLS5
WPTools_SaveVCLStrings; //WPTOOLS5
WPTools_SaveActionStrings; //WPTOOLS5
for i:=0 to RadioGroup1.Items.Count-1 do
(RadioGroup1.Items.Objects[i] as TWPCustomAttrDlg)._CreateFormAndFree;
{$IFDEF WPPDFEX}
with TWPCreatePDF.Create(nil) do Free;
{$ENDIF}
// This saves all other definitions, too
WPLanguageControl1.SaveToFile(f);
finally
WPLocalizeSaveForms := FALSE;
ShowMessage('Created the file ' + f);
end;
end;
Alles anzeigen
Some documentation for the "shared" components is online at
http://www.wpcubed.com/manuals/shared/index.htm
In the wpDefActions.pas unit, the File|New TMenuItem is called 'New1' and is linked to the 'XA_New' action. In the same unit, the 'StdActions' TActionList contains 2 actions: 'WPANew1' which is not attached to any menu items (is this normal ?) and 'XA_New' which is attached to the 'New1' TMenuItem.
In the WordPad5 demo application in the unit WPLocalU.pas there is a TWPLanguageControl which contains the translation for the 'wpaNew' action. This action is currently not attached to any TMenuItem (is this normal ?). If I create a new entry for 'XA_New' (in the 'EN' and 'FR' branch) in the WPLanguageControl1 of the WPLocalU.pas unit, the File|New menu item still does not get translated
Can you please tell me the exact steps required so that the File|New menu item gets translated in the WordPad5 demo application. Currently in the WordPad5 demo application, only the different dialogs and only some menu items are translated. If I get this working in the demo application, then I will make it work properly in my own application.
Ok - this was difficult.
I updated the SaveStrings method in WPDefAction to create an entry in the XML for all menu captions.
The created data looks like:
<loc>
<EN>
<DefaultActions_MainMenu
c_File1="&File"
c_New1="New"
c_Open1="Load"
c_CloseFile1="Close"
c_Save1="Save"
c_SaveAs1="Save As ..."
I posted the new unit here. It also include the XML file for translation. Use the XML editor (double click on the TWPLanguageControl) to load the translated strings into the datamodule WPLocalU.PAS.
To activate the localisation use
WPToolsEditor.WPDefAct.SelectLanguage1.OnClick := WPLocalisationDataModule.SelectLanguage;
WPToolsEditor.WPDefAct.SelectLanguage1.Visible := TRUE;
Saving is not necessary since the ZIP contains a template, but if you want to test it use
WPToolsEditor.WPDefAct.SaveStrings;
WPLocalisationDataModule.WPLanguageControl1.SaveToFile('c:\allstrings.xml');
Hope this helps,
Julian
This is the new SaveStrings and the LoadStrings method. It is a good example how to use the WPLangInterface to save a list of strings.
procedure TWPDefAct.SaveStrings;
var
lst: TStringList;
procedure SaveMenu(Menu: TMenuItem);
var i: Integer;
begin
for i := 0 to Menu.Count - 1 do
if (Menu.Items[i].Caption <> '-') and
(Menu.Items[i].Name <> '') then
begin
lst.Add('c_' + Menu.Items[i].Name + '=' + Menu.Items[i].Caption);
if Menu.Items[i].Hint <then> 2) then
begin
cmp := {was: Menu.}FindComponent(Copy(s, 3, j - 3));
if (cmp <> nil) and (cmp is TMenuItem) then
begin
if s[1] = 'c' then
TMenuItem(cmp).Caption := Copy(s, j + 1, Length(s) - j)
else if s[1] = 'h' then
TMenuItem(cmp).Hint := Copy(s, j + 1, Length(s) - j);
end;
end;
end;
end;
begin
if Assigned(WPLangInterface) then
begin
lst := TStringList.Create;
try
lst.Clear;
if WPLangInterface.LoadStrings('DefaultActions_MainMenu', lst, a) then
begin
LoadMenu(MainMenu);
end;
lst.Clear;
if WPLangInterface.LoadStrings('DefaultActions_GraphicPopupMenu', lst, a) then
begin
LoadMenu(GraphicPopupMenu);
end;
finally
lst.Free;
end;
end;
end;
Alles anzeigen
I took the new files in WPT5DefAction.zip (wpDefActions.pas and .dfm) and reinstalled the new package but it does not work.
I have also merged the file Default_Action_Menu_EN.xml into the WPLanguageControl1 in WPLocalU.pas.
For example, if I modify the value associated to c_New1 in the XML editor, when I switch language in the WordPad5 demo, the File|New menu item is still not translated.
What am I doing wrong ?
Hi,
did you edit the tags <EN> and </EN> in the xml file before you merge it in?
Julian
Zitat von wpsupportHi,
did you edit the tags <EN> and </EN> in the xml file before you merge it in?
Julian
Like I said un my previous post, I merged your new .XML file and I modified the value associated to 'c_New1' in the XML editor. When I switch language in the WordPad5 demo to 'FR' and then back to 'EN' (I only modified the EN translation), the File|New menu item is still not translated.
It still doesn't work. I have taken your XML file and modified the caption for c_New1 in the XML editor under the "EN' branch of the WPLocalU.pas for the WordPad5 demo.
After this change I run the WordPad5 demo application and the File|New menu item is still not translated.
Can you please try this yourself in the WordPad5 demo application and tell me what I am doing wrong.
I have the latest version 5.2.11 and I am using Delphi 5.