Board index » delphi » A multi-language application in Delphi ?

A multi-language application in Delphi ?

Is there an easy way to create a multilanguage application in Delphi?
Everything needs to be translated: every menu, button, massage dialog, ...

Is it possible to work with different .RES files ?

Pieter Verstraelen
v...@innet.be

 

Re:A multi-language application in Delphi ?


Quote
"Pieter Verstraelen" <v...@innet.be> wrote:
>Is there an easy way to create a multilanguage application in Delphi?
>Everything needs to be translated: every menu, button, massage dialog, ...
>Is it possible to work with different .RES files ?

Possible, and not even very hard.

Use the Tag property to assign numbers to your controls. Then, on
the assumption that you have fewer than 1000 controls, assign a
number to each language you want to handle, e.g.:  0 for English,
1000 for Spanish, 2000 for French,....

For each form, you then iterate through all the controls and use
LoadStr to load the appropriate string. You need to check the
type of control of course:

  for j := 0 to frmMain.ComponentCount-1 do
        begin
        if frmMain.Components[j].Tag = 0 then CONTINUE;
        if frmMain.Components[j] is TSpeedButton then begin
                with frmMain.Components[j] as TSpeedButton do
                if Tag < 5000 then Caption := LoadStr(Tag+i)
                else Hint := LoadStr(Tag+i);
        end else if frmMain.Components[j] is TMenuItem then begin
                with frmMain.Components[j] as TMenuItem do Caption :=
LoadStr(Tag+i);
        end else if frmMain.Components[j] is TBitBtn then begin
                with frmMain.Components[j] as TBitBtn do Caption :=
LoadStr(Tag+i);
        end else if frmMain.Components[j] is TPanel then begin
                with frmMain.Components[j] as TPanel do Caption :=
LoadStr(Tag+i);
        end else if frmMain.Components[j] is TLabel then begin
                with frmMain.Components[j] as TLabel do Caption :=
LoadStr(Tag+i);
        end;
     end;

Here i is the language number.

Note that if you want to support double-byte languages, you may
have a problem compiling the RES file, since the literal
indicator \ appears in some DBCS strings. The solution is to do a
search-and-replace, adding another \ wherever one occurs.

good luck,

Ken

Re:A multi-language application in Delphi ?


Quote
Pieter Verstraelen wrote:

> Is there an easy way to create a multilanguage application in Delphi?
> Everything needs to be translated: every menu, button, massage dialog, ...

> Is it possible to work with different .RES files ?

> Pieter Verstraelen
> v...@innet.be

Borland produce a couple of products.  A of set translated versions of
the VCL, which can each be installed in different directories and by
suitable manipulation of dfm files can be used to produce conditional
compiles in different languages.  I think you get French, German,
Spanish, Italian and Japanese.  This is the 'cheap' way to do it and
costs ~$150.  (I have the software but havn't got to the multi-language
compile stage yet for the stuff I'm working on - hence the rather hazy
theory here :-)

The other approach is to go for Borland's full translation suite.  This
looks nice with table driven language compilation, but at $2500 it's not
cheap.

--
************************************************************
* Kevin Woolley *              Visual Explorer             *
*               * 3D Landscape Visualization and Modelling *
*               * Home Page: http://www.stir.ac.uk/~kjw1r/ *
*               * Email    : 100332.2...@compuserve.com    *
************************************************************
*            Don't let Dunblane happen again               *
*    Write to your MP calling for a ban on handguns now!   *
************************************************************

Re:A multi-language application in Delphi ?


In article <01bbb555$806411b0$0200a8c0@mpieter>,

Quote
Pieter Verstraelen <v...@innet.be> wrote:
>Is there an easy way to create a multilanguage application in Delphi?
>Everything needs to be translated: every menu, button, massage dialog, ...

>Is it possible to work with different .RES files ?

We've just purchased a multi-lingual component for Delphi that does all
that for you. You place a copy of TMultLang on each form in you app and
they collect all captions and hints from the form, putting them into an
easy to use property editor which lets you add languages to your app as
required. The package also comes with a set of replacements for common
dialogs, which are built to allow use with multiple languages.

The component (TMULTLANG) crops up on some of places like www.delphi32.com
but you can also download a trial from the authors, http://www.lingscape.com

The package costs considerably less the borland's multilanguage
package and does all we want it to.

Ps. I've no connection with Lingscape, except as a customer.

hope this helps

--
Dave Langstaff | d...@augusta.co.uk
Any views expressed are those of the author alone. | Phone:(01970)622838
After-life, After-shave, don't hold with any of it, bleugh!  - Sir Henry

Other Threads