| Localization of PE files Delphi/C++ Builder |
|
|
|
The compiler and design environment in Delphi/C++ Builder allow the user to create PE files and localize created files. Besides standard resources, Delphi/C++ Builder places resources of VCL forms, frames and data modules into RC_DATA[#10] resources. PE files of this type are supported by two parsers:
The parsers help to add data to VCL resources correctly. The type of the parser is chosen automatically when a file is added to the project. The user can also choose it manually in the File Properties dialog. If the parser is chosen incorrectly, localized files may fail to work properly. There are several localization projects for PE files of Delphi/C++ Builder in demo samples. “Resourcestring” stringsStrings that need localization are placed to resources in a Delphi project. They must also be declared in the resourcestring section: resourcestring
There is no need to create RC files that contain string resources. This method is not recommended at all because it may cause conflicts with other libraries and components. The compiler determines which strings from the resourcestring sections are used and packs them to RT_STRING[#10] resources. Along with this, the compiler builds the DRC file with a list of strings, their indexes and unique names (creation of DRC files is permitted by the Detailed Map option in the properties dialog of a Delphi project). This file is important to update a Radialix project correctly when a new version of a localized file is available. RT_STRING[#10] strings in resources of a PE file are identified by index. The order and indexes of strings can change a lot even if changes in source texts are minor, or a localized application is recompiled. This happens because the compiler forms the order and indexes of strings automatically. Radialix 2 cannot match strings and handles them as edited when it updates resources. As a result, the user has to restore a part of the translation using auto-translation or manually (translations of modified strings are saved to memory of deleted translations). If the DRC file is connected, strings in RT_STRING[#10] will be assigned names, and resources will be updated correctly. The name of the DRC file is specified on the Source Settings tab in the File Properties dialog. VCL resourcesResources of VCL forms, frames and data modules are another type of localizable data in PE files, created in Delphi/C++Builder. Frames are containers with visual and non-visual components. Frames can be inserted to forms and other frames many times. Data modules are containers of non-visual components. All these resources are created in RT_RCDATA[#10]. Data inside a resource is stored as a tree, where the root is a form, frame, or data module. Names of resources correspond to names of VCL classes of these objects. In a general case, there is no exact match between data in a resource and properties of a created form (frame or data module) and components on it. VCL enables components to save into a resource their own internal data that may not possibly be changed in the Properties Inspector. The format of this data is entirely determined by the component code and is not known in a general case. You can view and change data of a resource in the resource editor on the Resource tab. To edit a resource visually, you need to create and load from a resource its root object and then all of its components. Components are created based on names of classes (names of classes are contained in a VCL resource). To match names of classes and real data of classes, Radialix 2 uses a PE file to extract RTTI information – data about classes and data types used in an application. This data is required for correct editing of resources and for work of the form designer. If there is no RTTI information in a file, or it is packed, Radialix 2 tries to determine the class hierarchy using templates or indirectly. As a result, the program may determine incorrectly or fail to determine an ancestor class for some classes. Such a component will be displayed and edited in the designer incorrectly. Radialix 2 handles a component as unknown if its ancestor class is not determined. The list of unknown classes is displayed in the message window after adding a file to the project, or after updating project resources. You can see the list of unknown components in all project files and ancestors assigned to classes of these components in the Unknown Components dialog of the Project menu. This dialog also allows the user to select parents of unknown classes. The hierarchy of classes can be viewed in the Classes dialog, which also allows you to assign ancestors of classes. In some cases, an attempt to create a visual representation of a form may fail. Too often it occurs due to incorrectly assigned ancestor classes. As a result, the user will not be able to edit a resource visually. The resource editor is the only way to edit in this situation. VCL form designerThe form designer displays a visual representation of a VCL resource. Properties of components can be edited in the Properties Inspector. As you do editing, Radialix 2 automatically updates data saved to a resource. Inherited components declared in an ancestor class have an icon in the upper-left corner. Наследованные компоненты (компоненты, объявленные в классе-предке) в левом верхнем углу содержат иконку Unknown controls are displayed as shaded rectangles: The designer resizes and snaps controls to guide lines and grid automatically. To enable these options, you can use the context menu, keyboard shortcuts, or toolbars: Form Designer - Alignment and Form Designer - Coordinates. If these panels are not displayed, you can enable them in the main menu. Go View>Toolbars. The Form Designer - Alignment panel can configure the mutual alignment of controls.
The Form Designer - Coordinates panel enables quick access to the settings related to position and size of controls. On this panel, you can also change the display mode – screen pixels (Pix), or dialog size units (DLU). This switch is not available for VCL resources. Screen pixels are always used.
As you edit VCL resources, you need to remember the following:
VCL resource editorThe VCL resource editor can be found on the Resource tab. You can use it to edit resource data directly. It can be useful if you, for example, saved to a resource a property, which cannot be modified neither in the form editor, nor in the property inspector, or in case when it is impossible to create a visual representation of a resource. The resource editor has these columns: Status – status of an object in a localization project (R, A, U)Components/Properties – tree of resource objects Type – class of a VCL object (inherited, list, inline) Original – property value in an original file Translation – localized property value. The VCL resource editor cannot insert new data into a resource but allows you to delete properties in a resource and components that have been added to a resource by the form designer. To do so, select the Delete option in the context menu (status of added objects is A, U). Automatic selection of VCL ancestor classesAncestors of unknown VCL classes can be set automatically. This occurs when you add files to a project or update resources. Classes are auto-assigned by matching a class name and a name template of a supported class. Templates may have wildcards (*) that stands for any number of characters. For example, the supported component called TProgressBar has a template – *ProgressBar. The TProgressBar class will be set as an ancestor for classes whose name end with ProgressBar: TExProgressBar, TSmartProgressBar, TCxProgressBar and others. The templates are listed in the VCL section of the Project Properties dialog. You can add a new template by editing the last string of the list. Templates are deleted from the context menu. In addition to class templates, you can also specify property templates that can be edited and property templates that cannot. You can do this on the Localizable Properties and Non-Localizable Properties tabs. By default, the list of these templates is empty. |