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.
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.
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 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 diagram below shows an example of the database from the form above, after adding German to the previous list of languages. Note that the German values are identical to the English ones as they have not yet been translated.
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 final three 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
application 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 French language. By setting
the Language property based on a Registry setting it is possible to ensure
that the application work 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, a 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 application developer is responsible for performing any non-default text changes.
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 which have been removed from a project will be removed from the database. Where text is extracted from multiline 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.
You should now have a TLanguage component
()
on the Samples tab of your component palette.
TLanguage is Shareware. You are authorised to download the TLanguage distribution 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.
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.
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.
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 callback 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.