Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/main/java/com/crowdin/client/translations/TranslationsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.crowdin.client.translations.model.UploadTranslationsStringsRequest;
import com.crowdin.client.translations.model.UploadTranslationsStringsResponse;
import com.crowdin.client.translations.model.UploadTranslationsStringsResponseObject;
import com.crowdin.client.translations.model.PreTranslationReportResponse;
import com.crowdin.client.translations.model.PreTranslationReportResponseObject;

import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -288,4 +290,24 @@ public ResponseObject<PreTranslation> editPreTranslation(Long projectId, String
);
return ResponseObject.of(preTranslationResponseObject.getData());
}

/**
* Pre-Translation Report
*
* @param projectId project identifier
* @param preTranslationId pre-translation identifier
* @return pre-translation report data
* @see <ul>
* <li><a href="https://developer.crowdin.com/api/v2/#tag/Translations/operation/api.projects.pre-translations.report.getReport" target="_blank"><b>API Documentation</b></a></li>
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#tag/Translations/operation/api.projects.pre-translations.report.getReport" target="_blank"><b>Enterprise API Documentation</b></a></li>
* </ul>
*/
public ResponseObject<PreTranslationReportResponse> getPreTranslationReport(Long projectId, String preTranslationId) throws HttpException, HttpBadRequestException {
PreTranslationReportResponseObject response = this.httpClient.get(
this.url + "/projects/" + projectId + "/pre-translations/" + preTranslationId + "/report",
new HttpRequestConfig(),
PreTranslationReportResponseObject.class
);
return ResponseObject.of(response.getData());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.crowdin.client.translations.model;

import lombok.Data;
import java.util.List;
import java.util.Map;
import com.crowdin.client.translationstatus.model.Category;


@Data
public class PreTranslationReportResponse {

private List<TargetLanguage> languages;
private Method preTranslateType;

@Data
public static class TargetLanguage {
private String id;
private List<File> files;
private Map<String, Integer> skipped;
private List<Category> skippedQaCheckCategories;
}

@Data
public static class File {
private Long id;
private Statistics statistics;
}

@Data
public static class Statistics {
private Integer phrases;
private Integer words;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.crowdin.client.translations.model;

import lombok.Data;
import com.crowdin.client.translations.model.PreTranslationReportResponse;

@Data
public class PreTranslationReportResponseObject {
private PreTranslationReportResponse data;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.crowdin.client.translations.model.UploadTranslationsResponse;
import com.crowdin.client.translations.model.UploadTranslationsStringsRequest;
import com.crowdin.client.translations.model.UploadTranslationsStringsResponse;
import com.crowdin.client.translations.model.PreTranslationReportResponse;

import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPatch;
Expand Down Expand Up @@ -69,7 +71,8 @@ public List<RequestMock> getMocks() {
RequestMock.build(this.url + "/projects/" + projectId + "/translations/builds/" + buildId, HttpDelete.METHOD_NAME),
RequestMock.build(String.format("%s/projects/%d/translations/exports", this.url, projectId), HttpPost.METHOD_NAME, "api/translations/exportProjectTranslationRequest.json", "api/translations/exportProjectTranslationResponse.json"),
RequestMock.build(this.url + "/projects/" + projectId + "/pre-translations", HttpGet.METHOD_NAME, "api/translations/listPreTranslations.json"),
RequestMock.build(this.url + "/projects/" + projectId + "/pre-translations/" + preTranslationId, HttpPatch.METHOD_NAME, "api/translations/editPreTranslationRequest.json", "api/translations/editPreTranslationResponse.json")
RequestMock.build(this.url + "/projects/" + projectId + "/pre-translations/" + preTranslationId, HttpPatch.METHOD_NAME, "api/translations/editPreTranslationRequest.json", "api/translations/editPreTranslationResponse.json"),
RequestMock.build(this.url + "/projects/" + projectId + "/pre-translations/" + preTranslationId + "/report", HttpGet.METHOD_NAME, "api/translations/preTranslationReportResponse.json")
);
}

Expand Down Expand Up @@ -266,4 +269,16 @@ public void editPreTranslationTest() {
assertEquals(language, preTranslationResponseObject.getData().getAttributes().getLanguageIds().get(0));
assertEquals(fileId, preTranslationResponseObject.getData().getAttributes().getFileIds().get(0));
}

@Test
public void getPreTranslationReportTest() {
ResponseObject<PreTranslationReportResponse> response = this.getTranslationsApi().getPreTranslationReport(projectId, preTranslationId);
PreTranslationReportResponse report = response.getData();
assertNotNull(report);
assertEquals(Method.AI, report.getPreTranslateType());
PreTranslationReportResponse.TargetLanguage lang = report.getLanguages().get(0);
assertEquals(language, lang.getId());
PreTranslationReportResponse.File file = lang.getFiles().get(0);
assertEquals(fileId, file.getId());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"data": {
"languages": [
{
"id": "uk",
"files": [
{
"id": "2",
"statistics": { "phrases": 6, "words": 13 }
}
],
"skipped": { "ai_error": 6 },
"skippedQaCheckCategories": ["spellcheck"]
}
],
"preTranslateType": "ai"
}
}