function weather_format_condition in Weather 7.2
Same name and namespace in other branches
- 7.3 weather_theme.inc \weather_format_condition()
Returns weather condition as translated text from yr.no symbol number.
Parameters
mixed $condition_no: The weather condition number from yr.no.
Return value
string Translated text with corresponding weather condition
2 calls to weather_format_condition()
- theme_weather_forecast_preprocess in ./
weather_theme.inc - Custom theme function for preprocessing the weather display.
- weather_handler_condition::render in views_handlers/
weather_handler_condition.inc - Render translated condition or <img> tag.
File
- ./
weather_theme.inc, line 94 - Prepare themed weather output.
Code
function weather_format_condition($condition_no) {
// Strip the suffix "d", "n", and "m".
// (day, night, mørketid -> polar night)
$condition_no = substr($condition_no, 0, 2);
$conditions = array(
'null' => t('No data'),
'01' => t('Clear sky'),
'02' => t('Fair'),
'03' => t('Partly cloudy'),
'04' => t('Cloudy'),
'05' => t('Rain showers'),
'06' => t('Rain showers and thunder'),
'07' => t('Sleet showers'),
'08' => t('Snow showers'),
'09' => t('Rain'),
'10' => t('Heavy rain'),
'11' => t('Heavy rain and thunder'),
'12' => t('Sleet'),
'13' => t('Snow'),
'14' => t('Snow and thunder'),
'15' => t('Fog'),
'20' => t('Sleet showers and thunder'),
'21' => t('Snow showers and thunder'),
'22' => t('Rain and thunder'),
'23' => t('Sleet and thunder'),
'24' => t('Light rain showers and thunder'),
'25' => t('Heavy rain showers and thunder'),
'26' => t('Light sleet showers and thunder'),
'27' => t('Heavy sleet showers and thunder'),
'28' => t('Light snow showers and thunder'),
'29' => t('Heavy snow showers and thunder'),
'30' => t('Light rain and thunder'),
'31' => t('Light sleet and thunder'),
'32' => t('Heavy sleet and thunder'),
'33' => t('Light snow and thunder'),
'34' => t('Heavy snow and thunder'),
'40' => t('Light rain showers'),
'41' => t('Heavy rain showers'),
'42' => t('Light sleet showers'),
'43' => t('Heavy sleet showers'),
'44' => t('Light snow showers'),
'45' => t('Heavy snow showers'),
'46' => t('Light rain'),
'47' => t('Light sleet'),
'48' => t('Heavy sleet'),
'49' => t('Light snow'),
'50' => t('Heavy snow'),
);
if (!array_key_exists($condition_no, $conditions)) {
$condition_no = 'null';
}
return $conditions[$condition_no];
}