javascriptphpjsongoogle-cloud-platform

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"
    }
}

Solution

  • 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.