Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud translate JSON file

I would like to translate the fields of a composite JSON object using Google Cloud Platform, instead of translating every single sentence on its own. Is it possible?

Example (from English to Italian):

Origin JSON file:

{job_description: {
    name: "Taxi driver",
    description: "like the movie"
    }
}

Output JSON file:

{job_description: {
    name: "Tassista",
    description: "Come nel film"
    }
}
like image 337
Andrea Grippi Avatar asked Aug 23 '26 10:08

Andrea Grippi


2 Answers

Here is a script I wrote to achieve this. Hope this helps someone. https://github.com/EisenVault/json-google-translate

like image 187
Vipul Swarup Avatar answered Aug 24 '26 22:08

Vipul Swarup


Translation API accepts only plain-text or HTML as a format [1].

To achieve your goal, load your JSON file as an object in your code, send the fields to the Translation API, edit the object with the translation result and then generate a JSON file from your new object.

like image 39
Yurci Avatar answered Aug 24 '26 22:08

Yurci



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!