Skip to content

Commit 535333d

Browse files
committed
Phrase Connector to import with status REVIEW_NEEDED and SKIP_IF_ACCEPTED
Translation imported from Phrase will now use the REVIEW_NEEDED status. If there is an existing translation with ACCEPTED status, the translation from Phrase will be skipped.
1 parent 4bcb311 commit 535333d

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

webapp/src/main/java/com/box/l10n/mojito/entity/TMTextUnitVariantComment.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ public enum Type {
4949
LEVERAGING,
5050
INTEGRITY_CHECK,
5151
AI_TRANSLATE,
52-
QUALITY_CHECK
52+
QUALITY_CHECK,
53+
THIRD_PARTY_TMS_PULL,
5354
}
5455

5556
public enum Severity {

webapp/src/main/java/com/box/l10n/mojito/service/thirdparty/ThirdPartyTMSPhrase.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
import com.box.l10n.mojito.android.strings.AndroidStringDocumentReader;
99
import com.box.l10n.mojito.android.strings.AndroidStringDocumentWriter;
1010
import com.box.l10n.mojito.android.strings.AndroidStringDocumentWriter.EscapeType;
11-
import com.box.l10n.mojito.entity.PollableTask;
12-
import com.box.l10n.mojito.entity.Repository;
13-
import com.box.l10n.mojito.entity.RepositoryLocale;
11+
import com.box.l10n.mojito.entity.*;
1412
import com.box.l10n.mojito.service.pollableTask.PollableFuture;
1513
import com.box.l10n.mojito.service.repository.RepositoryService;
1614
import com.box.l10n.mojito.service.thirdparty.phrase.PhraseClient;
@@ -492,10 +490,26 @@ private void pullLocale(
492490
// communicate some comments, but anyway it should not be the source comment
493491
textUnitDTOS.forEach(t -> t.setComment(null));
494492

495-
Stopwatch importStopWatch = Stopwatch.createStarted();
493+
List<TextUnitBatchImporterService.TextUnitDTOWithVariantComment>
494+
textUnitDTOWithVariantComments =
495+
textUnitDTOS.stream()
496+
.map(
497+
t -> {
498+
t.setStatus(TMTextUnitVariant.Status.REVIEW_NEEDED);
499+
TMTextUnitVariantComment tmTextUnitVariantComment =
500+
new TMTextUnitVariantComment();
501+
tmTextUnitVariantComment.setType(
502+
TMTextUnitVariantComment.Type.THIRD_PARTY_TMS_PULL);
503+
tmTextUnitVariantComment.setSeverity(TMTextUnitVariantComment.Severity.INFO);
504+
tmTextUnitVariantComment.setContent("Import from Phrase Strings");
505+
return new TextUnitBatchImporterService.TextUnitDTOWithVariantComment(
506+
t, tmTextUnitVariantComment);
507+
})
508+
.toList();
496509

497-
textUnitBatchImporterService.importTextUnits(
498-
textUnitDTOS, integrityChecksType, SKIP_IF_ACCEPTED);
510+
Stopwatch importStopWatch = Stopwatch.createStarted();
511+
textUnitBatchImporterService.importTextUnitsWithVariantComment(
512+
textUnitDTOWithVariantComments, integrityChecksType, SKIP_IF_ACCEPTED);
499513
logger.info("Time importing text units: {}", importStopWatch.elapsed());
500514
}
501515

0 commit comments

Comments
 (0)