Keywords: Multilanguage, multilingual, bilingual, TsiLang Components Suite
How to build multilingual applications.
There are at least three reasons
why most serious programmers need to build multilingual
- You want to build
professional well-distributed software that will be
popular all over the world.
- You have customers in other
country with different from your native language.
- You are in country with two
or more state languages.
There are also at least three
ways how to build multilingual applications using Delphi:
- You could use Delphi's
Resource DLL Wizard (if you have Delphi 4 or later).
- You could design your own
technology and realize it.
- You could use third party
components and tools that provide way to make your
Using Delphi's Resource DLL
Wizard contains a lot of pros and 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 Resource DLL
Wizard so we will discuss only about two other ways.
Before starting to develop your
own technology for creating multilingual applications you should
analyze two aspects:
- How much time you'll spend
for realizing it?
- Would it fill all your
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
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
- 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 I couldn't give you any
ideas since I don't know what you think.
Now I will describe how to build
ready-to-use multilingual application using TsiLang
that could be downloaded from
http://www.sicomponents.com. The last version that was released at
this article time was version 4.9.
For starting to use TsiLang
you should install it in Delphi IDE. If you used setup program
and you have Delphi 3 or later then it is already installed in
Delphi IDE, otherwise you can read "INSTALL.TXT" file
for installation instruction.
We will demonstrate just the few
features of TsiLang
Components Suite on
Richedit example that is included in standard Delphi install set.
Lets try to build multilingual application in 16 steps:
- Open RICHEDIT.DPR project
- Open TsiLang Expert
from Delphi menu. Select "Tools|TsiLang
Expert". You will have appeared the TsiLang
Expert form with list of project forms available
like on picture below:
- Select main form (MainForm)
in the list of forms. You will see that disabled buttons
are enabled now. Click on the button with "0"
caption (it indicates the number of languages for
selected form) and in appeared edit filed input the
amount of languages that you need to have in this form.
For example 2, we will have bilingual application.
- Double-click on the
MainForm in the list of forms and you will have appeared TsiLang
Captions Editor where you can input translation
values for components' "Caption" property for
- Input translation values
for second languages. We will have the German as second
language of our application and English as primary
- In the same way we can
translate all other properties for performing this just
click on the buttons on Expert's tool
- Repeat these actions for
second form. After this you will have the situation as
presented on picture below:
- Now we can translate all
string constants hard-coded in the source files. Select
MainForm and select in Expert's menu
". 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 you don't want that this constant will
be multilingual. Just select the row 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 constants 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()
method of TsiLang component. This method
returns the string value according input string ID in
respect with active language of interface. So in our case
we will delete rows for IDS_0, IDS_2 and IDS_3 and click
- After this all selected
string constants will be placed in "Strings"
property of TsiLang component placed on
form and in your source lines they will be replaced by
respective call of GetText() 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,
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-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
procedure TMainForm.German1Click(Sender: TObject);
TMenuItem(Sender).Checked := True;
- 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.