0

The day names on my site are in English.

How can I get the day names in Russian?

In JavaScript I tried to replace Tuesday->Вторник in code but it is not working.

Code:

<?php
$ip = $_SERVER['REMOTE_ADDR'];
$url = 'http://api.sypexgeo.net/xml/'. $ip .'';
$xml = simplexml_load_string(file_get_contents($url));
$loc_array = array($xml->ip->city->lat,$xml->ip->city->lon);
$loc_safe = array();
foreach($loc_array as $loc){
    $loc_safe[] = urlencode($loc);
}
$loc_string=implode(',', $loc_safe);
$json = file_get_contents('http://api.wunderground.com/api/232323***/satellite/webcams/forecast/q/' . $loc_string . '.json');
$obj = json_decode($json, true);    
?>    

<?

$html .= "</h2><table cellpadding=4 cellspacing=3><tr>";

    foreach ($obj['forecast']['simpleforecast']['forecastday'] as $arr) {

        $html .= "<td align='center'>" . $arr['date']['weekday'] . "<br />";
        $html .= "<img src='http://icons-pe.wxug.com/i/c/k/" . $arr['icon'] . ".gif' border=0 /><br />";
        $html .= "<font color='red'>" . $arr['high']['celsius'] . '&deg;C' . " </font>";
        $html .= "<font color='blue'>" . $arr['low']['celsius'] . '&deg;C' . "</font>";
        $html .= "</td>";    
    }
    $html .= "</tr></table>";

echo $html;
?>


<script type="text/javascript">

window.onload=function(){

//I try, but not replace
$("td:contains('Tuesday')").html("Вторник");      
};

</script>
ArK
  • 20,698
  • 67
  • 109
  • 136
user3331122
  • 969
  • 1
  • 7
  • 14

2 Answers2

1

As an option, you can change the call to wunderground API. Include language settings /lang:xy. Something like this:

https://api-ak-aws.wunderground.com/api/8dee7a0******/satellite/webcams/forecast/lang:RU/units:metric/v:2.0/q/CWEW.json
Andrey Borisko
  • 4,511
  • 2
  • 22
  • 31
1

You can try defining a JSON object like:

days = { "name of the day": "name of the day in Russian" }

Then instead of using $arr['date']['weekday'] use days[$arr['date']['weekday']].

Note: I don't know the php syntax actually, but something like that should work.

Bünyamin Sarıgül
  • 3,031
  • 4
  • 30
  • 55