Skip to content

Commit

Permalink
Fixes batch import logic to save target comments
Browse files Browse the repository at this point in the history
Previously, the source comment (text unit) was systemically copied into the target comment (text unit variant) and that for all imported translations. This seems to be the behavior since day 1 of the TextUnitBatchImporterService, yet it is a bug.

It affects ThirdPartySync and all other batch imports.
  • Loading branch information
aurambaj committed Jul 12, 2023
1 parent 9abb8c4 commit 273db30
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ TMTextUnitVariant importTextUnit(
tmTextUnitId,
targetLocaleId,
targetString,
null,
targetComment,
status,
includedInLocalizedFile,
createdDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ boolean isUpdateNeeded(TextUnitForBatchMatcherImport textUnitForBatchImport) {
currentTextUnit.getStatus(),
DigestUtils.md5Hex(currentTextUnit.getTarget()),
currentTextUnit.isIncludedInLocalizedFile(),
currentTextUnit.getComment(),
currentTextUnit.getTargetComment(),
textUnitForBatchImport.getStatus(),
DigestUtils.md5Hex(textUnitForBatchImport.getContent()),
textUnitForBatchImport.isIncludedInLocalizedFile(),
Expand Down Expand Up @@ -359,7 +359,7 @@ List<TextUnitForBatchMatcherImport> skipInvalidAndConvertToTextUnitForBatchImpor

textUnitForBatchImport.setLocale(localeService.findByBcp47Tag(t.getTargetLocale()));
textUnitForBatchImport.setContent(NormalizationUtils.normalize(t.getTarget()));
textUnitForBatchImport.setComment(t.getComment());
textUnitForBatchImport.setComment(t.getTargetComment());
textUnitForBatchImport.setIncludedInLocalizedFile(t.isIncludedInLocalizedFile());
textUnitForBatchImport.setStatus(t.getStatus() == null ? APPROVED : t.getStatus());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ public void testAsyncImportTextUnitsNameOnly() throws InterruptedException {
textUnitDTO.setAssetPath(tmTestData.asset.getPath());
textUnitDTO.setName("TEST2");
textUnitDTO.setTarget("TEST2 translation for fr");
textUnitDTO.setComment("Comment2");

TextUnitDTO textUnitDTO2 = new TextUnitDTO();
textUnitDTO2.setRepositoryName(tmTestData.repository.getName());
textUnitDTO2.setTargetLocale(tmTestData.frFR.getBcp47Tag());
textUnitDTO2.setAssetPath(tmTestData.asset.getPath());
textUnitDTO2.setName("TEST3");
textUnitDTO2.setTarget("TEST3 translation for fr");
textUnitDTO2.setTargetComment("TEST3 target comment");

TextUnitDTO textUnitDTO3 = new TextUnitDTO();
textUnitDTO3.setRepositoryName(tmTestData.repository.getName());
Expand Down Expand Up @@ -121,9 +123,11 @@ public void testAsyncImportTextUnitsNameOnly() throws InterruptedException {
i++;
assertEquals("TEST2", textUnitDTOsFromSearch.get(i).getName());
assertEquals("TEST2 translation for fr", textUnitDTOsFromSearch.get(i).getTarget());
assertNull(textUnitDTOsFromSearch.get(i).getTargetComment());
i++;
assertEquals("TEST3", textUnitDTOsFromSearch.get(i).getName());
assertEquals("TEST3 translation for fr", textUnitDTOsFromSearch.get(i).getTarget());
assertEquals("TEST3 target comment", textUnitDTOsFromSearch.get(i).getTargetComment());
i++;
}

Expand Down

0 comments on commit 273db30

Please sign in to comment.