Skip to content

Commit 152855b

Browse files
authored
feat(api): Pre-Translations: add Label IDs support (#198)
1 parent cbea7d5 commit 152855b

5 files changed

Lines changed: 26 additions & 3 deletions

File tree

src/main/java/com/crowdin/client/translations/model/ApplyPreTranslationRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ public class ApplyPreTranslationRequest {
1616
private Boolean translateUntranslatedOnly;
1717
private Boolean translateWithPerfectMatchOnly;
1818
private Boolean markAddedTranslationsAsDone;
19-
19+
private List<Long> labelIds;
20+
private List<Long> excludeLabelIds;
2021
}

src/main/java/com/crowdin/client/translations/model/PreTranslationStatus.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ public static class Attributes {
2626
private boolean duplicateTranslations;
2727
private boolean translateUntranslatedOnly;
2828
private boolean translateWithPerfectMatchOnly;
29+
private List<Long> labelIds;
30+
private List<Long> excludeLabelIds;
2931
}
3032
}

src/test/java/com/crowdin/client/translations/TranslationsApiTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,22 @@ public void applyPreTranslationTest() {
6868
request.setFileIds(singletonList(fileId));
6969
request.setAutoApproveOption(AutoApproveOption.NONE);
7070
request.setMethod(Method.MT);
71+
request.setLabelIds(singletonList(10000L));
72+
request.setExcludeLabelIds(singletonList(20000L));
7173
ResponseObject<PreTranslationStatus> preTranslationStatusResponseObject = this.getTranslationsApi().applyPreTranslation(projectId, request);
7274
assertEquals(preTranslationStatusResponseObject.getData().getIdentifier(), preTranslationId);
75+
76+
assertEquals(10000L, preTranslationStatusResponseObject.getData().getAttributes().getLabelIds().get(0));
77+
assertEquals(20000L, preTranslationStatusResponseObject.getData().getAttributes().getExcludeLabelIds().get(0));
7378
}
7479

7580
@Test
7681
public void preTranslationStatusTest() {
7782
ResponseObject<PreTranslationStatus> preTranslationStatusResponseObject = this.getTranslationsApi().preTranslationStatus(projectId, preTranslationId);
7883
assertEquals(preTranslationStatusResponseObject.getData().getIdentifier(), preTranslationId);
84+
85+
assertEquals(10000L, preTranslationStatusResponseObject.getData().getAttributes().getLabelIds().get(0));
86+
assertEquals(20000L, preTranslationStatusResponseObject.getData().getAttributes().getExcludeLabelIds().get(0));
7987
}
8088

8189
@Test

src/test/resources/api/translations/preTranslationRequest.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,11 @@
66
2
77
],
88
"method": "mt",
9-
"autoApproveOption": "none"
9+
"autoApproveOption": "none",
10+
"labelIds": [
11+
10000
12+
],
13+
"excludeLabelIds": [
14+
20000
15+
]
1016
}

src/test/resources/api/translations/preTranslationStatus.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
"autoApproveOption": "all",
1515
"duplicateTranslations": true,
1616
"translateUntranslatedOnly": true,
17-
"translateWithPerfectMatchOnly": true
17+
"translateWithPerfectMatchOnly": true,
18+
"labelIds": [
19+
10000
20+
],
21+
"excludeLabelIds": [
22+
20000
23+
]
1824
},
1925
"createdAt": "2019-09-20T14:05:50+00:00",
2026
"updatedAt": "2019-09-20T14:05:50+00:00",

0 commit comments

Comments
 (0)