Apply Pre-translate issue

Hi!

I’m attempting to implement the same pre-translation functionality as found on the project page of “my-project” via Dashborad using the Crowdin dev API. I’ve followed these steps:

  1. Initiated a POST request to {protocol}://{host}/api/v2/projects/{projectId}/pre-translations with the required parameters.
  2. Periodically checked the pre-translation status at projects/{projectId}/pre-translations/{preTranslationId} until it is marked as finished.

I’ve also examined the network requests made by the Crowdin site, and they closely resemble what I’m trying to achieve through the Crowdin dev API.

Based on my observations, I’ve narrowed down the possibilities to two options:

  1. There may be a bug in the apply-pretranslate API.
  2. I might be overlooking some steps in the pre-translation process.

Could you please assist me with resolving this issue? I would appreciate it if you could point out any mistakes I may have made in my approach.

Hi @pavel.karpukhin

Can you please clarify what issues you are facing with the pre-translate feature and what is the expected result?

Looking forward to your reply,

I want to have the same functionality that crowdin on Crowdin>dashboard-> pre-translation-> via TM

When I pre-translate string resources on crowdin site it works perfectly. As soon as pre-translation is finished, I can see that my string resources are translated via TM.

I expect the same behaviour when I use projects/{projectId}/pre-translations with TM parameters. The problem is that as soon as I use Apply Pre-Translation from API v2 Reference and wait until it 's finished, I do not see translated string resources

@pavel.karpukhin

Thank you for sharing the details!

Please provide details of how you are making a request, including any request body parameters. Do you any of the Crowdin API Clients?

I do not use any Crowdin API Clients.

Here is my pre-translate request using java.net package:

 HttpRequest.newBuilder()
            .uri(URI("https://api.crowdin.com/api/v2/projects/${PROJECT_ID}/pre-translations"))
            .header("Authorization", "Bearer my token")
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(requestBody))
            .timeout(Duration.ofSeconds(120))
            .build()

        val response = client.send(request, HttpResponse.BodyHandlers.ofString())

request body:

{"languageIds":["fr","es-ES","ja","ko","zh-CN","vi","pt-BR","id","th","hi","ar-SA"],"fileIds":[57614],"method":"tm","translateWithPerfectMatchOnly":true,"translateUntranslatedOnly":true}

response:

{"data":{"identifier":"e0f82128-292d-475f-aeea-d66afbbb5712","status":"created","progress":0,"attributes":{"languageIds":["fr","es-ES","ja","ko","zh-CN","vi","pt-BR","id","th","hi","ar-SA"],"labelIds":null,"excludeLabelIds":null,"method":"tm","autoApproveOption":null,"duplicateTranslations":null,"skipApprovedTranslations":null,"translateUntranslatedOnly":true,"translateWithPerfectMatchOnly":true,"fallbackLanguages":null,"fileIds":[57614]},"createdAt":"2023-12-12T13:29:21+00:00","updatedAt":"2023-12-12T13:29:21+00:00","startedAt":null,"finishedAt":null,"eta":null}}

Hi @pavel.karpukhin ,

Thanks for the details! As far as I can see, the response is successful. However, in your request body, you have set the parameter “translateWithPerfectMatchOnly”:true, which means that only those strings that have a perfect match TM suggestion will receive the translation.

From my database, I can see that this file that you are applying pre-translation to has only 3 untranslated strings in French, for example, and none of them has a perfect match in the TM.

Thus, when running the Apply Pre-translation method, the response is successful, but there is nothing to apply. If you set the parameter “translateWithPerfectMatchOnly”:false, the translations will be applied when there are perfect match and not less than 100% match suggestions.

Hope this helps!

Hi, @taniam

Thanks for response!

I have tried to set translateWithPerfectMatchOnly to false.
Unfortunately, it is futile.

I added another string resource that has already been translated, and translation for this string exists in TM. Applying Pre-translation has still no results

@pavel.karpukhin ,

In the file with the ID 57614, there are only untranslated 3 strings. Two of them do not have TM suggestions at all, and the third one has the suggestion but its match ratio is 70%. In order for the translations to be applied, the match ratio needs to be 100%.

As for the second file, I do not see from our database any new files added recently. Could you please let me know its ID if it is the same project?

PROJECT_ID = 292597

Please, take a look at the attached screenshot.
I haven’t added new file. I have added text to existed file.
There are untranslated string resource and translation from TM that has 100% match

@pavel.karpukhin ,

Thanks! Let me please check everything with the team and get back to you.

Hi @pavel.karpukhin,

As far as I can see from our database, the string “Request a call” has already been translated using the TM. Could you please confirm if everything worked fine?

@TaniaM
Hi, apply pre-translate still doesn’t work

Dear Pavel,

As I can from the last message, pre-translation was applied. Could you please share details of what file are you trying to pre-translate this time, the request, and the response you are getting?

@NataliaS , Hi

I have added new file with name features_temp_string.xml
With single string: Call Requested

Request body:

{"languageIds":["fr","es-ES","ja","ko","zh-CN","vi","pt-BR","id","th","hi","ar-SA"],"fileIds":[59710],"method":"tm","translateWithPerfectMatchOnly":false,"translateUntranslatedOnly":true}

Response:

{"data":{"identifier":"283702b4-aa96-44a5-a779-6c9ae292d4c9","status":"created","attributes":{"languageIds":["fr","es-ES","ja","ko","zh-CN","vi","pt-BR","id","th","hi","ar-SA"],"fileIds":["59710"],"method":"tm","autoApproveOption":false,"duplicateTranslations":false,"translateUntranslatedOnly":true,"translateWithPerfectMatchOnly":false}}}

Then I open my project on crowdin website and see that features_temp_string.xml hasn’t been translated.

Dear Pavel,

Could you please try to run this string with pre-translate via IU? Just to check if the issue is related only to the API

@NataliaS
Done it.
Pre-translate via UI works perfectly

Thank you! We need to investigate case from our end

1 Like

@NataliaS
Hi!
Do you have any updates?

Hi @pavel.karpukhin ! let us double-check the progress with the team and get back to you

1 Like

Hi @pavel.karpukhin

Could you please tell me whether you used any duplicate options at the moment you tried to pre-translate the file?