![]() Properties Methods Events |
Unit
WPLngCtr
Declaration
TWPLanguageControl = class(TWPCustomXMLTree)
Hierarchy
TComponent <--TWPCustomXMLInterface <--TWPCustomXMLTree <--TWPLanguageControl
Subclasses
None
Description
This class - one instance is allowed in one project - manages the localization of the WP products and can be used for your own forms, too. It inherits from the WP XML interface class:
You can use the property editor (double click) to load and save the language data. This property also allows it to load and save sub-trees of the XML tree so you can add and remove language resources.
WPTools 4:
The localization can be done through the function pointers defined in unit WPLocalize or using the class TWPLocalizeForm. Please note that the function pointers in WPLocalize are all NULL as long as no instance of TWPLanguageControl has been created!
WPTools 5:
The localization has been updated. Instead of the interface unit wplocalize.dcu a COM interface is used. This interface has to be created in the main form of the application, using an instance of this class:
WPLangInterface:=TWPLocalizationInterface.Create(WPLanguageControl1); WPTools_LoadVCLStrings; WPTools_LoadActionStrings; WPLocalizeLoadForms := TRUE; |
var NewText : String; // This is the language id, for example "EN" begin // Check if there is an entry for this language id if WPLanguageControl1.Find('/loc/'+NewText)<>nil then begin // Switches the language ID WPLanguageControl1.GlobalLanguage := NewText; // Load the VCL strings (everything what is not on a form) WPLanguageControl1.LoadVCLStrings; WPTools_LoadActionStrings; end else ShowMessage('Language Code ' + NewText + ' was not defined!'); |
WPLanguageControl1.LoadForm('Forms/' + Form1.Name, Form1 ,true,true,true); |
WPLanguageControl1.SaveForm('Forms/Main',Self,true,true,true); // Update the XML Tree WPLanguageControl1.SaveToFile('LocFile.XML'); |
var xml : TWPXMLOneLevel; f : String; begin F := ExtractFilePath(Application.EXEName) + 'MainForm.XML'; xml := WPLanguageControl1.SaveForm('Forms/Main',Self,true,true,true); // ... any other forms ? // ... // This saves the branch we have just created // You can later 'merge' it into the main tree with the XML property editor // To save the complete tree use xml.Parent.SaveToFile ... xml.Comment := 'Localisation of ' + ClassName + '(' + Name + ')'; xml.SaveToFile(F,true); end; |
Introduced Properties |
![]() | Active | |
![]() | AutoLoadStrings | |
![]() | AutoSaveStrings | |
![]() | FileName | |
![]() | GlobalLanguage | |
![]() | OnLoaded | |
![]() | XMLData | |
![]() | XMLParent |
Introduced Methods |
![]() | Create | ![]() | |
![]() | Destroy | ![]() | |
![]() | Loaded | ![]() | |
![]() | LoadForm | ![]() | |
![]() | LoadString | ||
![]() | LoadStrings | ||
![]() | LoadVCLStrings | ||
![]() | SaveForm | ![]() | |
![]() | SaveString | ||
![]() | SaveStrings | ||
![]() | SaveVCLStrings | ||
![]() | WPAutoLocalize |
Introduced Events |
![]() | AfterLoadForm | |
![]() | AfterSaveForm | |
![]() | BeforeLoadForm | |
![]() | BeforeSaveForm |
Copyright (C) by WP |