Add Developing multilanguage applications (updated)


How to build multilingual applications?

There are at least three reasons why a software developer or company may need to make their applications multilingual:

You distribute your software world-wide. In this case adding support for a few wide spread languages into your application would significantly increase your customer base.
You distribute the software in a country with two or more used (official) languages.
Most of your potential customers live in a country with different from your native language.

There are also at least three ways to build multilingual applications using Delphi or C++ Builder:

You could use Borland ITE (you must have either Professional or Enterprise IDE version 4 or higher).
You could design your own technology and realize it.
You could use third party components and tools that provide way to make your applications multilingual.

Using Borland ITE has as well pros as cons so each developer should decide by himself to use or not this feature of Delphi. There is a lot of documentation in online Delphi help about ITE so we will discuss only about two other ways.

Before starting to develop your own technology for creating multilingual applications you may need to consider two aspects:

How much time you'll spend for realizing it?
Would it fill all your requests?

Of course, there are strict rules in some companies that require using only self-developed programs that were written without using any third-party code or tools. But you should admit that following this way your company will be always at least one step back from other companies in producing software.

The Delphi component oriented environment allows you to find ready third party component and to use it in your application without spending a lot of time for developing your own. So on my opinion, before creating something by yourself try to check if there are no the same component worldwide available. When you find something that could fulfill your requests you or your manager should analyze what is better for your company:

To pay you for your time spent for creating the same component and to stop development of main application while your component will be ready.
To buy ready to use component and continue development of main application that is the main target of your development.

If you decided to use your own technology and design for building multilingual application then you could stop reading this article since we couldn't give you any ideas since we don't know what and how you think.

In the current article we will demonstrate using TsiLang Components Suite for building ready-to-use multilingual application. You can download the most current version of the Suite from http://www.sicomponents.com.

To internationalize a small project we have choosen Richedit example that is included in standard Delphi install set. Lets try to build multilingual application in 16 easy steps:

Open RICHEDIT.DPR project in the IDE.
Click the IDE menu Tools | TsiLang Expert to launch the TsiLang Expert. The Expert enumerates all forms in the current project and displays the project state in the window below:




Next, we will define the number and names of languages we need to add. Click the Expert menu Tools | Options. For instance, we implement support for English and German languages.



To add a TsiLang component to a form and open Translation Editor for this component, just double click on the form name in the Expert window. As we already set up default language names and type of TsiLang component, the Expert automatically places a new TsiLang component on the form, adjusts the component's properties and opens the Translation Editor. For instance, if we double-click on the MainForm we see the below picture:



Now we need to enter translations for German language. The translations might be typed directly in the Translation Editor or grabbed from Dictionary Manager which is a specilazed tool for storing and managing common words and phrases. Alternatively, if you do not know German, you can export all original data to an external file, send this file along with the special editor (the editor is included in the package and can be freely redistributed) to a translator, and later import the translations back.
Repeat the action 4) for all other forms or data modules in the current project.
Now we can translate all explicit and hard-coded string constants in the source files. Click the Expert menu File|Const Section|With form…". You will have appeared form with all string constants that were found in your unit source.



You can delete any constant from this list if it is not to be translated. Just select row(s) with this constant and click "Delete" button. As you could see on picture above the first column displays the string ID that will be used for this constant, for equal coostants this ID is the same. Second column contains the value of string constant. Third column displays the text that will be placed in your source instead of this constant; you can add here any modifications if you want that they will be placed too. And forth column displays the line of source where this constant was found. As you could see all string constants will be replaced by respective call GetText()/GetTextOrDefault() method of TsiLang component. Using GetTextOrDefault() is preferable because this method returns default value if the translation for active language is missing.
After this all selected string constants will be placed in the Strings property of TsiLang component placed on form and in your source lines they will be replaced by respective method of TsiLang. So for input translation for these strings just open TsiLang Strings Editor by double-click on Strings property of TsiLang in object inspector.
For creating real bilingual project replace TSaveDialog, TOpenDialog, TFontDialog and TPrintDialog components to TsiSaveDialog, TsiOpenDialog, TsiFontDialog and TsiPrintDialog components available from "SiDialogs" components palette page. Link them to TsiLang by setting "siLang" property. Open "Standard Dialogs Captions" editor by double-click on "DlgsCaptions" property of TsiLang in Object Inspector and input translations for common dialog strings.
Now, place TsiLangDispatcher component on the MainForm (it is available on "SiComponents" components palette page). Set NumOfLanguages property to 2 and input language names in LangNames property (English and German).
Select TsiLang component on the form and set LangDispatcher property. You could see that LangNames property of TsiLang was changed respective the same property of TsiLangDispatcher. TsiLangDispatcher component helps to manage the language switching process. Once you change its ActiveLanguage property it changes this property in all TsiLang components linked to this dispatcher.
Activate second of form of project (AboutBox), add REMain unit to uses clause of Reabout unit, select TsiLang component on the AboutBox and set LangDispatcher property to TsiLangDispatcher component placed on the main form.
Now the last and easiest step, including language switching realization. For example it could be like the following:


