mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-11-04 05:23:12 +01:00 
			
		
		
		
	LCL: TPOFile: fixed continuation lines
git-svn-id: trunk@35387 -
This commit is contained in:
		
							parent
							
								
									b75cbdf949
								
							
						
					
					
						commit
						5803ddeab4
					
				@ -580,6 +580,12 @@ msgid "                      Do not show splash screen"
 | 
				
			|||||||
msgstr ""
 | 
					msgstr ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					type
 | 
				
			||||||
 | 
					  TMsg = (
 | 
				
			||||||
 | 
					    mid,
 | 
				
			||||||
 | 
					    mstr,
 | 
				
			||||||
 | 
					    mctx
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
var
 | 
					var
 | 
				
			||||||
  l: Integer;
 | 
					  l: Integer;
 | 
				
			||||||
  LineLen: Integer;
 | 
					  LineLen: Integer;
 | 
				
			||||||
@ -587,10 +593,8 @@ var
 | 
				
			|||||||
  LineStart: PChar;
 | 
					  LineStart: PChar;
 | 
				
			||||||
  LineEnd: PChar;
 | 
					  LineEnd: PChar;
 | 
				
			||||||
  Identifier: String;
 | 
					  Identifier: String;
 | 
				
			||||||
  MsgID,MsgStr,PrevMsgID: String;
 | 
					  PrevMsgID: String;
 | 
				
			||||||
  Line: String;
 | 
					 | 
				
			||||||
  Comments: String;
 | 
					  Comments: String;
 | 
				
			||||||
  Context: string;
 | 
					 | 
				
			||||||
  Flags: string;
 | 
					  Flags: string;
 | 
				
			||||||
  TextEnd: PChar;
 | 
					  TextEnd: PChar;
 | 
				
			||||||
  i: Integer;
 | 
					  i: Integer;
 | 
				
			||||||
@ -598,15 +602,17 @@ var
 | 
				
			|||||||
  NewSrc: String;
 | 
					  NewSrc: String;
 | 
				
			||||||
  s: String;
 | 
					  s: String;
 | 
				
			||||||
  Handled: Boolean;
 | 
					  Handled: Boolean;
 | 
				
			||||||
 | 
					  CurMsg: TMsg;
 | 
				
			||||||
 | 
					  Msg: array[TMsg] of string;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  procedure ResetVars;
 | 
					  procedure ResetVars;
 | 
				
			||||||
  begin
 | 
					  begin
 | 
				
			||||||
    MsgId := '';
 | 
					    CurMsg:=mid;
 | 
				
			||||||
    MsgStr := '';
 | 
					    Msg[mid]:='';
 | 
				
			||||||
    Line := '';
 | 
					    Msg[mstr]:='';
 | 
				
			||||||
 | 
					    Msg[mctx]:='';
 | 
				
			||||||
    Identifier := '';
 | 
					    Identifier := '';
 | 
				
			||||||
    Comments := '';
 | 
					    Comments := '';
 | 
				
			||||||
    Context := '';
 | 
					 | 
				
			||||||
    Flags := '';
 | 
					    Flags := '';
 | 
				
			||||||
    PrevMsgID := '';
 | 
					    PrevMsgID := '';
 | 
				
			||||||
  end;
 | 
					  end;
 | 
				
			||||||
@ -617,24 +623,24 @@ var
 | 
				
			|||||||
  begin
 | 
					  begin
 | 
				
			||||||
    if Identifier<>'' then begin
 | 
					    if Identifier<>'' then begin
 | 
				
			||||||
      // check for unresolved duplicates in po file
 | 
					      // check for unresolved duplicates in po file
 | 
				
			||||||
      Item := TPOFileItem(FOriginalToItem.Data[MsgID]);
 | 
					      Item := TPOFileItem(FOriginalToItem.Data[Msg[mid]]);
 | 
				
			||||||
      if (Item<>nil) then begin
 | 
					      if (Item<>nil) then begin
 | 
				
			||||||
        // fix old duplicate context
 | 
					        // fix old duplicate context
 | 
				
			||||||
        if Item.Context='' then
 | 
					        if Item.Context='' then
 | 
				
			||||||
          Item.Context:=Item.IdentifierLow;
 | 
					          Item.Context:=Item.IdentifierLow;
 | 
				
			||||||
        // set context of new duplicate
 | 
					        // set context of new duplicate
 | 
				
			||||||
        if Context='' then
 | 
					        if Msg[mctx]='' then
 | 
				
			||||||
          Context := Identifier;
 | 
					          Msg[mctx] := Identifier;
 | 
				
			||||||
        // if old duplicate was translated and
 | 
					        // if old duplicate was translated and
 | 
				
			||||||
        // new one is not, provide a initial translation
 | 
					        // new one is not, provide a initial translation
 | 
				
			||||||
        if MsgStr='' then
 | 
					        if Msg[mstr]='' then
 | 
				
			||||||
          MsgStr := Item.Translation;
 | 
					          Msg[mstr] := Item.Translation;
 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
      Add(Identifier,MsgID,MsgStr,Comments,Context,Flags,PrevMsgID);
 | 
					      Add(Identifier,Msg[mid],Msg[mstr],Comments,Msg[mctx],Flags,PrevMsgID);
 | 
				
			||||||
      ResetVars;
 | 
					      ResetVars;
 | 
				
			||||||
    end else
 | 
					    end else
 | 
				
			||||||
    if (Line<>'') and (FHeader=nil) then begin
 | 
					    if (Msg[CurMsg]<>'') and (FHeader=nil) then begin
 | 
				
			||||||
      FHeader := TPOFileItem.Create('',MsgID,Line);
 | 
					      FHeader := TPOFileItem.Create('',Msg[mid],Msg[CurMsg]);
 | 
				
			||||||
      FHeader.Comments:=Comments;
 | 
					      FHeader.Comments:=Comments;
 | 
				
			||||||
      ResetVars;
 | 
					      ResetVars;
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
@ -648,10 +654,7 @@ begin
 | 
				
			|||||||
  LineStart:=p;
 | 
					  LineStart:=p;
 | 
				
			||||||
  TextEnd:=p+l;
 | 
					  TextEnd:=p+l;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Identifier:='';
 | 
					  ResetVars;
 | 
				
			||||||
  Comments:='';
 | 
					 | 
				
			||||||
  Line:='';
 | 
					 | 
				
			||||||
  Flags:='';
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  while LineStart<TextEnd do begin
 | 
					  while LineStart<TextEnd do begin
 | 
				
			||||||
    LineEnd:=LineStart;
 | 
					    LineEnd:=LineStart;
 | 
				
			||||||
@ -680,7 +683,7 @@ begin
 | 
				
			|||||||
              PrevMsgID:=PrevMsgID+GetUTF8String(LineStart+length('#| msgid "'),LineEnd-1);
 | 
					              PrevMsgID:=PrevMsgID+GetUTF8String(LineStart+length('#| msgid "'),LineEnd-1);
 | 
				
			||||||
              Handled:=true;
 | 
					              Handled:=true;
 | 
				
			||||||
            end else if IsKey(LineStart, '#| "') then begin
 | 
					            end else if IsKey(LineStart, '#| "') then begin
 | 
				
			||||||
              Line := Line + GetUTF8String(LineStart+length('#| "'),LineEnd-1);
 | 
					              Msg[CurMsg] := Msg[CurMsg] + GetUTF8String(LineStart+length('#| "'),LineEnd-1);
 | 
				
			||||||
              Handled:=true;
 | 
					              Handled:=true;
 | 
				
			||||||
            end;
 | 
					            end;
 | 
				
			||||||
          ',':
 | 
					          ',':
 | 
				
			||||||
@ -703,24 +706,27 @@ begin
 | 
				
			|||||||
          case LineStart[3] of
 | 
					          case LineStart[3] of
 | 
				
			||||||
          'i':
 | 
					          'i':
 | 
				
			||||||
            if IsKey(LineStart,'msgid "') then begin
 | 
					            if IsKey(LineStart,'msgid "') then begin
 | 
				
			||||||
              MsgID:=MsgID+GetUTF8String(LineStart+length('msgid "'),LineEnd-1);
 | 
					              CurMsg:=mid;
 | 
				
			||||||
 | 
					              Msg[CurMsg]:=Msg[CurMsg]+GetUTF8String(LineStart+length('msgid "'),LineEnd-1);
 | 
				
			||||||
              Handled:=true;
 | 
					              Handled:=true;
 | 
				
			||||||
            end;
 | 
					            end;
 | 
				
			||||||
          's':
 | 
					          's':
 | 
				
			||||||
            if IsKey(LineStart,'msgstr "') then begin
 | 
					            if IsKey(LineStart,'msgstr "') then begin
 | 
				
			||||||
              MsgStr:=MsgStr+GetUTF8String(LineStart+length('msgstr "'),LineEnd-1);
 | 
					              CurMsg:=mstr;
 | 
				
			||||||
 | 
					              Msg[CurMsg]:=Msg[CurMsg]+GetUTF8String(LineStart+length('msgstr "'),LineEnd-1);
 | 
				
			||||||
              Handled:=true;
 | 
					              Handled:=true;
 | 
				
			||||||
            end;
 | 
					            end;
 | 
				
			||||||
          'c':
 | 
					          'c':
 | 
				
			||||||
            if IsKey(LineStart, 'msgctxt "') then begin
 | 
					            if IsKey(LineStart, 'msgctxt "') then begin
 | 
				
			||||||
              Context:=GetUTF8String(LineStart+length('msgctxt "'), LineEnd-1);
 | 
					              CurMsg:=mctx;
 | 
				
			||||||
 | 
					              Msg[CurMsg]:=Msg[CurMsg]+GetUTF8String(LineStart+length('msgctxt "'), LineEnd-1);
 | 
				
			||||||
              Handled:=true;
 | 
					              Handled:=true;
 | 
				
			||||||
            end;
 | 
					            end;
 | 
				
			||||||
          end;
 | 
					          end;
 | 
				
			||||||
        end;
 | 
					        end;
 | 
				
			||||||
      '"':
 | 
					      '"':
 | 
				
			||||||
        begin
 | 
					        begin
 | 
				
			||||||
          if (MsgID='')
 | 
					          if (Msg[mid]='')
 | 
				
			||||||
          and IsKey(LineStart,'"Content-Type: text/plain; charset=') then
 | 
					          and IsKey(LineStart,'"Content-Type: text/plain; charset=') then
 | 
				
			||||||
          begin
 | 
					          begin
 | 
				
			||||||
            FCharSet:=GetUTF8String(LineStart+length('"Content-Type: text/plain; charset='),LineEnd);
 | 
					            FCharSet:=GetUTF8String(LineStart+length('"Content-Type: text/plain; charset='),LineEnd);
 | 
				
			||||||
@ -740,7 +746,8 @@ begin
 | 
				
			|||||||
              LineLen:=LineEnd-LineStart;
 | 
					              LineLen:=LineEnd-LineStart;
 | 
				
			||||||
            end;
 | 
					            end;
 | 
				
			||||||
          end;
 | 
					          end;
 | 
				
			||||||
          Line := Line + GetUTF8String(LineStart+1,LineEnd-1);
 | 
					          // continuation
 | 
				
			||||||
 | 
					          Msg[CurMsg]:=Msg[CurMsg]+GetUTF8String(LineStart+1,LineEnd-1);
 | 
				
			||||||
          Handled:=true;
 | 
					          Handled:=true;
 | 
				
			||||||
        end;
 | 
					        end;
 | 
				
			||||||
      end;
 | 
					      end;
 | 
				
			||||||
@ -748,7 +755,7 @@ begin
 | 
				
			|||||||
        AddEntry;
 | 
					        AddEntry;
 | 
				
			||||||
    end;
 | 
					    end;
 | 
				
			||||||
    LineStart:=LineEnd+1;
 | 
					    LineStart:=LineEnd+1;
 | 
				
			||||||
    while (LineStart<TextEnd) and (LineStart^ in [#10,#13]) do inc(LineStart);
 | 
					    while (LineStart^ in [#10,#13]) do inc(LineStart);
 | 
				
			||||||
  end;
 | 
					  end;
 | 
				
			||||||
  AddEntry;
 | 
					  AddEntry;
 | 
				
			||||||
end;
 | 
					end;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user