Tlanguage ========= Design-time internationalisation component. ------------------------------------------- TLanguage allows the application developer to provide instant language translation capabilities to their Delphi 4 applications, by just dropping a single component onto the main form of their application. After that there are three simple steps. A list property defines the required languages. A single design time property change triggers the component to produce a database containing all display based textual information from the components in the application, with database fields for all languages. The database can be edited independently to provide the required translation. A single statement in the OnActivate event handler for the main form loads the required language. Language switching can be provided at run-time by using a single instruction. Technical Specification ======================= Component Name -------------- TLanguage Version ------- Beta1.2 Published properties -------------------- BuildList --------- This property can only be changed at design-time. An attempt to change it in fact triggers the component to regenerate the database of text items in the application. DatabaseName ------------ This property is a simple Text property, which must specify a valid directory or Paradox BDE alias. It is not linked to a property editor. You must type the value in directly. It identifies the location for a Paradox table (Language.DB) which contains all the translations. KeepDatabaseWithEXE ------------------- Setting this property to true changes the DatabaseName property to the current directory for the project (at design time). At run-time the DatabaseName property is set to an empty string, causing your application to look for the translation database in the application directory. KeepPrevious ------------ This property is only of use at design-time. When true this causes a subsequent BuildList property change to update the existing database (if it exists). When false any existing database is completely overwritten by a regenerated version, thus losing any translation changes which may have been previously made by editing the database. Languages --------- A TStrings property that maintains a list of languages required by the application developer. Name and Tag ------------ Same as all other components. Public property Language -------- This acts to select the working language from the database of translations. A value of -1 (default) means the application uses the design time values for all textual information. Language selection values are from 0 (the first language in the Languages property to one less than the number of languages in the Languages property (the last). How to use the TLanguage Component ================================== There is minimal preparation required before using the TLanguage component. It suffices to identify a list of languages and to design your application such that there is sufficient room for displaying all potential text. Remember that small items such as labels for edit boxes have the biggest potential for change when translated to another language. The TLanguage component will extract the following list of properties from all components in all forms in the current project. * Text * Caption * Hint * Items * Lines A TLanguage component can be safely dropped onto the main form of a project at any time from initial form creation to just before the application is complete. Once the component is on the form, it can be selected and its initial properties set. Initially you just need to set the list of languages in the Languages property. This is done using a standard String list property editor. Having done this double-click the BuildList property (or choose true from the property drop down list). A prompt will appear asking you to confirm creation of the language database. By setting the KeepPrevious property to true a database regenerate will retain any existing data, but only for the current list of languages in the Languages property. If a rebuild occurs after adding extra languages to the Languages property, a new field will be created in the database for each new language. The values will be the current text values on the form. The first three columns in the database table form a unique key to identify a piece of text. These values should not be edited. The remaining columns correspond to the Languages property. These columns need to be translated and edited using the Database Desktop or any other suitable Database editor. The Database is created in Paradox 7 format, and requires the Borland Database Engine to be installed on the development machine and all target installations. At run-time, the Language property needs to be set, once all forms in the appplication have been created. During the OnActivate method of the main form is a suitable place. The statement: 'Language1.Language := 2;' will ensure the application above will use the third language in the Languages list. By setting the Language property based on a Registry setting it is possible to ensure that the application works in any language without compiling different versions. You just need to distribute the application along with its database, and set the appropriate registry values. Dynamic switching of language is available by allowing the user to select a language from a list based on the TLanguage components Languages property, and setting the Language property to the appropriate value. You may wish to make this a password-protected feature. Currently, TLanguage will overwrite all text items when translating. The appplication developer is responsible for performing any non-default text changes. Updating the database following modifications to a project The TLanguage component makes every effort to retain existing data (if KeepPrevious is set to true). Where new components have been added, new records will be added to the database. New forms in a project will be scanned and text added to new records in the database. Components and forms that have been removed from a project will be removed from the database. Where text is extracted from mutiline properties TLanguage makes every effort to identify those lines which have been retained and those lines which have been inserted or deleted. This is possible only if the first language in the list is unchanged. It is recommended to make the first language the native language of the application developer. As long as this is the case the text in the list can be re-ordered and interspersed with new data. TLanguage will keep existing text lines and place them in their new positions along with any new text. Currently any change in component names will result in any translations for these components being lost. Installing TLanguage ==================== * Unzip the distribution into a convenient directory. * From Delphi, choose Component|Install Packages... * Choose the Add... button from the resulting dialog. * Type in the path and filename (Language.bpl) for the TLanguage package (or use the Browse... button to select it. * Select OK. You should now have a TLanguage component on the Samples tab of your component palette. Software License ================ TLanguage is Shareware. You are authorised to download the TLanguage distibution ZIP file and distribute it without change as long as no fee is charged for the distribution. Feel free to make the TLanguage distribution ZIP file available from your Web pages or FTP site. You may use the TLanguage component in any software you create for personal use, but if you intend to distribute your software (for payment, or otherwise) with a TLanguage component built in you will be deemed to find the software useful. As such, if you find the component useful a donation of œ20 sterling is requested, made payable to John P Scott at 30 Adder Hill, Great Boughton, CHESTER, CH3 5RA, UK. Cheques and money orders made out in sterling only please. Folding money is acceptable in any currency. Disclaimer/Statement of Suitability or Fitness of Purpose ========================================================= The TLanguage component is provided as is and is not warranted to be suitable for any particular purpose. John P Scott shall not be liable for any claim resulting for loss or damage caused by using the TLanguage component howsoever caused. Beta1.02 Bug List ================= When setting BuildList in a multiple form application the database is updated or created normally but on completion an AV occurs within the VCL40 package. This does not cause any problems with the operation of Delphi or the functionality of the the application. Wish List ========= Make Language a published property, which allows design time selection of a language, and so allows the translation to be done within the Delphi IDE. Trap component name changes and update the database accordingly. Provide a call-back for application developers to hook in their own custom components for extraction of the text in fields other than the basic set (Text, Caption, Hint, Items and Lines When loading a new language, allow the developer to specify that only unchanged text data is translated, there by keeping run-time data changes. Tips for using TLanguage ======================== * Don't change the names of components once you have generated and modified your translation database. * Remove any records from the database that you do not want to take part in the translation process. * Keep a dummy form in your application with a TLabel for every literal string which you want to use in your project. Copy the caption for the label whenever you need the string. In this way your string literals will be included in the language database. This saves using string resources and having to include different DLL's for each language, or having different compiled versions.