mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-06 03:33:00 +02:00
+ rstconv: add support for -c XXX parameter to add header containing the CharSet to a .po-file
git-svn-id: trunk@9541 -
This commit is contained in:
parent
e5f8426f61
commit
d28f943b0e
@ -31,6 +31,8 @@ resourcestring
|
|||||||
' po GNU gettext .po (portable) format (DEFAULT)'+LineEnding+
|
' po GNU gettext .po (portable) format (DEFAULT)'+LineEnding+
|
||||||
' msg IBM OS/2 MSG file format'+LineEnding+
|
' msg IBM OS/2 MSG file format'+LineEnding+
|
||||||
' rc Resource compiler .rc format'+LineEnding+LineEnding+
|
' rc Resource compiler .rc format'+LineEnding+LineEnding+
|
||||||
|
'.po format only options are:'+LineEnding+
|
||||||
|
' -c char set Adds a header specifying the given character set (OPTIONAL).'+LineEnding+LineEnding+
|
||||||
'OS/2 MSG file only options are:'+LineEnding+
|
'OS/2 MSG file only options are:'+LineEnding+
|
||||||
' -c identifier Specifies the component identifier (REQUIRED).'+LineEnding+
|
' -c identifier Specifies the component identifier (REQUIRED).'+LineEnding+
|
||||||
' Identifier is any three chars in upper case.'+LineEnding+
|
' Identifier is any three chars in upper case.'+LineEnding+
|
||||||
@ -60,6 +62,7 @@ type
|
|||||||
var
|
var
|
||||||
InFilename, OutFilename: String;
|
InFilename, OutFilename: String;
|
||||||
ConstItems: TCollection;
|
ConstItems: TCollection;
|
||||||
|
CharSet: String;
|
||||||
Identifier: String;
|
Identifier: String;
|
||||||
FirstMessage: Word;
|
FirstMessage: Word;
|
||||||
MessageTable: Boolean;
|
MessageTable: Boolean;
|
||||||
@ -126,6 +129,16 @@ var
|
|||||||
begin
|
begin
|
||||||
Assign(f, OutFilename);
|
Assign(f, OutFilename);
|
||||||
Rewrite(f);
|
Rewrite(f);
|
||||||
|
|
||||||
|
if CharSet<>'' then begin
|
||||||
|
// Write file header with
|
||||||
|
WriteLn(f, 'msgid ""');
|
||||||
|
WriteLn(f, 'msgstr ""');
|
||||||
|
WriteLn(f, '"MIME-Version: 1.0\n"');
|
||||||
|
WriteLn(f, '"Content-Type: text/plain; charset=', CharSet, '\n"');
|
||||||
|
WriteLn(f, '"Content-Transfer-Encoding: 8bit\n"');
|
||||||
|
WriteLn(f);
|
||||||
|
end;
|
||||||
|
|
||||||
for i := 0 to ConstItems.Count - 1 do begin
|
for i := 0 to ConstItems.Count - 1 do begin
|
||||||
item := TConstItem(ConstItems.items[i]);
|
item := TConstItem(ConstItems.items[i]);
|
||||||
@ -291,6 +304,7 @@ begin
|
|||||||
|
|
||||||
ConversionProc := @ConvertToGettextPO;
|
ConversionProc := @ConvertToGettextPO;
|
||||||
OutputFormat:='';
|
OutputFormat:='';
|
||||||
|
CharSet:='';
|
||||||
Identifier:='';
|
Identifier:='';
|
||||||
FirstMessage:=0;
|
FirstMessage:=0;
|
||||||
MessageTable:=True;
|
MessageTable:=True;
|
||||||
@ -330,11 +344,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
Inc(i, 2);
|
Inc(i, 2);
|
||||||
end else if ParamStr(i) = '-c' then begin
|
end else if ParamStr(i) = '-c' then begin
|
||||||
if Identifier <> '' then begin
|
if (OutputFormat='') or (OutputFormat='po') then begin
|
||||||
WriteLn(StdErr, OptionAlreadySpecified, '-c');
|
if CharSet <> '' then begin
|
||||||
Halt(1);
|
WriteLn(StdErr, OptionAlreadySpecified, '-c');
|
||||||
|
Halt(1);
|
||||||
|
end;
|
||||||
|
CharSet:=ParamStr(i+1);
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
if Identifier <> '' then begin
|
||||||
|
WriteLn(StdErr, OptionAlreadySpecified, '-c');
|
||||||
|
Halt(1);
|
||||||
|
end;
|
||||||
|
Identifier:=ParamStr(i+1);
|
||||||
end;
|
end;
|
||||||
Identifier:=ParamStr(i+1);
|
|
||||||
Inc(i, 2);
|
Inc(i, 2);
|
||||||
end else if ParamStr(i) = '-s' then begin
|
end else if ParamStr(i) = '-s' then begin
|
||||||
if not MessageTable then begin
|
if not MessageTable then begin
|
||||||
@ -365,6 +388,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
If ((OutputFormat<>'') and (OutputFormat<>'po')) and (CharSet<>'') then begin
|
||||||
|
WriteLn(StdErr, InvalidOption, '');
|
||||||
|
Halt(1);
|
||||||
|
end;
|
||||||
|
|
||||||
If ((OutputFormat<>'msg') and (OutputFormat<>'rc')) and ((Identifier<>'') or (FirstMessage<>0)) then begin
|
If ((OutputFormat<>'msg') and (OutputFormat<>'rc')) and ((Identifier<>'') or (FirstMessage<>0)) then begin
|
||||||
WriteLn(StdErr, InvalidOption, '');
|
WriteLn(StdErr, InvalidOption, '');
|
||||||
Halt(1);
|
Halt(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user