Recent

Author Topic: Trouble with po files  (Read 2838 times)

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Trouble with po files
« on: December 18, 2010, 01:43:41 pm »
I'm trying to learn how to use i18n and .po files to internationalise strings.
A simple test project as follows produces an external SIGSEGV error. Anyone see what I'm doing wrong?
(Win 7, Laz 0.9.29, FPC 2.4.3)

Code: [Select]
unit Unit1;

{$mode objfpc}{$H+}

interface

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

type

  { TForm1 }

  TForm1 = class(TForm)
    btn1: TButton;
    btn2: TButton;
    procedure FormActivate(Sender: TObject);
    procedure FormCreate(Sender: TObject);
 end;

var
  Form1: TForm1;

resourcestring
  btn1caption = 'One';
  btn2caption = 'Two';

implementation

uses DefaultTranslator,
     LResources,
     Translations;

const poDirectory = 'C:\LazProjects\Dec10\i18nTest\language';

{$R *.lfm}

{ TForm1 }

procedure TForm1.FormActivate(Sender: TObject);
begin
  btn1.Caption:= btn1Caption;
  btn2.Caption:= btn2Caption;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  TranslateUnitResourceStrings('unit1', poDirectory + '\fr\project1.fr.po', 'fr', '');
end;

initialization
  LRSTranslator := TPoTranslator.Create(poDirectory);
end.

Thanks,
Howard

 

TinyPortal © 2005-2018