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 work with RAD Studio, Delphi or C++Builder can opt for three different ways to add a multilingual support to their applications. Firstly, you can do this through Resource DLL Wizard. 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 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 user-friendly, easy-to-use 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”
Customers all over the world use TsiLang Components Suite 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 has 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 other 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 to 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 process a two-minutes trip
To give you the feel of how it is easy to use TsiLang software, we would like to use the example of MDIAPP included in the standard Delphi delivery. Let’s move on to multilingual in 7 steps!
- Open or create the MDIApp.dpr sample project in RAD Studio, Delphi or C++Builder.
- Step 1. Start TsiLang Expert from IDE. You can do this through the Tools menu. In the opened TsiLang Expert window you can see the main menu bar and toolbar. Below you can view the list of all the available project forms. Select all of them.
- Step 2. Select in Expert’s menu File | Wizard or click the respective button on toolbar. Click Next button in appeared Wizard to start it.
- Select main form and set TsiLang type in the combo-box at the right. For all other forms in the list set TsiLangLinked.
- Configure the settings as displayed below and click Next button.
Entering translations just by mouse clicks
- Step 3. Once Wizard completes your project forms are already almost completely multilingual. Just double-click on any form in Expert to display Translation Editor and enter translations for user interface entries. To prevent translation of any entry you can leave value(s) for other language(s) empty or add this entry to exclusion list.
- Double-click on other form(s) in TsiLang Expert to provide translations for controls placed on these form(s).
Hard-coded strings translation
- Step 4. On our next step we will translate all hard-coded string in our source files. Click on “MainForm” and select the “File | Source| With form…” command in TsiLang Expert’s menu. This command will open the form displaying all hard-coded string constants found in your unit’s source. You can delete any constant from this list if you don’t want this constant to be translated. Just select the line with the needed constant and click “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 source string. For equal strings this ID will be the same. The third column contains the value of string in source. The forth column displays the text that will be placed into your source instead of this hard-coded string. You can add any modifications here and they will be used on replacement. At the bottom of the form you can see the preview of the source code where the string was found.
After clicking Modify Source button all listed hard-coded strings will be replaced by GetTextOrDefault() method of 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.
Original values of strings will be placed into “Strings” property of TsiLang. You can translate them by double-click on this property in Object Inspector.
- Step 5. To make your application truly multilangual you need to replace TSaveDialog, TOpenDialog, TFontDialog and TPrintDialog components by TsiSaveDialog, TsiOpenDialog, TsiFontDialog and TsiPrintDialog. These components are 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.
Language switching code
- Step 6. To add language switching code follow the following steps:
- Add new menu item named “Language” to top-level of main menu.
- Add “English” and “German” sub-menu items to “Language” menu.
- Set RadioItem property for these items to True and set Checked property of English item to True.
- Set Tag property to 1 for English item and to 2 for German item.
- Add the following code for OnClick event handler for both items:
procedure TMainForm.German1Click(Sender: TObject); begin siLangDispatcher1.ActiveLanguage := TComponent(Sender).Tag; TMenuItem(Sender).Checked := True; end;
- Step 7. Compile your project and run it. The application is multilingual!
You can download TsiLang Components Suite from our download page.