Add in the main menu of main form new top level item called "Language".
Add two sub-item "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:
  1.  
  2.     procedure TMainForm.German1Click(Sender: TObject);
  3.     begin
  4.         siLangDispatcher1.ActiveLanguage := TComponen(Sender).Tag;
  5.         TMenuItem(Sender).Checked := True;
  6.     end;



Compile your project and run it. Now you have multilingual project.

Following this way you will have single executable file with included multilingual support. You don't need any additional files, databases and so on. But you could use TsiLangRT or TsiLangRTSE components instead of TsiLang component if you need to build light multilingual applications. These components allow using external files with stored translation for building multilingual interface. TsiLangRT component contains embedded editor for translations that allows your users to modify and to add new languages to your application without your assistance. TsiLangRTSE uses the COM interface to SIL Editor application included into delivery that allows editing SIL files easy. The SIL Editor application is freeware so you can provide it to your users.

Also you can store your translations in Dictionary Manager that is included in delivery for future utilizing in other project. All TsiLang Editors allow automating the translation process. You can always make automatic translation of your project with translations stored in Dictionary Manager.

As you could see the building multilingual project using TsiLang Components Suite is quite easy and fast. You can find additional information about using TsiLang Components Suite in online help file or on SiComponents home page at http://www.sicomponents.com/
Related Discussions
  • RUNNING A DATABASE APPLICATION ON ANOTHER COMPUTER (2001-01-07 07:36:33)
    In the BDE on the other PC (the one without the database), you must add an alias to point to the location of the database in the format of:...
  • REPEATING FUNCTIONS (2001-01-04 11:46:34)
    The OnIdle event is not hardware dependent. It is called when the program has idle time. The OnIdle event is in TApplication and is a warpper...
  • TELEPHONE BASED APPLICATION (2001-01-08 12:29:39)
    I did something like this. I wrote a fully operative phone- based banking applciation in two days using VisualVoice and Dialogic cards. However,...
  • DELPHI WITH INTERNET.. (2001-01-05 21:35:50)
    http://www.matlus.com/scripts/website.dll This site is 100% Delphi built and 100% dynamic. All the content you see here is "database driven" and a...
  • HOW TO COPY A COMPLETE STRINGLIST TO THE CLIPBOARD? (2001-01-08 10:51:56)
    Where do you want to paste your items ?? In Notepad, or in your application ? If you want to copy it between your applications, I've exactly what...
  • CLOSE AN APP I JUST OPEN WITHIN DELPHI (2001-01-12 15:32:36)
    See this component... TRunner. http://sedlan.com/runner.php Key Features Available for Delphi versions 3, 4 and 5 Get the handle of the...
  • SENDING FILES VIA HTML!!! .... BUT WITHOUT ANY COMPONENT (2001-01-10 01:49:06)
    I really don't know if this will help you or not, but I came across it a while back and thought it might be of use to you regarding how you phrased...
  • HOW CAN I ACCESS BTRIEVE DATA FILES (2001-01-24 08:38:59)
    Try downloading the Btrieve programmer's guide : ftp://ftp.pervasive.com/documentation/btrieve/v615/B615PROG.PDF Good luck ...
  • DETECTING IF WINDOWS IS SHUTTING DOWN... (2001-01-12 15:16:08)
    Some info... 1: Go to http://www.used-disks.com/delphi/Components/Default.htm and download my TSystemEvents component. It will let you know...
  • COMMAND LINE ARGUMENTS? (2001-01-15 05:04:25)
    Here's the best way for me to do so... It's an article published in UNDU April 1998... If you don't want to read the article, just copy the unit...
Latest News
Submit News Form Past News
Latest Forum Entries