2016-11-22 4 views
0

내 사이트의 날짜는 영어로 표시되어 있습니다.러시아어로 요일 이름을 받으십시오.

어떻게 러시아어로 요일 이름을 얻을 수 있습니까?

JavaScript에서는 Tuesday-> Вторник를 코드로 대체하려고했지만 작동하지 않습니다.

코드 : 옵션으로

<?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> 

답변

1

, 당신은 wunderground API 호출을 변경할 수 있습니다. 언어 설정 /lang:xy을 포함하십시오. 이런 식으로 뭔가 :

https://api-ak-aws.wunderground.com/api/8dee7a0******/satellite/webcams/forecast/lang:RU/units:metric/v:2.0/q/CWEW.json 
1

당신은 같은 JSON 객체를 정의하는 시도 할 수 있습니다 : 대신 $arr['date']['weekday'] 사용 days[$arr['date']['weekday']]를 사용하여 다음

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

.

참고 : 실제로 php 구문을 알지 못합니다. 그러나 그와 같은 것이 작동해야합니다.