Welcome, Guest
Username: Password: Remember me
CodeTyphon MS Windows (Win7, Win8.x, Win10 and Win11) OS Development, discussions and problems
  • Page:
  • 1

TOPIC:

Multilanguage project 9 years 1 month ago #8282

  • zbyna
  • zbyna's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 33
  • Thank you received: 2
HI all,

have you any experience with multi language project ? I am trying step by step way according lazarus wiki but not able to change language even if with command line switch. I am using LCLTranslator unit and its setDefaultLang().

Are they any extra step needed for creating multilanguage projects in CodeTyphon(5.5) comparing to Lazarus (1.4x) ?

Thanks for any clarification.

Please Log in or Create an account to join the conversation.

Last edit: by zbyna.

Multilanguage project 9 years 1 month ago #8283

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
Sir the programming steps are the same,
it's simple resourcestring work.

--did you make/write the language *.po files ?
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Multilanguage project 9 years 1 month ago #8286

  • zbyna
  • zbyna's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 33
  • Thank you received: 2
Yes, po file was created automatically and then I created another with translated string. Everything according lazarus wiki I mentioned in my last post. I have used even the same project - example of imageviewer. Po files are corectly updated when some resource string is added. It is possible to add lcltranslator unit but nothing from inside this unit works but I am able to compile without errors.

Please Log in or Create an account to join the conversation.

Multilanguage project 9 years 1 month ago #8288

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
Try to use
DefaultTranslator.pas not LCLTranslator.pas direct
all Multilanguage stuff must finish before TApplication start to load project Forms
unit DefaultTranslator;

{$mode objfpc}{$H+}

interface

uses
  LCLTranslator;

implementation

initialization
  //It is safe to place code here as no form is initialized before unit
  //initialization is made
  SetDefaultLang('', '', false);

end.
PilotLogic Architect and Core Programmer
The following user(s) said Thank You: zbyna

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.

Multilanguage project 9 years 1 month ago #8292

  • zbyna
  • zbyna's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 33
  • Thank you received: 2
Thanks for reply. But DefaultTranslator does not work too. It is strange, at least for me, that I am not able to trace (debug) the call to DefaultTranslator of LCLTranslator unit to find out what is the problem. I am on win7 64bit.
unit Unit1;

{$mode objfpc}{$H+}
interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  lcltranslator, ExtCtrls;

type
  { TForm1 }
  TForm1 = class(TForm)
    Label1: TLabel;
    RadioGroup1: TRadioGroup;
    procedure FormSHow(Sender: TObject);
    procedure RadioGroup1SelectionChanged(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

resourcestring
  rsZkouKaPEklad = 'Attempt for translating: a small yellow horse';
  rsWhereIsAProb = 'Where is a problem ?';

implementation
{$R *.lfm}
{ TForm1 }

procedure TForm1.FormShow(Sender: TObject);
begin
  Label1.Caption:= rsZkouKaPEklad;
end;

procedure TForm1.RadioGroup1SelectionChanged(Sender: TObject);
type
   TJazyky = (english,czech);
var
  jazyky:array[TJazyky] of String[2]=('en','cs');
begin
   SetDefaultLang(jazyky[TJazyky(RadioGroup1.ItemIndex)]);
end;
end.
program project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Interfaces, // this includes the LCL widgetset
  Forms, Unit1
  { you can add units after this };

{$R *.res}

begin
  RequireDerivedFormResource := True;
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

Please Log in or Create an account to join the conversation.

Last edit: by zbyna.

Multilanguage project 9 years 1 month ago #8313

  • zbyna
  • zbyna's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 33
  • Thank you received: 2
Seems like this is the solution: Example from svn
In my opinion this is the worst thing when using free pascal, mostly no information or several sources claiming different things.
Sometimes I feel like true detective :laugh:

Please Log in or Create an account to join the conversation.

Last edit: by zbyna.

Multilanguage project 9 years 1 month ago #8314

  • zbyna
  • zbyna's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 33
  • Thank you received: 2
The same project is part of CodeTyphon in:
..\codetyphon\CodeOcean\aa_LCLBasics\samples\translation\

But for runtime language switching is needed to delete the default value (..\xbin) in Project Options/Compiler Options/Paths/Unit Output Directory.

Provided that the project successfully finds *.po files (which shloud be at the same directory as exe) and everything works great :woohoo:

Please Log in or Create an account to join the conversation.

Multilanguage project 9 years 1 month ago #8315

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
Thanks Sir
OR
set Po output Directory
..\translation\languages




CodeOcean has 1300 sample projects (CT 5.5)
CodeTyphon is the larger Programming Studio on this Planet...
have fun...
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.
  • Page:
  • 1