在发送信息之前翻译值

Translate value before sending information

是否可以使用 google api 翻译或任何其他 api...
[=11 来翻译 php 中的值=]

<?php
   // 1.- Query to get information
   // 2.- build array with that query
   // Example array from query
   $data = array(
          '0' => array (
                   'name' => 'Zapatos',
                   'color' => 'Verde'
                 ),

          '1' => array (
                   'name' => 'Casa',
                   'color' => 'Rosa'
                 ),
           );
       // Now that the array has been build, lets make a translation
       // Which I have no idea how to do that but the final array should be

$final = array(
          '0' => array (
                   'name' => 'Zapatos',
                   'color' => 'Verde',
                   'name_en' => 'Shoes',
                   'color_en' => 'Green'
                 ),

          '1' => array (
                   'name' => 'Casa',
                   'color' => 'Rosa',
                   'name_en' => 'House',
                   'color_en' => 'Pink'
                 ),
           );

这个过程是可能的还是我只是在做梦?
我对 Goolge API 的工作原理知之甚少,因为我只使用 Google 翻译小部件,翻译是在您提供信息之后进行的,但在这种情况下,我们需要在提供信息之前进行翻译...

Google翻译API是付费服务。您需要从 google api 服务获取 api 密钥: google translate API

之后,您可以在从查询中获取结果后将 curl 设为 google api : 样本 url 为 curl : https://www.googleapis.com/language/translate/v2?key=INSERT-YOUR-KEY&source=en&target=de&q=Hello%20world&q=My%20name%20is%20Jeff

您将获得 JSON 对象的结果,执行 json_decode 并将结果添加到您的数组。