[Lazarus] Translations / Localizations for controls at design time

Jürgen Hestermann juergen.hestermann at gmx.de
Tue Jul 31 17:56:23 CEST 2012


Am 2012-07-31 13:28, schrieb Krzysztof:
> . Exists any way to assign translate const to the caption in design
> time or must I assign translated consts to all controls manually (on
> form create)?
I have not done very much localization but I am always wondering how all these nifty things added for this purpose realy help much.
I have done it in the following way:

1.) At each code place where text is going to be displayed I added a case statement that selects a language:
------------------------------------------------------------------------
case Language of
    German:  s := 'Dieser Text ist in deutsch';
    Dutch:      s := '...';
    .....
else             s := 'This text is in english';
    end; // of case
------------------------------------------------------------------------

2.) I have one routine that sets all captions according to the current language:

------------------------------------------------------------------------
begin
case Language of
    German:
       begin
       Button1.Caption  := 'Deutscher Text 1';
       Button2.Caption  := 'Deutscher Text 2';
       ....
       end;
    Dutch:
       begin
       Button1.Caption  := 'Deutscher Text 1';
       Button2.Caption  := 'Deutscher Text 2';
       ....
       end;
    ....
else
       begin
       Button1.Caption  := 'Deutscher Text 1';
       Button2.Caption  := 'Deutscher Text 2';
       ....
       end;
    end; // of case
------------------------------------------------------------------------

IMO This WOW has some advantages:

1.) A person that translate the text not only sees a naked text from another language but also a bit of the (code) context it is displayed in. Sometimes translations are very crude because someone simply translates the text one by one like a google translator without knowing what it means and the outcome is often misleading.

2.) When you change something within the text it reminds you to change it for the other language(s) too.

3.) It is very easy to let the user switch the language at runtime.

4.) You don't have to bother with these more or less helpful localization constructs that were added to "help" you with localizations


Of course, there are also some (IMO small) drawbacks:

1.) You need access to the code to translate the text

2.) It becomes tricky if you realy want to use an automatic translator






More information about the Lazarus mailing list