I buid a live score website using Laravel and React template, I use an API to get live data with json format like this :
[
{
"country_id": "6",
"country_name": "Spain",
"league_id": "300",
"league_name": "Copa del Rey",
"league_season": "2020/2021",
"league_logo": "https://apiv3.apifootball.com/badges/logo_leagues/300_copa-del-rey.png",
"country_logo": "https://apiv3.apifootball.com/badges/logo_country/6_spain.png"
},
{
"country_id": "6",
"country_name": "Spain",
"league_id": "302",
"league_name": "La Liga",
"league_season": "2020/2021",
"league_logo": "https://apiv3.apifootball.com/badges/logo_leagues/302_la-liga.png",
"country_logo": "https://apiv3.apifootball.com/badges/logo_country/6_spain.png"
},
And I do like that to get values :
$APIkey='xxxxxxxxxxxxxx';
$country_id = 6;
$curl_options = array(
CURLOPT_URL => "https://apiv3.apifootball.com/?
action=get_leagues&country_id=$country_id&APIkey=$APIkey",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => false,
CURLOPT_TIMEOUT => 30,
CURLOPT_CONNECTTIMEOUT => 5
);
$curl = curl_init();
curl_setopt_array( $curl, $curl_options );
$result = curl_exec( $curl );
$result = (array) json_decode($result);
var_dump($result);
What I’m looking for is to do translations of some specific json fields before displaying it in frontend, I clarify my idea like that:
------------------------------------------------------------------------
JSON file from API ======> make translations ===>displaying in view
||
||
getting translations words from database
for example Copa del Rey translate it to Coupe du Roi who this word stored in database in french language?
Any Ideas?