Skip to content

Commit

Permalink
Fixes RefId's don't get populated for Paratext Projects #93 (#94)
Browse files Browse the repository at this point in the history
* Fixes RefId's don't get populated for Paratext Projects #93

If there is no target file, there are no target refs; in this case, use the source ref.

* Damien's fix to ref logic

(Note: minimally tested against serval main and verse refs are properly generated)
  • Loading branch information
Enkidu93 authored Sep 29, 2023
1 parent 3a9766a commit 6311ffb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,35 @@ async IAsyncEnumerable<Pretranslation> ProcessRowsAsync()
&& row.TargetSegment.Count == 0
)
{
IReadOnlyList<object> refs;
if (row.TargetRefs.Count == 0)
{
if (sourceCorpus is ScriptureTextCorpus sstc && targetCorpus is ScriptureTextCorpus tstc)
{
refs = row.SourceRefs
.Cast<VerseRef>()
.Select(srcRef =>
{
var trgRef = srcRef.Clone();
trgRef.ChangeVersification(tstc.Versification);
return (object)trgRef;
})
.ToList();
}
else
{
refs = row.SourceRefs;
}
}
else
{
refs = row.TargetRefs;
}
yield return new Pretranslation
{
CorpusId = corpus.Id,
TextId = row.TextId,
Refs = row.TargetRefs.Select(r => r.ToString()!).ToList(),
Refs = refs.Select(r => r.ToString()!).ToList(),
Translation = row.SourceText
};
}
Expand Down
1 change: 1 addition & 0 deletions src/Machine/src/SIL.Machine.AspNetCore/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@
global using SIL.Machine.Utils;
global using SIL.ObjectModel;
global using SIL.WritingSystems;
global using SIL.Scripture;

0 comments on commit 6311ffb

Please sign in to comment.