Custom batch pre-translationfuction skipping segment or missing result

When I develop a plugin use the Batch task API ,I custom a batch pre-translation function,but when I send the source text to translation engine to ask for the result ,The result is not inserted into the corresponding segment or the result is missing.  I want to know the reason.

Parents Reply Children
  • Deer 

    The related code is as follow:

    public override void ProcessParagraphUnit(IParagraphUnit paragraphUnit)
    {

    int num = 9;
    if (paragraphUnit.IsStructure)
    {
    base.ProcessParagraphUnit(paragraphUnit);
    }
    else
    {
    using (IEnumerator<ISegmentPair> enumerator = paragraphUnit.SegmentPairs.GetEnumerator())
    {
    while (enumerator.MoveNext())
    {
    ISegmentPair current = enumerator.Current;
    //if (!current.Properties.IsLocked && !this.IsTargetEmpty(current) && (this.__setings.IsBatchChangeStatus && current.Target.Properties.TranslationOrigin.OriginType == "mt"))
    //{
    // current.Target.Properties.TranslationOrigin.OriginType = "Interact";
    //}
    ////else if (!current.Properties.IsLocked && this.IsTargetEmpty(current) && (string.IsNullOrEmpty(BatchTranslatorProcessor.GetPlainTextFromSegment(current.Target)) || string.IsNullOrWhiteSpace(BatchTranslatorProcessor.GetPlainTextFromSegment(current.Target))))
    //else if (!current.Properties.IsLocked )
    //{
    string empty = string.Empty;
    string plainTextFromSegment;
    try
    {
    plainTextFromSegment = BatchTranslatorProcessor.GetPlainTextFromSegment(current.Source);
    }
    catch (Exception ex)
    {
    continue;
    }

    if (!string.IsNullOrWhiteSpace(plainTextFromSegment) && !string.IsNullOrEmpty(plainTextFromSegment))
    {
    //this.segPairs_in_batch.Add(current);
    //this.TranslateBatch();