We help IT Professionals succeed at work.

Flexible way to make a program multiligual?

JDN asked
Hi experts,

I need to develop a multilingual program. Depending on the user who logs on to the program, all labels, qrlabels, showmessage texts, menu captions, and whatever should be presented in the language of the user.
For instance: for an English user, the label TForm1.label5 shows "enter the quantity", for a German user the same label shows "geben Sie die Quantitat ein" and for a French user that label shows "entrez la quantite".
I'm thinking of a conversion routine; when the user user logs on, all text in the program is converted according to the language of this user.

I need a flexible way to define all captions or text in my program, with all the translations. I'm thinking of a text file where all this information is stored, that way it's very easy to add new texts and translations.
For the above example, the line in this text file will look like this:

TForm1.label5.caption , enter the quantity , geben Sie die Quantitat ein , entrez la quantite

Now, of course, my question is: how can I assign the string my program reads form the text file (like "enter the quantity") to the other string that's read: "TForm1.label5.caption"? In other words: I need to convert the string "TForm1.label5.caption" to the name my Delphi program is using, and then assign the value "enter the quantity" to it.
Or, if that's not possible, is there another flexible way to make my program multiligual?

Thanks for all information,
Watch Question

Software Developer

  Delphi comes with tool to make mulit langauge application, look in project menu > langauges
if you don't see that, that's mean this feature not include with ur delphi version ( I think it need enterprise or pro version)

if you dont' have that, look in torry site, there are some free component may help you

Best regards
Mohammed Nasman
The whole thing is not that easy. You may have to change the layout of the forms. This can only be done by hand.

I use a single file in the project to hold ALL string constants used in the project. Only '' allowed in any other  Pascal file of the project.
That reduces the translation to this file and the .dfm files. So you can create a second project using all the .pas files except the string file.
The .dfm files are only text files. It should be possible to write a simple parser to present the strings in a special translation editor.
I forgot. There is already a parser to read and write .dfm files. That is the TPersistent mechanism to read and write components.
It should be possible to write an alternative TForm property editor.


In my case there's no need to change the layout of the forms. Only the text in labels etc. has to be changed, depending on the language of the user who logs on.

And I don't need a way to generate the same program in different languages, using multiple projects and dfm-files.
I need only one executable (to be installed on our Citrix server), and when the user logs on in my program all text (label captions etc.) should be translated to the language of this user. So, multiple Delphi projects is not the solution here I think...


JDN, I'd suggest to use resourcestrings and to put the strings into a DLL, one for each language. You then only have to load the resourcestrings from the correct DLL, and you're basically done.

Just some more information on what I mean:

* Create a resource DLL (there's even a wizard for this) where you put all the strintgs into. I think you can use the comfy "resourcestring" constanmts approach, which avoids having to use type in "LoadStr()" everytype you use such a string.

* When your app want to change the language, use the "LoadNewResourceModule()" function to load the new DLL and "ReinitializeForms" to apply the new strings. Note that this process is dynamic and can be done while the application is running!

http://www.borland.com/techpubs/delphi/delphi5/dg/intapps.html also has some more information on the topic.


I found some interesting en very usefull tools on the Torry site.
The component TjanLanguage was exactly what I was looking for.

So, I'll be fair, the points are for mnasman.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.