Translate JSON Excluding JS Template Literals

75 views
Skip to first unread message

Dasun Nirmitha

unread,
Sep 22, 2021, 11:19:11 AM9/22/21
to Google Cloud Translation API

Hello guys,
Can you suggest a surefire way to exclude JavaScript template literals when translating a JSON string that includes them?
For example, if my input JSON was:
{
"hello": "Hello ${name}!"
}
I want the JSON output translated to French to hold:
{
"hello": "Bonjour ${name}!"
}
API does execute this way when I try it, but there's no documentation on how the Cloud Translation API processes JS template literal syntax (  ${}  ), so I can't rely on it in a production-level application.

Nitish Sharma

unread,
Sep 24, 2021, 9:16:35 AM9/24/21
to Google Cloud Translation API
There could be multiple reasons for this to occur, One may be Engine couldn't find the exact translation for the entire literal, and return as it is. In that it could work.

Even i am a consumer of this service and i can tell you this, there is a cost associated with each letter/word send over to Translation engine, so its better to have the logic to remove these fillers outside of the request  and once translation content is back, put these filler back in original position. we have been doing the same and it has been working so far, reducing the cost.

I hope it helped.

Regards
Nitish

--
You received this message because you are subscribed to the Google Groups "Google Cloud Translation API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-translate...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-translate-api/4137ef3d-fa1e-4bd8-a268-43196a5307c6n%40googlegroups.com.


--
Thanks & Regards
Nitish Sharma
Mobile: 91-8552954140
Reply all
Reply to author
Forward
0 new messages