mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-03 02:00:16 +02:00
LazUtils: when updating translation item, always check for formatting arguments and update flags accordingly, because badformat flags are often removed e.g. by poEdit. This change should allow to avoid the need to do two regenerations of .po files in a row in some cases.
git-svn-id: trunk@56953 -
This commit is contained in:
parent
f113cfc740
commit
50260ae6a6
@ -1617,6 +1617,22 @@ begin
|
||||
end;
|
||||
|
||||
procedure TPOFile.UpdateItem(const Identifier: string; Original: string);
|
||||
|
||||
function VerifyItemFormatting(var Item: TPOFileItem): boolean;
|
||||
begin
|
||||
// this function verifies item formatting and sets its flags if the formatting is bad
|
||||
Result := true;
|
||||
if Item.Translation <> '' then
|
||||
begin
|
||||
Result := CompareFormatArgs(Item.Original,Item.Translation);
|
||||
if not Result then
|
||||
if pos(sFuzzyFlag, Item.Flags) = 0 then
|
||||
Item.ModifyFlag(sFuzzyFlag, true);
|
||||
Item.ModifyFlag(sBadFormatFlag, not Result);
|
||||
FModified := true;
|
||||
end;
|
||||
end;
|
||||
|
||||
var
|
||||
Item: TPOFileItem;
|
||||
AContext,AComment,ATranslation,AFlags,APrevStr: string;
|
||||
@ -1637,11 +1653,11 @@ begin
|
||||
if (Item.PreviousID = '') or (pos(sFuzzyFlag, Item.Flags) = 0) then
|
||||
Item.PreviousID:=Item.Original;
|
||||
Item.ModifyFlag(sFuzzyFlag, true);
|
||||
Item.ModifyFlag(sBadFormatFlag, not CompareFormatArgs(Original,Item.Translation));
|
||||
end;
|
||||
end;
|
||||
Item.Original:=Original;
|
||||
Item.Tag:=FTag;
|
||||
VerifyItemFormatting(Item);
|
||||
exit;
|
||||
end;
|
||||
|
||||
@ -1664,6 +1680,9 @@ begin
|
||||
// if old item is fuzzy, copy PreviousID too
|
||||
if pos(sFuzzyFlag, Item.Flags)<>0 then
|
||||
APrevStr := Item.PreviousID;
|
||||
// check if old item's formatting arguments are correct and
|
||||
// set old item's fuzzy and badformat flags if not
|
||||
VerifyItemFormatting(Item);
|
||||
// set a flag to mark item fuzzy if it is not already
|
||||
SetFuzzy := true;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user