@@ -35,19 +35,35 @@ CancellationToken cancellationToken
3535        List < PreTranslation >  preTranslations  =  [ ] ; 
3636
3737        // Ensure we have the parameters to retrieve the pre-translation 
38-         ( string ?  translationEngineId ,  string  corpusId ,  bool  useParatextVerseRef )  = 
38+         ( string ?  translationEngineId ,  string ?  corpusId ,   string ?   parallelCorpusId ,  bool  useParatextVerseRef )  = 
3939            await  GetPreTranslationParametersAsync ( sfProjectId ) ; 
4040
4141        // Get the pre-translation data from Serval 
4242        string  textId  =  useParatextVerseRef  ?  GetTextId ( bookNum )  :  GetTextId ( bookNum ,  chapterNum ) ; 
43-         foreach  ( 
44-             Pretranslation  preTranslation  in  await  translationEnginesClient . GetAllPretranslationsAsync ( 
43+         IList < Pretranslation >  servalPreTranslations ; 
44+         if  ( parallelCorpusId  is  not null ) 
45+         { 
46+             servalPreTranslations  =  await  translationEnginesClient . GetAllPretranslationsAsync ( 
47+                 translationEngineId , 
48+                 parallelCorpusId , 
49+                 textId , 
50+                 cancellationToken 
51+             ) ; 
52+         } 
53+         else 
54+         { 
55+             // Retrieve the pre-translations from a legacy corpus 
56+ #pragma warning disable CS0612  // Type or member is obsolete 
57+             servalPreTranslations  =  await  translationEnginesClient . GetAllCorpusPretranslationsAsync ( 
4558                translationEngineId , 
4659                corpusId , 
4760                textId , 
4861                cancellationToken 
49-             ) 
50-         ) 
62+             ) ; 
63+ #pragma warning restore CS0612  // Type or member is obsolete 
64+         } 
65+ 
66+         foreach  ( Pretranslation  preTranslation  in  servalPreTranslations ) 
5167        { 
5268            // A reference will be in one of the formats: 
5369            // FileFormat.Text: "40_1:verse_001_002" 
@@ -185,30 +201,62 @@ CancellationToken cancellationToken
185201    ) 
186202    { 
187203        // Ensure we have the parameters to retrieve the pre-translation 
188-         ( string ?  translationEngineId ,  string  corpusId ,  bool  _ )  =  await  GetPreTranslationParametersAsync ( sfProjectId ) ; 
204+         ( string ?  translationEngineId ,  string ?  corpusId ,  string ?  parallelCorpusId ,  bool  _ )  = 
205+             await  GetPreTranslationParametersAsync ( sfProjectId ) ; 
189206
190207        // Get the USFM 
191-         string  usfm  =  await  translationEnginesClient . GetPretranslatedUsfmAsync ( 
192-             id :  translationEngineId , 
193-             corpusId :  corpusId , 
194-             textId :  GetTextId ( bookNum ) , 
195-             textOrigin :  PretranslationUsfmTextOrigin . OnlyPretranslated , 
196-             template :  PretranslationUsfmTemplate . Source , 
197-             paragraphMarkerBehavior :  config . ParagraphFormat  switch 
198-             { 
199-                 ParagraphBreakFormatOptions . Remove  =>  PretranslationUsfmMarkerBehavior . Strip , 
200-                 ParagraphBreakFormatOptions . BestGuess  =>  PretranslationUsfmMarkerBehavior . PreservePosition , 
201-                 ParagraphBreakFormatOptions . MoveToEnd  =>  PretranslationUsfmMarkerBehavior . Preserve , 
202-                 _ =>  PretranslationUsfmMarkerBehavior . PreservePosition , 
203-             } , 
204-             quoteNormalizationBehavior :  config . QuoteFormat  switch 
205-             { 
206-                 QuoteStyleOptions . Denormalized  =>  PretranslationNormalizationBehavior . Denormalized , 
207-                 QuoteStyleOptions . Normalized  =>  PretranslationNormalizationBehavior . Normalized , 
208-                 _ =>  PretranslationNormalizationBehavior . Denormalized , 
209-             } , 
210-             cancellationToken :  cancellationToken 
211-         ) ; 
208+         string  usfm ; 
209+         if  ( parallelCorpusId  is  not null ) 
210+         { 
211+             usfm  =  await  translationEnginesClient . GetPretranslatedUsfmAsync ( 
212+                 id :  translationEngineId , 
213+                 parallelCorpusId :  parallelCorpusId , 
214+                 textId :  GetTextId ( bookNum ) , 
215+                 textOrigin :  PretranslationUsfmTextOrigin . OnlyPretranslated , 
216+                 template :  PretranslationUsfmTemplate . Source , 
217+                 paragraphMarkerBehavior :  config . ParagraphFormat  switch 
218+                 { 
219+                     ParagraphBreakFormatOptions . Remove  =>  PretranslationUsfmMarkerBehavior . Strip , 
220+                     ParagraphBreakFormatOptions . BestGuess  =>  PretranslationUsfmMarkerBehavior . PreservePosition , 
221+                     ParagraphBreakFormatOptions . MoveToEnd  =>  PretranslationUsfmMarkerBehavior . Preserve , 
222+                     _ =>  PretranslationUsfmMarkerBehavior . PreservePosition , 
223+                 } , 
224+                 quoteNormalizationBehavior :  config . QuoteFormat  switch 
225+                 { 
226+                     QuoteStyleOptions . Denormalized  =>  PretranslationNormalizationBehavior . Denormalized , 
227+                     QuoteStyleOptions . Normalized  =>  PretranslationNormalizationBehavior . Normalized , 
228+                     _ =>  PretranslationNormalizationBehavior . Denormalized , 
229+                 } , 
230+                 cancellationToken :  cancellationToken 
231+             ) ; 
232+         } 
233+         else 
234+         { 
235+             // Retrieve the USFM from a legacy corpus 
236+ #pragma warning disable CS0612  // Type or member is obsolete 
237+             usfm  =  await  translationEnginesClient . GetCorpusPretranslatedUsfmAsync ( 
238+                 id :  translationEngineId , 
239+                 corpusId :  corpusId , 
240+                 textId :  GetTextId ( bookNum ) , 
241+                 textOrigin :  PretranslationUsfmTextOrigin . OnlyPretranslated , 
242+                 template :  PretranslationUsfmTemplate . Source , 
243+                 paragraphMarkerBehavior :  config . ParagraphFormat  switch 
244+                 { 
245+                     ParagraphBreakFormatOptions . Remove  =>  PretranslationUsfmMarkerBehavior . Strip , 
246+                     ParagraphBreakFormatOptions . BestGuess  =>  PretranslationUsfmMarkerBehavior . PreservePosition , 
247+                     ParagraphBreakFormatOptions . MoveToEnd  =>  PretranslationUsfmMarkerBehavior . Preserve , 
248+                     _ =>  PretranslationUsfmMarkerBehavior . PreservePosition , 
249+                 } , 
250+                 quoteNormalizationBehavior :  config . QuoteFormat  switch 
251+                 { 
252+                     QuoteStyleOptions . Denormalized  =>  PretranslationNormalizationBehavior . Denormalized , 
253+                     QuoteStyleOptions . Normalized  =>  PretranslationNormalizationBehavior . Normalized , 
254+                     _ =>  PretranslationNormalizationBehavior . Denormalized , 
255+                 } , 
256+                 cancellationToken :  cancellationToken 
257+             ) ; 
258+ #pragma warning restore CS0612  // Type or member is obsolete 
259+         } 
212260
213261        // Return the entire book 
214262        if  ( chapterNum  ==  0 ) 
@@ -241,19 +289,34 @@ public async Task UpdatePreTranslationStatusAsync(string sfProjectId, Cancellati
241289        } 
242290
243291        // Ensure we have the parameters to retrieve the pre-translation 
244-         ( string ?  translationEngineId ,  string  corpusId ,  bool  useParatextVerseRef )  = 
292+         ( string ?  translationEngineId ,  string  corpusId ,  string   parallelCorpusId ,   bool  useParatextVerseRef )  = 
245293            await  GetPreTranslationParametersAsync ( sfProjectId ) ; 
246294
247295        // Get all the pre-translations and update the chapters 
248-         Dictionary < int ,  HashSet < int > >  bookChapters  =  [ ] ; 
249-         foreach  ( 
250-             Pretranslation  preTranslation  in  await  translationEnginesClient . GetAllPretranslationsAsync ( 
296+         IList < Pretranslation >  preTranslations ; 
297+         if  ( parallelCorpusId  is  not null ) 
298+         { 
299+             preTranslations  =  await  translationEnginesClient . GetAllPretranslationsAsync ( 
300+                 translationEngineId , 
301+                 parallelCorpusId , 
302+                 textId :  null , 
303+                 cancellationToken 
304+             ) ; 
305+         } 
306+         else 
307+         { 
308+             // Retrieve the pre-translations from a legacy corpus 
309+ #pragma warning disable CS0612  // Type or member is obsolete 
310+             preTranslations  =  await  translationEnginesClient . GetAllCorpusPretranslationsAsync ( 
251311                translationEngineId , 
252312                corpusId , 
253313                textId :  null , 
254314                cancellationToken 
255-             ) 
256-         ) 
315+             ) ; 
316+ #pragma warning restore CS0612  // Type or member is obsolete 
317+         } 
318+         Dictionary < int ,  HashSet < int > >  bookChapters  =  [ ] ; 
319+         foreach  ( Pretranslation  preTranslation  in  preTranslations ) 
257320        { 
258321            // Get the book and chapter number 
259322            int  bookNum ; 
@@ -339,7 +402,8 @@ await projectDoc.SubmitJson0OpAsync(op =>
339402    /// <exception cref="DataNotFoundException">The pre-translation engine is not configured, or the project secret cannot be found.</exception> 
340403    protected  internal  virtual  async  Task < ( 
341404        string  translationEngineId , 
342-         string  corpusId , 
405+         string ?  corpusId , 
406+         string ?  parallelCorpusId , 
343407        bool  useParatextVerseRef 
344408    ) >  GetPreTranslationParametersAsync ( string  sfProjectId ) 
345409    { 
@@ -350,11 +414,12 @@ bool useParatextVerseRef
350414        } 
351415
352416        string  translationEngineId  =  projectSecret . ServalData ? . PreTranslationEngineId ; 
353-         string  corpusId ; 
417+         string ?  corpusId  =  null ; 
418+         string ?  parallelCorpusId  =  null ; 
354419        bool  useParatextVerseRef  =  false ; 
355420        if  ( ! string . IsNullOrWhiteSpace ( projectSecret . ServalData ? . ParallelCorpusIdForPreTranslate ) ) 
356421        { 
357-             corpusId  =  projectSecret . ServalData . ParallelCorpusIdForPreTranslate ; 
422+             parallelCorpusId  =  projectSecret . ServalData . ParallelCorpusIdForPreTranslate ; 
358423            useParatextVerseRef  =  true ; 
359424        } 
360425        else 
@@ -369,11 +434,14 @@ bool useParatextVerseRef
369434            } 
370435        } 
371436
372-         if  ( string . IsNullOrWhiteSpace ( translationEngineId )  ||  string . IsNullOrWhiteSpace ( corpusId ) ) 
437+         if  ( 
438+             string . IsNullOrWhiteSpace ( translationEngineId ) 
439+             ||  ( string . IsNullOrWhiteSpace ( corpusId )  &&  string . IsNullOrWhiteSpace ( parallelCorpusId ) ) 
440+         ) 
373441        { 
374442            throw  new  DataNotFoundException ( "The pre-translation engine is not configured." ) ; 
375443        } 
376444
377-         return  ( translationEngineId ,  corpusId ,  useParatextVerseRef ) ; 
445+         return  ( translationEngineId ,  corpusId ,  parallelCorpusId ,   useParatextVerseRef ) ; 
378446    } 
379447} 
0 commit comments