Localisation Default Editor

  • 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!

  • 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

  • Zitat von wpsupport

    Hi,

    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 ?

    • Offizieller Beitrag

    Hi,

    The action names are defined in the XML data which has been loaded into the TWPLanguage control:

    Example:

    Code
    <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:

    Code
    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:

  • 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.

    • Offizieller Beitrag

    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:

    Code
    <loc>
    <EN>
     <DefaultActions_MainMenu
     c_File1="&amp;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

    • Offizieller Beitrag

    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.

  • 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 ?

  • Zitat von wpsupport

    Hi,

    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.