You are reading help file online using chmlib.com
|
Translation of hard-coded strings
TsiLang Components Suite allows you not only to translate your control's captions and other string properties, but also hard-coded strings, as well as constants declared under CONST section of a unit (See: Translation of CONST section).
TsiLang does this by modifying the source code in a way that the translation for a given string is retrieved automatically at run-time.
To translate a unit with a form select File|Source|With Form... (or File|Source|Without Form... for a unit without a form) from the TsiLang Expert main menu. TsiLang will scan the source code of each of selected units and will display the list of all hard-coded strings found.
The list displays:
a) The String ID. TsiLang generates a String ID for each string found. This ID will be used at run-time to retrieve the translation corresponding to a given string. TsiLang starts generating from IDS_0, but you can change this pressing the Start ID button and entering a new value.
b) The original string.
c) The code line that will replace the corresponding string.
d) The source line that contained the string.
Note: You can modify both a) and c) manually or even delete some of the strings. If you modify the string ID TsiLang will prompt you to replace all references to the old ID with the new one.
Finally, you have to press the Replace button to let TsiLang do the necessary changes to your source code.
Naturally, when you translate a unit that doesn't have an associated form, there is no TsiLang component that can 'translate' the strings at run-time. Here comes the only difference between translating a unit with or without a form. In the second case, you will have to choose which TsiLang component (or, rather, lying on which form) will do the translation of your strings at run-time.
Note: You can select several units from the list and apply this operation all of them simultaneously.
Here you can see the way TsiLang deals with hard-coded strings
Before
procedure TForm1.Button1Click(Sender: TObject);
begin
Caption := 'MyProgram';
end;
After
procedure TForm1.Button1Click(Sender: TObject);
begin
Caption := TsiLang1.GetText('IDS_1' (* 'MyProgram' *) );
end;
See also
You are reading help file online using chmlib.com
|