crowdin / crowdin-api-client-java Goto Github PK
View Code? Open in Web Editor NEWJava client library for Crowdin API
Home Page: https://jitpack.io/#crowdin/crowdin-api-client-java
License: MIT License
Java client library for Crowdin API
Home Page: https://jitpack.io/#crowdin/crowdin-api-client-java
License: MIT License
Crowdin Rest API Add File and Update or Restore File now support new ImportOptions
types:
These new Import Options should be added to this API client as well as the corresponding unit tests.
We've added new possible import options for files:
Add File: new ImportOptions
possible value - Docx File Import Options (including the response)
Update or Restore File: new ImportOptions
possible value - Docx File Import Options (including the response)
Edit File: new /importOptions/*
path parameters
So these changes should be reflected in this API Client.
This property was removed from the API:
https://github.com/crowdin/crowdin-api-client-java/search?q=defaultProjectId
HttpException(error=HttpException.Error(code=403, message=Forbidden))
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at com.fasterxml.jackson.databind.introspect.AnnotatedConstructor.call(AnnotatedConstructor.java:119)
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator.createUsingDefault(StdValueInstantiator.java:270)
at com.fasterxml.jackson.databind.deser.std.ThrowableDeserializer.deserializeFromObject(ThrowableDeserializer.java:149)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:164)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4526)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3468)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3436)
at com.crowdin.client.core.http.impl.json.CrowdinApiExceptionDeserializer.deserialize(CrowdinApiExceptionDeserializer.java:35)
at com.crowdin.client.core.http.impl.json.CrowdinApiExceptionDeserializer.deserialize(CrowdinApiExceptionDeserializer.java:17)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4526)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3468)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3436)
at com.crowdin.client.core.http.impl.json.JacksonJsonTransformer.parse(JacksonJsonTransformer.java:60)
at com.playtika.services.infra.translation.service.crowdin.http.ApacheHttpClient.request(ApacheHttpClient.java:91)
at com.playtika.services.infra.translation.service.crowdin.http.ApacheHttpClient.get(ApacheHttpClient.java:53)
at com.crowdin.client.teams.TeamsApi.listTeams(TeamsApi.java:56)
The tasks
package has low code coverage by Unit tests. We need to add more Unit tests to cover the code.
References:
There is a dot before url in CrowdinApi class -> line 46
if (credentials.getOrganization() != null) { this.url = "https://" + credentials.getOrganization() + ".api.crowdin.com/api/v2"; } else { this.url = "https://api.crowdin.com/api/v2"; }
API Reference:
api.mts.translations.post (crowdin.com)
api.mts.translations.post (Crowdin Enterprise)
https://github.com/crowdin/crowdin-api-client-java/search?q=eta
This property is being deprecated and should be removed. Actually, it never provided any usable result so probably no one is dependent on it.
Crowdin Rest API now supports the API methods for TM (Translation Memory) segments management.
New API methods:
It should be added to this API client as well as the corresponding unit tests.
Crowdin recently added a bunch of new API methods to manage Strings Exporter settings for some file formats.
The new methods need to be added to this API Client.
API Reference:
Reference - api.projects.strings.get
XmlFileImportOptions contains field translatableElements.
In java com.crowdin.client.sourcefiles.model.XmlFileImportOptions it is represented as a list of Strings.
However, the api returns it as a key-value map what cause exception in deserialization.
Crowdin returns error if I try to pass limit and offset
AFAIK Crowdin doesn't need them anymore.
public ResponseList<WorkflowStep> listWorkflowSteps(Long projectId, Integer limit, Integer offset) throws HttpException, HttpBadRequestException {
Map<String, Optional<Integer>> queryParams = HttpRequestConfig.buildUrlParams("limit", Optional.ofNullable(limit), "offset", Optional.ofNullable(offset));
WorkflowStepResponseList workflowStepResponseList = (WorkflowStepResponseList)this.httpClient.get(this.url + "/projects/" + projectId + "/workflow-steps", new HttpRequestConfig(queryParams), WorkflowStepResponseList.class);
return WorkflowStepResponseList.to(workflowStepResponseList);
}
the object : ExportPrjoectTranslationRequest
are bad named and in the object there is :
private String targetLanguageId; private String format; private List<Long> branchIds; private List<Long> directoryIds; private List<Long> fileIds; private Boolean skipUntranslatedStrings; private Boolean skipUntranslatedFiles; private Integer exportWithMinApprovalsCount;
But on the reference API v2 this is exportApprovedOnly
instead exportWithMinApprovalsCount
Because when the client send request, it throw exception because
"errors": [ { "code": "notFound", "message": "Field 'exportWithMinApprovalsCount' Not Found" }
The Distribution creation API has been changed. Now you can create a distribution with the following parameters:
bundleIds
- array of bundle idsThe following parameters have been deprecated:
format
exportPattern
labelIds
A Distribution response has also been changed. Now it contains the bundleIds
field. The format
, exportPattern
, and labelIds
fields are deprecated.
In addition, the fileIds
request parameter is now optional.
All the changes are described in the API documentation.
API reference:
We've added new API methods to the "Source Files" section that would be great to reflect in this API Client.
API Reference:
Crowdin Rest API now supports API methods that allow to manage screenshot labels.
New API methods:
It should be added to this API client as well as the corresponding unit tests.
We're happy to announce a significant update for Crowdin Glossaries that allows managing the terminology in a more advanced way.
There are a lot of new things and some changes in the Crowdin API.
New APIs:
Updates:
format
and exportFields
scheme
The translationOfTermId
is deprecated and the conceptId
added in:
status
, type
, gender
, note
, url
)Edit Term - new path options
All of these changes should be reflected in this API Client.
As a Crowdin Java API client user, I would like to have online docs to navigate and explore the client resources, methods, parameters, etc.
Examples:
These docs should be generated using GH Actions and deployed to GH Pages. Workflow example: docs.yml
The possible tool for that is javadoc.
Steps:
API reference: api.projects.tasks.post
The core
package has low code coverage by Unit tests. We need to add more Unit tests to cover the code.
References:
We've added a new API methods section - Organization-Webhooks. It's a webhooks that allow you to collect information about events that happen in your Crowdin account/organization.
It would be great to reflect these API changes in the API Client.
Note: the events
list is different for crowdin.com and Crowdin Enterprise APIs.
While using this snippet:
@Test
fun testCrash() {
val baseUrl = "https://translate.loophabits.org"
val t = "YOUR_OWN_TOKEN"
val organization = "loop-habit-tracker-api-test"
val credentials = Credentials(t, organization, baseUrl)
val client = Client(credentials)
client.usersApi.getProjectMember(440668L, 14614530L)
}
I get the following error:
HttpException(error=HttpException.Error(code=null, message=Cannot construct instance of `com.crowdin.client.users.model.LanguagePermission` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('translator')
at [Source: (String)"{"data":{"id":14614530,"username":"hiq2","fullName":"Quentin","role":"translator","permissions":{"tw":"translator","ar-BH":"translator","lg":"translator"},"avatarUrl":"https:\/\/crowdin-static.downloads.crowdin.com\/avatar\/14614530\/medium\/bb2591b51932e79e834e744523e847ba.png","joinedAt":"2021-02-08T09:27:24+00:00","timezone":"Europe\/Zurich"}}"; line: 1, column: 103] (through reference chain: com.crowdin.client.users.model.ProjectMemberResponseObject["data"]->com.crowdin.client.users.model.ProjectMember["permissions"]->java.util.LinkedHashMap["tw"])))
at com.crowdin.client.core.http.exceptions.HttpException.fromMessage(HttpException.java:22)
at com.crowdin.client.core.http.impl.http.ApacheHttpClient.request(ApacheHttpClient.java:132)
at com.crowdin.client.core.http.impl.http.ApacheHttpClient.get(ApacheHttpClient.java:76)
at com.crowdin.client.users.UsersApi.getProjectMember(UsersApi.java:52)
I'm interested in these permissions: I want to get the list of project members and which languages they translated, so that I can give them proper credit.
I'm using the latest version of the API client library (1.3.3).
In my project I got a "lang" folder with the files messages.txt
(english original) and messages_de.txt
which follow the Java properties format. I want to use crowdin to upload those files and download versions for other languages.
Please add documentation how to use the SDK to do this.
Using version 1.1.2.
Steps to reproduce the issue:
Long projectId = ...; // Valid project ID.
Credentials credentials = ...; // Valid credentials.
new Client(credentials).getTranslationsApi().buildProjectTranslation(projectId, new BuildProjectTranslationRequest());
(Let me know if you need the project ID used.)
2. Note that it fails with an exception:
HttpException(error=HttpException.Error(code=null, message=Cannot deserialize instance of `java.util.ArrayList` out of START_OBJECT token
at [Source: (String)"{"data":{"id":1,"projectId":1234,"status":"inProgress","progress":0,"attributes":{"branchId":null,"targetLanguageIds":[],"exportTranslatedOnly":false,"skipUntranslatedFiles":false,"exportApprovedOnly":false}}}"; line: 1, column: 82] (through reference chain: com.crowdin.client.translations.model.ProjectBuildResponseObject["data"]->com.crowdin.client.translations.model.ProjectBuild["attributes"])))
checkBuildStatus
or listProjectBuilds
will also result in a similar exception.I'm not sure if this is a client issue or a server one, the API definition says that those API endpoints return a project build with a list of attributes but the server is currently just returning a single attribute (i.e. an object instead of a list). Is the client/API definition that's incorrect or the server should be really returning a list?
The isMultilingual
flag is missing. It should be added as well as the corresponding test case updated.
API reference - api.projects.bundles.get
Model - Bundle.java
Test - BundlesApiTest.java
Also, the public
modifier should be added here - BundlesApi.java#L160
Crowdin has recently enhanced its response for the Progress API Methods:
For example:
{
"data": [
{
"data": {
"words": {
"total": 7249,
"translated": 3651,
+ "preTranslateAppliedTo": 1254,
"approved": 3637
},
"phrases": {
"total": 3041,
"translated": 2631,
+ "preTranslateAppliedTo": 1254,
"approved": 2622
},
"translationProgress": 86,
"approvalProgress": 86,
"languageId": "af"
}
}
],
"pagination": {
"offset": 0,
"limit": 25
}
}
The response of these methods now contains a new field preTranslateAppliedTo
in the words
and phrases
objects.
These new fields should also be reflected in this API Client.
Crowdin Rest API now supports the qaChecksIgnorableCategories
field on the Projects API.
This field allows you to retrieve the list of QA Check categories that can be ignored for a Crowdin project.
Affected API methods:
It should be reflected in this API client and the corresponding unit tests should be updated.
Crowdin added new API endpoint - String Batch Operations.
It would be great to add the new method to this API client as well as the corresponding unit tests.
New API endpoints:
These new endpoints should be reflected in this API client and covered by Unit tests.
API Reference: Add Task
The API response will also include this new field.
This is relevant for both the crowdin.com and Crowdin Enterprise APIs.
The new parameter should also be reflected in this API client.
Crowdin Rest API now supports an API method that allows downloading file preview.
New API method:
It should be added to this API client as well as the corresponding unit tests.
The projectsgroups
package has low code coverage by Unit tests. We need to add more Unit tests to cover the code.
References:
New API endpoints:
Crowdin Enterprise endpoints are almost the same, but there is some difference in template config:
The reports
package has low code coverage by Unit tests. We need to add more Unit tests to cover the code.
References:
Crowdin API has a new Notifications API that allows sending notifications to the project and organization members. It would be great to add support for this API in this Crowdin API client.
API reference:
Crowdin recently added the ability to configure the export options for JavaScript files. This is a great feature, but it's not yet supported by the API Client.
exportPattern
- string, File export pattern. Defines file name and path in resulting translations bundle.exportQuotes
- string enum single
or double
. Defines quotes to be used in resulting translations bundle.The new options need to be added to this API Client.
API Reference:
Crowdin has recently added a possibility to Pre-Translate strings by labels. However, the new parameters are not supported in this API client.
The new labelIds
and excludeLabelIds
parameters should be added to the "Apply Pre-Translation" method in this API client.
API Reference:
attributes
field now contains the new fields as well)In API add tags endpoint accepts array of tags
[
{
"stringId": 0,
"position": {}
}
]
but client sends single object
public ResponseObject<Tag> addTag(Long projectId, Long screenshotId, AddTagRequest request) throws HttpException, HttpBadRequestException {
TagResponseObject tagResponseObject = (TagResponseObject)this.httpClient.post(this.url + "/projects/" + projectId + "/screenshots/" + screenshotId + "/tags", request, new HttpRequestConfig(), TagResponseObject.class);
return ResponseObject.of(tagResponseObject.getData());
}
and thus we get error
HttpBadRequestException.Error(code=data, message=Expects each item in a collection to be an array or Traversable, integer provided)]
Write and run below test into BundleApiTest.java
@Test
public void downloadBundleTest() {
TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
ResponseObject<DownloadLink> response = this.getBundlesApi().downloadBundle(projectId, bundleId, exportId);
assertEquals(new Date(119, Calendar.SEPTEMBER, 20,10,31,21), response.getData().getExpireIn());
assertEquals("test.com", response.getData().getUrl());
}
When I run this test, the result shows that Date expireIn from Json file downloadBundle.json which look like this:
{
"data": {
"url": "test.com",
"expireIn": "2019-09-20T10:31:21+00:00"
}
}
is parsed as Fri Sep 20 08:00:21 GMT 2019
Despite of hours difference what will direct us to problem with TimeZone, what is more important we don't getting minutes of hour read properly.
What is expected when parsing given date of: 2019-09-20T10:31:21+00:00
is result looking like this: Fri Sep 20 10:31:21 GMT 2019
.
We've added a few new API endpoints to manage Bundles in Crowdin - https://developer.crowdin.com/api/v2/#tag/Bundles
It would be great to add the new methods to the corresponding class - BundlesApi.java and include tests.
The languages
package has low code coverage by Unit tests. We need to add more Unit tests to cover the code.
References:
While trying to call
public ResponseObject<Tag> addTag(Long projectId, Long screenshotId, List<AddTagRequest> request)
Get the following error
HttpException(error=HttpException.Error(code=null, message=Cannot deserialize instance of `com.crowdin.client.screenshots.model.Tag` out of START_ARRAY token
at [Source: (String)"{"data":[{"data":{"id":17,"screenshotId":19,"stringId":31649,"position":null,"createdAt":"2022-06-20T10:59:52+00:00"}},{"data":{"id":19,"screenshotId":19,"stringId":31651,"position":null,"createdAt":"2022-06-20T10:59:52+00:00"}},{"data":{"id":21,"screenshotId":19,"stringId":31653,"position":null,"createdAt":"2022-06-20T10:59:52+00:00"}},{"data":{"id":23,"screenshotId":19,"stringId":31655,"position":null,"createdAt":"2022-06-20T10:59:52+00:00"}},{"data":{"id":25,"screenshotId":19,"stringId":31657"[truncated 206 chars]; line: 1, column: 9] (through reference chain: com.crowdin.client.screenshots.model.TagResponseObject["data"])))
at com.crowdin.client.core.http.exceptions.HttpException.fromMessage(HttpException.java:22)
Server returns List of tags while Java client expect only one tag in response !
Crowdin added 3 new API endpoints that should be also added to the corresponding sections of this API Client.
New code should be covered by Unit tests in the same way as the rest of the code.
Crowdin recently released a big update of the reports functionality. Now, when calculating the price for translation in Cost Estimation and Translation Cost reports, we have introduced a new feature that allows you to include the cost of proofreading if the source text matches the Translation Memory (TM) or Machine Translation (MT) results.
The reports API was updated as well. The legacy Cost Estimate (including Fuzzy mode) and Translation Cost reports were deprecated in favor of the new Cost-Estimation Post-Editing and Translation Costs Post-Editing reports. The legacy reports will be removed in future releases.
API reference:
The Report Settings Template API was also affected (refer to the API Docs for details).
Deprecated forms should be marked as deprecated in this API Client, and the new forms should be added.
Added new request fields - api.projects.distributions.post
+ distribution response object and patch are also updated
crowdin.com and Crowdin Enterprise
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.