Localisation Form v1.3

Olivier Grosclaude (LocalisationForm@hotmail.com)
Copyright Somicronic 1999 - All rights reserved

FreeWare

Localisation Form translates most text properties (Caption, Hint, TStrings and embedded TCollection items) of the components found in the instantiated forms of the application at run-time.

(Nearly) all you have to do is add the Localisation Form to your project and it will automatically reference all the forms that will have been previously instantiated. To dynamically create forms that you want to be referenced by the Localisation Form, use TLocalisation.CreateForm instead of TApplication.CreateForm.
To prevent the properties of some components from being referenced, and therefore translated, set the tag property of the concerned components as follows:
-Tag and 1 = 0 to ignore their caption
-Tag and 2 = 0 to ignore their hint
-Tag and 4 = 0 to ignore the other strings
Hence a component with Tag = -7 will not be translated.

Hint: only component strings are translated, hence user messages need to be held in some hidden components, like the combo boxes used in the Localisation Form. For this purpose, the StringHolder available in the RX Library offers a more elegant solution, though.

How to use the Localisation Form to do the actual translation (user manual, sort of)
1. Show the localisation window.
2. When starting a translation, it is advisable to choose the application language that is to be used as a source for the translation, before switching to the target language. 
Note: languages for which no translation file exists are displayed in italics and in grey in the language combo boxes.
3. Press [Shift] + [F2]: the window expands to show a secondary language combo box and a tree structure which represents the different windows of the application and the text entries corresponding to each window.
4. To edit an entry, simply click on an already selected text or press [F2] when the desired entry is selected. When a text is translated, it is immediately replaced within the application; thus it is possible to check visually whether the translation is appropriate and whether the new text fits properly. Besides, whenever an entry is modified, its bullet becomes green as a reminder. The red bullet thus indicates new entries. As for the cross displayed over certain bullets, they simply signify that the corresponding controls are not currently present in memory; this may imply that they do not exist any longer in the application, in which case their entries can be deleted by assigning them an empty text.
5. The command [F9] inverts the colour of the selected bullet or the colours of all bullets if the [Shift] key is pressed at the same time. The command [Shift] + [Alt] +  [F9] changes all bullets into green.
Note:	unless it is doubled, the ampersand sign (&) does not show in the application: it is used as a tag to underline the letter following it. The underlined letter constitutes a keyboard short-cut towards the control to which it belongs. When the user presses the key which corresponds to this letter together with the [Alt] key, the control is activated in the same way as with the mouse. Naturally, a window should never have several identical short cuts, hence it is advisable, when choosing a short cut letter for a given element, to make sure that the same letter has not been used as a short cut for another element of the same window.
6. The entry selected in the tree view may be displayed in another language chosen in the second language combo box; the translation is displayed in the adjacent edit control. The text in this control may also be edited to be searched in the tree view when pressing the corresponding button (or the key [F3]). If the search text does not contain any capital letter, the case is not controlled. If no text is present in the edit control, red bullets are searched instead.
When the translation is completed, press the button "Save" (or the short-cut [Alt] + S). A language file is created in the applications directory. It has the same name as the application executable file followed by an underscore character and an abbreviation of the language. Its extension is ".lng".

Additional commands (some of which should be used cautiously)
- [F5] refreshes the treeview, whereas [Shift] + [F5] completely rescans the application to recreate the list of forms and components.
- [Shift] + [Del.] removes the references to all the components that no longer exist in instantiated forms. However, to erase the translation of a component that no longer exists, one should replace its text by a void string. [Alt] + [Shift] + [Del.] removes the references to all the forms that have not been instantiated.
- If the text to find entered in the edit control is "^x", the bullets with crosses whose parents do not have crosses are seeked, which comes to searching non existing components in instantiated forms, with the aim of removing their translation for instance.

How to change the application language
1. The property TLocalisation.LanguageCode may used to change the language programmatically.
2. When the Localisation Form is visible, the current language can be chosen among those available in the combo box.
Note: When the Localisation Form is created, it looks for a default language file named "ApplicationName_def.lng". If such a file is found, the Localisation Form will use it to translate the application at start-up time, and whenever the current language is changed, the default language file will be changed accordingly. This solution can be useful if you do not want to keep track of the currently selected language file in a configuration file or the registry. This file will be automatically created if you set the variable createDefaultLanguageFile to TRUE.

Notes
This project has undergone a vast amount of changes since I started it, mainly because I had seriously underestimated the complexity arising from the possible dynamic instantiations and deletions of forms and components. As a result, the produced code is often fairly unclear and so are the comments, which also feature the rather annoying characteristics of being sparse and not always intelligible.
However, it seems to be working reasonably well (at least it does for me) and it is pretty much free.
All comments, criticisms, suggestions are welcome, but do not expect me to make consequent improvements to the existing code.
Naturally, Somicronic accepts no liability from whatever in which the Localisation Form might be in any way involved.
