I have modified $ Currentsolardescription but it does not translate in Spanish:
16:30 27.4ºC (Max 27ºC / Min 18ºC) Clear
This is the code I use:
Code: Select all
<<?php
/* TweetWX-conditions.php
This package is based on code by Joe Chung at http://nullinfo.wordpress.com/oauth-twitter/
Repackaged for TweetWX by Ken True - Saratoga-weather.org 08-Jun-2010
Docs at http://saratoga-weather.org/scripts-TweetWX.php
TweetWX-conditions.php V1.00 - 11-Jun-2010 - Initial relase
This utility function should be used once to get the OAuth request_token and request_token_secret
for use in the next step of setup.
*/
if (phpversion() < 5) {
echo 'Failure: This Script requires PHP version 5 or greater. You only have PHP version: ' . phpversion();
exit;
}
// --------------- settings ----------------------
require_once("Settings.php");
require_once("common.php");
$tweetWXdir = './';
$wxdir = './'; // path to the advforecast2.php
$tweetTags = '#Tiempo actual en #Sevilla Más información en www.tiempoensevilla.es'; // customize for your Twitter tags and/or website url (shortened)
// ----------- end settings ----------------------
require_once($tweetWXdir . 'TweetWX-globals.php');
// Fill in the next 2 variables from the values produced in TweetWX-setup2.php.
$access_token = ''; // oauth_token
$access_token_secret = ''; // oauth_token_secret
include_once($wxdir . 'CUtags.php');
$uomTemp = 'ºC';
$uomWind = $WX['windunit'];
$uomBaro = $WX['pressunit'];
$uomRain = $WX['rainunit'];
$dirlabel = $WX['wdir'];
$temperature = $WX['temp'];
$avgspd = $WX['wspeed'];
$maxgst = $WX['wgustTM'];
$baro = $WX['press'];
$dayrn = $WX['rfall'];
$time = substr($WX['time'],0,5);
$maxtemp = $WX['tempTH'];
$mintemp = $WX['tempTL'];
//$sTemp = round(strip_units($temperature),0);
$sHum = $WX['hum'];
$sWind = "$dirlabel " . round($avgspd,0)."->".round(strip_units($maxgst),0).$uomWind;
if (preg_match('|0->0|',$sWind) ){
$sWind = "Calma";
}
//$sBaro = sprintf("%01.1f",strip_units($baro));
//$sRain = sprintf("%01.1f",strip_units($dayrn));
$message = fixup_time($time)." $temperature$uomTemp (Max ".round(strip_units($maxtemp),0)."$uomTemp/Min ".round(strip_units($mintemp),0).
"$uomTemp) $Currentsolardescription Hum: $sHum% Viento: $sWind ".
"Presión: $baro$uomBaro Lluvia: $dayrn$uomRain-";
$message .= ' ' . $tweetTags;
$message = trim($message);
if (strlen($message) > 200) {
echo $message . ' too long ('.strlen($message). ") -- reducing size<br/>\n";
$message = preg_replace('|Mostly cloudy with clear patches|is','Mostly Cloudy',$message);
$message = preg_replace('|Scattered|is','Sctd',$message);
}
echo $message."<br/>len=".strlen($message)."<br/>status=";
$utfmessage = iconv('ISO-8859-1','UTF-8',$message);
// POST a tweet using OAuth authentication
$retarr = post_tweet(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET,
$utfmessage, $access_token, $access_token_secret,
true, true);
// print_r($retarr);
exit(0);
//=========================================================================
// change the hh:mm AM/PM to h:mmam/pm format
function fixup_time ( $WDtime ) {
//if ($WDtime == "00:00: AM") { return ''; }
//$WDtime = preg_replace('|^00:|','12:',$WDtime);
return date('G:i' , strtotime($WDtime));
}
//
function fixupCondition( $inCond ) {
global $DebugMode;
$Cond = str_replace('_',' ',$inCond);
$Cond = strtolower($Cond);
$Cond = preg_replace('| -|','',$Cond);
$Cond = trim($Cond);
$dt = '';
$vals = array();
if(strpos($Cond,'/') !==false) {
$dt .= "<!-- vals split on slash -->\n";
$vals = explode("/",$Cond);
}
if(strpos($Cond,',') !==false) {
$dt .= "<!-- vals split on comma -->\n";
$vals = explode(",",$Cond);
}
$ocnt = count($vals);
if($ocnt < 1) { return(langtransstr(trim($inCond))); }
foreach ($vals as $k => $v) {
if($DebugMode) { $dt .= "<!-- v='$v' -->\n"; }
$v = ucfirst(strtolower(trim($v)));
$vals[$k] = langtransstr($v);
if($DebugMode) { $dt .= "<!-- vals[$k]='".$vals[$k]."' -->\n"; }
}
if($vals[0] == '') {$junk = array_shift($vals);}
if(isset($vals[2]) and $vals[0] == $vals[2]) {$junk = array_pop($vals);}
reset($vals);
$t = join(', ',$vals);
// return($Cond . "' orig=$ocnt n=" . count($vals) ." t='$t'");
if($DebugMode) {
$Currentsolardescription = "<!-- fixupCondition in='$inCond' out='$Currentsolardescription' ocnt='$ocnt' -->" . $dt . $Currentsolardescription;
}
return($Currentsolardescription);
}
//=========================================================================
// strip trailing units from a measurement
// i.e. '30.01 in. Hg' becomes '30.01'
function strip_units ($data) {
preg_match('/([\d\.\+\-]+)/',$data,$t);
return $t[1];
}
?>
http://tiempoensevilla.es/wxcunow.php
Thank you,
Regards,
Jose Ramon