1
+ { @author: Sylvain Maltais ([email protected] )
2
+ @created: 2024
3
+ @website(https://www.gladir.com/freebsd-0)
4
+ @abstract(Target: Turbo Pascal 7, Free Pascal 3.2)
5
+ }
6
+
7
+ Program GETTEXT;
8
+
9
+ Uses DOS;
10
+
11
+ Var
12
+ I:Integer;
13
+ TextDomainDir,FileName,MsgId,MsgStr:String;
14
+
15
+ Function FileExist (Name :String):Boolean;
16
+ Var
17
+ Rec:SearchRec;
18
+ Begin
19
+ FindFirst(Name ,AnyFile,Rec);
20
+ FileExist:=DosError=0 ;
21
+ End ;
22
+
23
+ Function FindText (FileName,MsgId:String;Var MsgStr:String):Boolean;
24
+ Var
25
+ POFile:Text;
26
+ CurrLine,CurrMsgId:String;
27
+ Begin
28
+ FindText:=False;
29
+ { $I-} Assign(POFile,FileName);
30
+ Reset(POFile);{ $I+}
31
+ If IOResult<>0 Then Begin
32
+ WriteLn(' Fichier PO introuvable : ' ,FileName);
33
+ Halt(1 );
34
+ End ;
35
+ CurrMsgId:=' ' ;
36
+ While Not EOF(POFile)do Begin
37
+ ReadLn(POFile,CurrLine);
38
+ If Copy(CurrLine,1 ,Length(' msgid ' ))=' msgid ' Then Begin
39
+ CurrMsgId:=Copy(CurrLine,Length(' msgid ' )+1 ,255 );
40
+ If (Copy(CurrMsgId,1 ,1 )=' "' )and (Copy(CurrMsgId,Length(CurrMsgId),1 )=' "' )Then Begin
41
+ CurrMsgId:=Copy(CurrMsgId,2 ,Length(CurrMsgId)-2 );
42
+ End ;
43
+ End
44
+ Else
45
+ If Copy(CurrLine,1 ,Length(' msgstr ' ))=' msgstr ' Then Begin
46
+ If (CurrMsgId=MsgId)Then Begin
47
+ MsgStr:=Copy(CurrLine,Length(' msgstr ' )+1 ,255 );
48
+ If (Copy(MsgStr,1 ,1 )=' "' )and (Copy(MsgStr,Length(MsgStr),1 )=' "' )Then Begin
49
+ MsgStr:=Copy(MsgStr,2 ,Length(MsgStr)-2 );
50
+ End ;
51
+ FindText:=True;
52
+ Exit;
53
+ End ;
54
+ End ;
55
+ End ;
56
+ Close(POFile);
57
+ End ;
58
+
59
+ BEGIN
60
+ If (ParamStr(1 )=' /?' )or (ParamStr(1 )=' --help' )or (ParamStr(1 )=' -h' )or
61
+ (ParamStr(1 )=' /h' )or (ParamStr(1 )=' /H' )Then Begin
62
+ WriteLn(' GETTEXT : Cette commande permet d'' afficher les ' ,
63
+ ' traductions de langages humains natif ' ,
64
+ ' dans un message textuel.' );
65
+ WriteLn;
66
+ WriteLn(' Syntaxe : GETTEXT [option] [[textdomain] msgid]' );
67
+ WriteLn;
68
+ WriteLn(' msgid Indique le MsgId' );
69
+ WriteLn(' -h Affiche l'' aide de cette commande' );
70
+ WriteLn(' -V Affiche la version de cette commande.' );
71
+ WriteLn(' --domain=textdomain Indique le nom du domain (g‚n‚ralement un fichier .PO)' );
72
+ WriteLn(' --help Affiche l'' aide de cette commande' );
73
+ WriteLn(' --version Affiche la version de cette commande.' );
74
+ End
75
+ Else
76
+ If (ParamStr(1 )=' --version' )or (ParamStr(1 )=' -V' )Then Begin
77
+ WriteLn(' GETTEXT 1.0 - Clone Pascal de freebsd, linux ou corail' );
78
+ WriteLn(' Licence MIT' );
79
+ WriteLn;
80
+ WriteLn(' crit par Sylvain Maltais' );
81
+ End
82
+ Else
83
+ Begin
84
+ FileName:=' ' ;
85
+ MsgId:=' ' ;
86
+ For I:=1 to ParamCount do Begin
87
+ If Copy(ParamStr(I),1 ,Length(' --domain=' ))=' --domain=' Then Begin
88
+ FileName:=Copy(ParamStr(I),Length(' --domain=' )+1 ,255 );
89
+ End
90
+ Else
91
+ If FileName=' ' Then FileName:=ParamStr(I)
92
+ Else MsgId:=ParamStr(I);
93
+ End ;
94
+ If Not FileExist(FileName)Then Begin
95
+ TextDomainDir:=GetEnv(' TEXTDOMAINDIR' );
96
+ If TextDomainDir<>' ' Then Begin
97
+ If TextDomainDir[Length(TextDomainDir)]<>' \' Then TextDomainDir:=TextDomainDir+' \' ;
98
+ FileName:=TextDomainDir+FileName;
99
+ End ;
100
+ End ;
101
+ If FindText(FileName,MsgId,MsgStr)Then Begin
102
+ WriteLn(MsgStr);
103
+ End
104
+ ELse
105
+ WriteLn(MsgId);
106
+ End ;
107
+ END .
0 commit comments