Why invent the wheel if someone has already taken care of it?
Localization of the software is essential if you want to expand your market reach and sell the product to foreign customers. Developers who write under Delphi, can opt for three different ways to add a multilingual support to their applications. Firstly, you can do this through Resource DLL Wizard (that's, of course, if you have Delphi 4 or later). Secondly, you can write your own tool. However just like it is with anything which is handmade and exclusive, writing your tool will cost you time and energy which you could be put into more important things. If you want to accelerate the development life-cycle, the best way would be to use a ready-to-run tool, like TsiLang Components Suite. It's cheap, easy and guaranteed to work well. Anyway, why invent the wheel, if someone has already taken care of it, and people know this wheel works perfectly?
"It's what can be called money well invested"
TsiLang™ Components Suite has been adopted by hundreds of customers worldwide, and it's already helping them to make their software multilingual. Steve Jordi is one of them. He works as a software engineer at TiltSoft, Switzerland. His company specializes in the development of volcano monitoring software, which is distributed to end-users in many countries around the world. Before they switched to TsiLang, the company had been on the search for an easy-to-use, yet powerful tool to localize their applications for other countries. Along with simplicity and price, one of their specific requirements was that the software should be able to let end users translate the application on their own. None of the components were able to meet their requirements.
"We investigated and tried a lot of solutions", says Steve. "All of them described themselves as the best tool around. If we found TsiLang, it's because none of the others were really the best tools and we kept searching. Only TsiLang had a dictionary, only TsiLang had that dispatcher mechanism that allows coding the language switch at one place only. Only TsiLang was able to translate DBGrid column headers, etc. With this software in place, we can localize our software in hours. This saves time and efforts, and helps us be more focused on the development of the main project. We can recommend TsiLang Components Suite without a single hesitation. It's what can be called money well invested."
TsiLang Components Suite makes localization a two-hour trip
To give you the feel of how easy it is to use TsiLang software, we would like to use the example of Richedit, included in the standard Delphi set. Let's go multilingual in 8 steps!
- Open the Richedit.dpr project in Delphi.
- Start TsiLang Expert from Delphi. You do this through the Tools menu. In the opened TsiLang Expert window, you can see the toolbar with TsiLang control buttons. Below you can view the list of all the available project forms. (In our example these are "AboutBox" and "MainForm").
- Now double-click on the "MainForm". This launches the TsiLang Translation Editor. The editor displays the list of components, and two columns of edit fields, entitled as English and German. You look at the value in English and then type in the translated value in the adjacent field from the German column.
In the end you will see the fields filled with translation variables as in the picture below. With the same click-and-input simplicity, you can type in translation values for other properties.
As soon as you have localized all forms, you will see the situation as in the picture below:
- Our next step is to translate all string constants which are hard-coded in the source files. Click on "MainForm" and select the "Const Section - With form..." option from the drop-down File menu. This opens the form with all string constants, which were found in your unit source. You can delete any constant from this list if you don't want this constant to be multilingual. Simply select the line with this constant and click the "Delete" button.
As you can see in the picture above, the first column displays the line number, the second- string ID that will be used for this constant. For equal constants this ID is the same. The third column contains the used name of the string constant. The forth column displays the text that will be placed in your source instead of this constant. You can add any modifications here, if you want them to be placed too. At the bottom of the form you can see preview of the source code where the string is found.
In the picture above you can see that all string constants will be replaced by the respective call of the GetTextOrDefault() method of the TsiLang component. This method returns the string value based on the input string ID, in respect to the active language of the interface, or value for the first language if the translation is not available.
After clicking "Modify Source" all selected string constants will be placed in the "Strings" property of the TsiLang component. A special but simple code to translate them using TsiLang will be placed in your source lines. To input the translation for these strings, you simply open the TsiLang Translation Editor by double-clicking on the "Strings" property of TsiLang in the Object Inspector.
- To make your application truly bilingual, you need to replace TSaveDialog, TOpenDialog, TFontDialog and TPrintDialog components by TsiSaveDialog, TsiOpenDialog, TsiFontDialog and TsiPrintDialog components available from the "SiDialogs" components palette page. Link them to TsiLang by setting the "siLang" property. Open the Standard Dialogs Captions editor by double-clicking on the "DlgsCaptions" property of TsiLang in Object Inspector and type in the translations for common dialog strings.
- The next step is to add a language switch. You do this by placing the TsiLangDispatcher component in the MainForm (it is available on the "SiComponents" components palette page). Set NumOfLanguages property to 2 and type in language names in the LangNames property (in our example they are English and German).
Select the TsiLang component on the form and set the LangDispatcher property. You can see that the LangNames property of TsiLang change with respect to the same property of the TsiLangDispatcher. The TsiLangDispatcher component helps you to control the language switch process. Once you change its ActiveLanguage property, it changes this property in all TsiLang components linked to this dispatcher.
Activate the second form (in our example, it is "AboutBox"), add REMain unit to uses clause of Reabout unit, select the TsiLang component on the "AboutBox" and set the LangDispatcher property to TsiLangDispatcher component placed on the main form.
- The last thing to go is integrating the language switching realization. For example, it could be done in the following way:
- Add into the main menu of the main form the new top level item called "Language".
- Add two sub-items "English" and "German" to this item. Set "RadioItem" property of these items to TRUE. Set "Checked" property of "English" item to TRUE. Set "Tag" property to "1" for "English" item and "2" for "German" item
- Select both items and add OnClick event handler. Be sure that you have the same handler for both items. Place the following code in event handler:
procedure TMainForm.German1Click(Sender: TObject);
siLangDispatcher1.ActiveLanguage := TComponent(Sender).Tag;
TMenuItem(Sender).Checked := True;
- Compile your project and run it. The application is multilingual!