mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-26 11:27:20 +01:00
LazUtils, Translations unit: simplify TPOFile.UpdateStrings method, there is no more particular need in early detection of multilined strings. No functional changes.
git-svn-id: trunk@60574 -
This commit is contained in:
parent
8b7e2c1e47
commit
1a22de281f
@ -1213,7 +1213,6 @@ var
|
|||||||
p: LongInt;
|
p: LongInt;
|
||||||
Identifier, Value, Line: string;
|
Identifier, Value, Line: string;
|
||||||
Ch: Char;
|
Ch: Char;
|
||||||
MultiLinedValue: boolean;
|
|
||||||
|
|
||||||
procedure NextLine;
|
procedure NextLine;
|
||||||
begin
|
begin
|
||||||
@ -1229,7 +1228,6 @@ var
|
|||||||
|
|
||||||
procedure NormalizeValue;
|
procedure NormalizeValue;
|
||||||
begin
|
begin
|
||||||
if MultiLinedValue then begin
|
|
||||||
//treat #10#13 sequences as #13#10 for consistency,
|
//treat #10#13 sequences as #13#10 for consistency,
|
||||||
//e.g. #10#13#13#13#10#13#10 should become #13#10#13#13#10#13#10
|
//e.g. #10#13#13#13#10#13#10 should become #13#10#13#13#10#13#10
|
||||||
p:=2;
|
p:=2;
|
||||||
@ -1244,7 +1242,7 @@ var
|
|||||||
inc(p);
|
inc(p);
|
||||||
end;
|
end;
|
||||||
Value := AdjustLineBreaks(Value);
|
Value := AdjustLineBreaks(Value);
|
||||||
end;
|
|
||||||
// escape special characters as #number, do not confuse translators
|
// escape special characters as #number, do not confuse translators
|
||||||
p:=1;
|
p:=1;
|
||||||
while p<=length(Value) do begin
|
while p<=length(Value) do begin
|
||||||
@ -1271,7 +1269,6 @@ var
|
|||||||
JsonItems := JsonData.Arrays['strings'];
|
JsonItems := JsonData.Arrays['strings'];
|
||||||
for K := 0 to JsonItems.Count - 1 do
|
for K := 0 to JsonItems.Count - 1 do
|
||||||
begin
|
begin
|
||||||
MultiLinedValue := false;
|
|
||||||
JsonItem := JsonItems.Items[K] as TJSONObject;
|
JsonItem := JsonItems.Items[K] as TJSONObject;
|
||||||
Data:=JsonItem.Find('sourcebytes');
|
Data:=JsonItem.Find('sourcebytes');
|
||||||
if Data is TJSONArray then begin
|
if Data is TJSONArray then begin
|
||||||
@ -1279,21 +1276,10 @@ var
|
|||||||
// while 'value' contains the string encoded as UTF16 with \u hexcodes.
|
// while 'value' contains the string encoded as UTF16 with \u hexcodes.
|
||||||
SourceBytes := TJSONArray(Data);
|
SourceBytes := TJSONArray(Data);
|
||||||
SetLength(Value,SourceBytes.Count);
|
SetLength(Value,SourceBytes.Count);
|
||||||
for L := 1 to length(Value) do begin
|
for L := 1 to length(Value) do
|
||||||
Value[L] := chr(SourceBytes.Integers[L-1]);
|
Value[L] := chr(SourceBytes.Integers[L-1]);
|
||||||
if Value[L] in [#13,#10] then
|
end else
|
||||||
MultilinedValue := True;
|
|
||||||
end;
|
|
||||||
end else begin
|
|
||||||
Value:=JsonItem.Get('value');
|
Value:=JsonItem.Get('value');
|
||||||
// check if the value we got is multilined
|
|
||||||
L := 1;
|
|
||||||
while (L<=Length(Value)) and (MultiLinedValue = false) do begin
|
|
||||||
if Value[L] in [#13,#10] then
|
|
||||||
MultilinedValue := True;
|
|
||||||
inc(L);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
if Value<>'' then begin
|
if Value<>'' then begin
|
||||||
NormalizeValue;
|
NormalizeValue;
|
||||||
UpdateItem(JsonItem.Get('name'), Value);
|
UpdateItem(JsonItem.Get('name'), Value);
|
||||||
@ -1315,7 +1301,6 @@ begin
|
|||||||
begin
|
begin
|
||||||
// for each string in lrt/rst/rsj list check if it's already in PO
|
// for each string in lrt/rst/rsj list check if it's already in PO
|
||||||
// if not add it
|
// if not add it
|
||||||
MultilinedValue := false;
|
|
||||||
Value := '';
|
Value := '';
|
||||||
Identifier := '';
|
Identifier := '';
|
||||||
i := 0;
|
i := 0;
|
||||||
@ -1333,7 +1318,6 @@ begin
|
|||||||
|
|
||||||
Value := '';
|
Value := '';
|
||||||
Identifier := '';
|
Identifier := '';
|
||||||
MultilinedValue := false;
|
|
||||||
|
|
||||||
end else begin
|
end else begin
|
||||||
|
|
||||||
@ -1365,8 +1349,6 @@ begin
|
|||||||
|
|
||||||
Ch := Chr(StrToInt(copy(Line, j, p-j)));
|
Ch := Chr(StrToInt(copy(Line, j, p-j)));
|
||||||
Value := Value + Ch;
|
Value := Value + Ch;
|
||||||
if Ch in [#13,#10] then
|
|
||||||
MultilinedValue := True;
|
|
||||||
|
|
||||||
if (p=n) and (Line[p]='+') then
|
if (p=n) and (Line[p]='+') then
|
||||||
NextLine;
|
NextLine;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user