Google weather API assistance
Hej med jer.Jeg har lavet dette her script som viser vejret i 4 dage.
Jeg kan simpelthen ikke få den til at vise det på dansk, hvilket jeg har kunne med nogle andre scripts.
Nogle der kender til det som kan hjælpe så det bliver dansk sprog og danske grader?
<table>
<tr>
<td>
<?php
/*
Nutzung dieses Scripts nur gestattet, wenn Kommentare in PHP nicht entfernt werden oder ein Link zu folgender Adresse gesetzt wird:
URL: http://www.web-spirit.de/webdesign-tutorial/9/Wetter-auf-eigener-Website-mit-Google-Weahter-API
Beschreibung: Wettervorhersage auf der eigenen Website mit Zugriff auf die Google Weather API
Autor: Sebastian Gollus
Internet: http://www.web-spirit.de
Version: 1.0.201106
*/
// Funktionsaufruf z.B.: $wetter = website_wetter("46562", "Germany", "/images/wetter/icons/", "de");
$place = 'Varde'; // city where you want local weather
$lang = 2;
$url = 'http://www.google.dk/ig/api?weather=varde';
function website_wetter($plz, $land, $icons_src="/", $ort="")
{
$icons_google = "/ig/images/weather/"; //alte Google-Version
//$icons_google = "http://g0.gstatic.com/images/icons/onebox/"; //neue Google-Version (bzw. zwischenzeitlich geändert)
if($ort != "")
{
$station = $ort;
}
else
{
$station = $plz."-".$land;
}
$api = simplexml_load_string(utf8_encode(file_get_contents("http://www.google.com/ig/api?weather=varde")));
$wetter = array();
// Allgemeine Informationen
$wetter['stadt'] = $api->weather->forecast_information->city->attributes()->data;
$wetter['datum'] = $api->weather->forecast_information->forecast_date->attributes()->data;
$wetter['zeit'] = $api->weather->forecast_information->current_date_time->attributes()->data;
// Aktuelles Wetter
$wetter[0]['zustand'] = $api->weather->current_conditions->condition->attributes()->data;
$wetter[0]['temperatur'] = $api->weather->current_conditions->temp_c->attributes()->data;
$wetter[0]['luftfeuchtigkeit'] = $api->weather->current_conditions->humidity->attributes()->data;
$wetter[0]['wind'] = $api->weather->current_conditions->wind_condition->attributes()->data;
$wetter[0]['icon'] = str_replace($icons_google, $icons_src, $api->weather->current_conditions->icon->attributes()->data);
// Wettervorhersage heute, morgen, in zwei und in drei Tagen ($wetter[1] bis $wetter[4])
$i = 1;
foreach($api->weather->forecast_conditions as $weather)
{
$wetter[$i]['wochentag'] = $weather->day_of_week->attributes()->data;
$wetter[$i]['zustand'] = $weather->condition->attributes()->data;
$wetter[$i]['tiefsttemperatur'] = $weather->low->attributes()->data;
$wetter[$i]['hoechsttemperatur'] = $weather->high->attributes()->data;
$wetter[$i]['icon'] = str_replace($icons_google, $icons_src, $weather->icon->attributes()->data);
$i++;
}
return $wetter;
}
// Funktionsaufruf in Array
$wetter = website_wetter("Varde", "Denmark");
?>
<table>
<tr>
<td>
<?php
if ($wetter[$i]['wochentag'] == "man") {
$wetter[$i]['wochentag'] = "Mandag";
}
if ($wetter[$i]['wochentag'] == "Tue") {
$wetter[$i]['wochentag'] = "Tirsdag";
}
if ($day_of_week == "Wed") {
$day_of_week = "Onsdag";
}
if ($day_of_week == "tor") {
$day_of_week = "Torsdag";
}
if ($day_of_week == "fre") {
$day_of_week = "Fredag";
}
if ($day_of_week == "lor") {
$day_of_week = "Lørdag";
}
if ($day_of_week == "son") {
$day_of_week = "Søndag";
}
?>
</td>
<td>
<?php
echo "<p>";
echo "<strong>".$wetter[1]['wochentag']."</strong><br/>
";
echo $wetter[1]['zustand']."<br/>
";
echo "min. ".$wetter[1]['tiefsttemperatur']."° C | max. ".$wetter[1]['hoechsttemperatur']."° C<br/>
";
echo "<img src=\"http://www.skala.fm/ig/images/weather".$wetter[1]['icon']."\" alt=\"".$wetter[1]['zustand']."\" />
";
echo "</p>";
?>
</td>
<td>
<?php
echo "<p>";
echo "<strong>".$wetter[2]['wochentag']."</strong><br/>
";
echo $wetter[2]['zustand']."<br/>
";
echo "min. ".$wetter[2]['tiefsttemperatur']."° C | max. ".$wetter[2]['hoechsttemperatur']."° C<br/>
";
echo "<img src=\"http://www.skala.fm/ig/images/weather".$wetter[2]['icon']."\" alt=\"".$wetter[2]['zustand']."\" />
";
echo "</p>";
?>
</td>
<td>
<?php
echo "<p>";
echo "<strong>".$wetter[3]['wochentag']."</strong><br/>
";
echo $wetter[3]['zustand']."<br/>
";
echo "min. ".$wetter[3]['tiefsttemperatur']."° C | max. ".$wetter[3]['hoechsttemperatur']."° C<br/>
";
echo "<img src=\"http://www.skala.fm/ig/images/weather".$wetter[3]['icon']."\" alt=\"".$wetter[3]['zustand']."\" />
";
echo "</p>";
?>
</td>
<td>
<?php
echo "<p>";
echo "<strong>".$wetter[4]['wochentag']."</strong><br/>
";
echo $wetter[4]['zustand']."<br/>
";
echo "min. ".$wetter[4]['tiefsttemperatur']."° C | max. ".$wetter[4]['hoechsttemperatur']."° C<br/>
";
echo "<img src=\"http://www.skala.fm/ig/images/weather".$wetter[4]['icon']."\" alt=\"".$wetter[4]['zustand']."\" />
";
echo "</p>";
?>
</td>
</tr>
</table>