blob: c1441199d95e42e5aa0f23f75c5e2fbcc688b5c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
unit PoTranslator;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, typinfo, Translations;
type
{ TPoTranslator }
TPoTranslator=class(TAbstractTranslator)
private
FPOFile:TPOFile;
public
constructor Create(POFileName:string);
destructor Destroy;override;
procedure TranslateStringProperty(Sender:TObject;
const Instance: TPersistent; PropInfo: PPropInfo; var Content:string);override;
end;
implementation
{ TPoTranslator }
constructor TPoTranslator.Create(POFileName: string);
begin
inherited Create;
FPOFile:=TPOFile.Create(POFileName);
end;
destructor TPoTranslator.Destroy;
begin
FPOFile.Free;
inherited Destroy;
end;
procedure TPoTranslator.TranslateStringProperty(Sender: TObject;
const Instance: TPersistent; PropInfo: PPropInfo; var Content: string);
var
s: String;
begin
if not Assigned(FPOFile) then exit;
if not Assigned(PropInfo) then exit;
{DO we really need this?}
if Instance is TComponent then
if csDesigning in (Instance as TComponent).ComponentState then exit;
{End DO :)}
if (AnsiUpperCase(PropInfo^.PropType^.Name)<>'TTRANSLATESTRING') then exit;
s:=FPOFile.Translate(Content, Content);
if s<>'' then Content:=s;
end;
end.
|