How to make your application multilingual, and keep development efforts and costs to a minimum

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.
TsiLang Expert
TsiLang Expert
  • Step 2. Click in Expert’s  command panel menu File | Selected | Wizard. Click the Next button in the 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.
Translation Wizard. Step 1
Translation Wizard. Step 1
  • Configure the settings as displayed below and click the Next button.
Translation Wizard. Step 2
Translation Wizard. Step 1

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 the Expert to display the Translation Editor and enter translations for the 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.
Translation Editor
Translation Editor
  • Double-click on other form(s) in the TsiLang Expert to provide translations for the controls placed on these form(s).

Translating the hard-coded strings

  • Step 4. On our next step we will translate all hard-coded string in our source files. Click on “MainForm” and select the “File | Strings in Source| w/ form” command in TsiLang Expert’s commands panel. 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 the “Delete” button.
Strings in source
Strings in source

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 the 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 the 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 the TsiLang. You can translate them by double-clicking on this property in the Object Inspector.

Fine tuning

  • 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 the TsiLang in  the Object Inspector and type in the translations for the common dialog strings.

Code to switch language

  • Step 6. To add language switching code follow the following steps:
    • Add new menu item named “Language” to the top-level of the main menu.
    • Add “English” and “German” sub-menu items to the “Language” menu.
    • Set RadioItem property for these items to True and set Checked property of the English item to True.
    • Set Tag property to 1 for the English item and to for  the 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!

TsiLang Components Suite:

Copyright © 1998-2024 Igor Siticov, SiComponents. TsiLang®, Resource Builder® and SiComponents® are registered trademarks of Igor Siticov.
RAD Studio, Delphi and C++Builder are trademarks and/or registered trademarks of Embarcadero Technologies, Inc.

Follow us: