Hi all !
The translation of lclstrconsts is seams to bee Ok, (the MessaheDlg buttons is translated) but rest of my allication Lazfont is not translated.
Po files (lazfont.hu.po, lazfont.rs.po, lclstrconsts.hu.po, lclstrconsts.rs.po) is in lazfont.lrs.
Below is the code, witch is separate unit, placed in uses section of main form, also main form has:
Initialization
{$I lazfont.lrs}
TranslateLCL('hu');
TranslateApp('hu');
Pleas could somebody help mi, why is my application not translated ?
(the main language is Serbian I'd like to translate to Hungarian and back to Serbian on run time)
I'm read and study all wiki pages and examples related with, but still confused, unclear how it's (should) work ...
My environment is : Lazarus 1.1 svn, FPC 2.6.3 svn, XUbuntu 12.04 LTS 32bit
unit Translation;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Translations, LCLProc, LResources, Dialogs;
procedure TranslateLCL(lan: string);
procedure TranslateApp(lan: string);
implementation
resourcestring
rsGreKaPrevodaPrograma = 'Greška prevoda programa na drugi jezik !';
procedure TranslateLCL(lan: string);
var
res : TLResource;
pof : TPOFile;
str : TStringStream;
begin
res := LazarusResources.Find('lclstrconsts.'+lan,'PO');
if res <> nil then begin
str := nil;
pof := nil;
try
str := TStringStream.Create(res.Value);
pof := TPoFile.Create(str, False);
try
if not TranslateUnitResourceStrings('lclstrconsts', pof) then
MessageDlg(rsGreKaPrevodaPrograma, mtError, [mbOk], 0);
except
MessageDlg(rsGreKaPrevodaPrograma, mtError, [mbOk], 0);
end;
finally
if Assigned(str) then
str.Free;
if Assigned(pof) then
pof.Free;
end;
end;
end;
procedure TranslateApp(lan: string);
var
res : TLResource;
pof : TPOFile;
str : TStringStream;
begin
res := LazarusResources.Find('Lazfont.'+lan,'PO');
if res <> nil then begin
str := nil;
pof := nil;
try
str := TStringStream.Create(res.Value);
pof := TPoFile.Create(str, False);
try
if not TranslateUnitResourceStrings('Lfont', pof) then
MessageDlg(rsGreKaPrevodaPrograma, mtError, [mbOk], 0);
except
MessageDlg(rsGreKaPrevodaPrograma, mtError, [mbOk], 0);
end;
finally
if Assigned(str) then
str.Free;
if Assigned(pof) then
pof.Free;
end;
end;
end;
end.