Add command to keep translation

feature/pre-code-move
kaetemi 5 years ago committed by Jan Boon
parent 2c1be97a50
commit 6961c10556

@ -111,7 +111,8 @@ enum TDiffCommand
diff_add, diff_add,
diff_changed, diff_changed,
diff_removed, diff_removed,
diff_swap diff_swap,
diff_keep
}; };
struct TDiffInfo struct TDiffInfo
@ -246,6 +247,8 @@ bool parseDiffCommandFromComment(const ucstring &comments, TDiffInfo &diffInfo)
diffInfo.Command = diff_changed; diffInfo.Command = diff_changed;
else if (commandStr == "REMOVED") else if (commandStr == "REMOVED")
diffInfo.Command = diff_removed; diffInfo.Command = diff_removed;
else if (commandStr == "KEEP")
diffInfo.Command = diff_keep;
else else
{ {
nlwarning("Invalid diff command '%s'", commandStr.c_str()); nlwarning("Invalid diff command '%s'", commandStr.c_str());
@ -402,6 +405,10 @@ bool mergeStringDiff(vector<TStringInfo> &strings, const string &language, const
nlassert(diffInfo.Index1 < strings.size()); nlassert(diffInfo.Index1 < strings.size());
strings.erase(strings.begin()+diffInfo.Index1); strings.erase(strings.begin()+diffInfo.Index1);
break; break;
case diff_keep:
nlassert(diffInfo.Index1 < strings.size());
strings[diffInfo.Index1].HashValue = diff[j].HashValue;
break;
default: default:
nlassert(false); nlassert(false);
} }
@ -904,6 +911,11 @@ bool mergePhraseDiff(vector<TPhrase> &phrases, const string &language, bool only
("In REMOVED, Index1 (%u) is not less than number of phrase (%u)", diffInfo.Index1, phrases.size())); ("In REMOVED, Index1 (%u) is not less than number of phrase (%u)", diffInfo.Index1, phrases.size()));
phrases.erase(phrases.begin()+diffInfo.Index1); phrases.erase(phrases.begin()+diffInfo.Index1);
break; break;
case diff_keep:
nlassertex(diffInfo.Index1 < phrases.size(),
("In KEEP, Index1 (%u) is not less than number of phrase (%u)", diffInfo.Index1, phrases.size()));
phrases[diffInfo.Index1].HashValue = diff[j].HashValue;
break;
default: default:
nlassert(false); nlassert(false);
} }
@ -1443,6 +1455,14 @@ bool mergeWorksheetDiff(const std::string filename, TWorksheet &sheet, bool only
// nlassertex(diffInfo.Index2 > 0); // nlassertex(diffInfo.Index2 > 0);
swap(sheet[diffInfo.Index1], sheet[diffInfo.Index2]); swap(sheet[diffInfo.Index1], sheet[diffInfo.Index2]);
break; break;
case diff_keep:
{
nlassertex(diffInfo.Index1 <= sheet.Data.size(),
("KEEP cmd in diff file reference row %u, but worksheet only contains %u entries",
diffInfo.Index1, sheet.Data.size()));
nlerror("diff_keep not implemented"); // TODO
}
break;
default: default:
nlassert(false); nlassert(false);
} }
@ -2059,13 +2079,17 @@ void mergePhraseDiff2Impl(vector<TPhrase>& reference, const vector<TPhrase>& add
{ {
nlassert( phrases.find(first->Identifier) == phrases.end() ); nlassert( phrases.find(first->Identifier) == phrases.end() );
phrases[first->Identifier] = *first; phrases[first->Identifier] = *first;
} }
else if ( first->Comments.find(ucstring("DIFF REMOVED")) != ucstring::npos) else if ( first->Comments.find(ucstring("DIFF REMOVED")) != ucstring::npos)
{ {
nlassert( phrases.find(first->Identifier) != phrases.end() ); nlassert( phrases.find(first->Identifier) != phrases.end() );
phrases.erase( phrases.find(first->Identifier)); phrases.erase( phrases.find(first->Identifier));
} }
else if ( first->Comments.find(ucstring("DIFF KEEP")) != ucstring::npos)
{
nlassert( phrases.find(first->Identifier) != phrases.end() );
phrases[first->Identifier].HashValue = first->HashValue;
}
else else
{ {
// nlassert(0 && "INVALID DIFF COMMAND"); // nlassert(0 && "INVALID DIFF COMMAND");

Loading…
Cancel
Save