Array order of translation result

210 views
Skip to first unread message

tipotto 404

unread,
Mar 8, 2021, 3:32:10 AM3/8/21
to Google Cloud Translation API
Hi.

I'm thinking about using Cloud Translate API v2 with Node.js, and I have a question about translation result.

I'd like to translate multiple texts into a specific language in a request.

In that case, I think source texts need to be passed as an array to Translate.translate function.

Is it possible to receive array of translation result in the same order as before translation was executed?
Or does the order change randomly each time after translation?

I'd like to identify and get each translated text.

Thank you.


aurelien gerits

unread,
Mar 8, 2021, 9:59:15 AM3/8/21
to Google Cloud Translation API
In V2, we do not know how to translate several texts, only V3 allows it or by making several requests

tielve

unread,
Mar 10, 2021, 3:25:58 AM3/10/21
to Google Cloud Translation API
Hi,
It is correct, to translate multiple texts, you need the Advanced Translation (V3) using a TSV file (Rest resources if needed).
And the order is irrelevant because each text request will have its own ID whether you specify it in the first column or if you don't (when you don't, the row number (0-based) from the input file is used as the ID in the output file).

tipotto 404

unread,
Mar 10, 2021, 4:03:57 AM3/10/21
to Google Cloud Translation API
Thank you for your reply.

Okay.
I thought you could translate multiple texts according to this official document.
Check it out just in case, and tell me what you think about it.

However, there could be no way of identifying each translated text, as you only get result of array...

2021年3月8日月曜日 23:59:15 UTC+9 gerits....@gmail.com:

Kevin

unread,
Mar 10, 2021, 4:47:21 AM3/10/21
to Google Cloud Translation API

My apologies, you are right. I am so used of the V3 that I went a bit to fast here.
You can indeed translate multiple sentences with the V2 and the API does send you back the translated sentences in the same order. I just tested the sample in the documentation you shared, with a simple curl.

tipotto 404

unread,
Mar 11, 2021, 10:32:14 PM3/11/21
to Google Cloud Translation API
Thank you for your reply.

That's good to know. I'm going to use the API v2 then.
I appreciate your help.



2021年3月10日水曜日 18:47:21 UTC+9 Kevin:
Reply all
Reply to author
Forward
0 new messages