Weather by You!

Templates and Projects support => Modules => Topic started by: saratogaWX on October 16, 2012, 10:02:14 PM

Title: WeatherUnderground forecast with translations...
Post by: saratogaWX on October 16, 2012, 10:02:14 PM
Jacques has done a great job integrating my WU-forecast.php script into the Weather Blue 2 template set.  Because the WU-forecast.php script does a default translation from UTF-8 to ISO-8859-1 character set, and the Weather Blue template uses UTF-8 natively, there can be issues displaying non-English forecasts.  Also, for non-English forecasts that contain more than three words, the WU icon name is used with English text under the icon displayed.  That English text would normally be translated in the Saratoga template set, but since Jacques uses a very different method for translation files, the WU English text remained just English.

I wrote a 'shim' program to establish the environment for WU-forecast so that translations and proper UTF-8 output could be provided for the Weather Blue 2 template.

To use it, the text_standard_LL.php file needs new variables
Code: [Select]
$Tr_Chance_flurries = 'Chance flurries';
$Tr_Chance_rain = 'Chance rain';
$Tr_Chance_sleet = 'Chance sleet';
$Tr_Chance_snow = 'Chance snow';
$Tr_Chance_thunderstorms = 'Chance thunderstorms';
$Tr_Clear = 'Clear';
$Tr_Cloudy = 'Cloudy';
$Tr_Flurries = 'Flurries';
$Tr_Fog = 'Fog';
$Tr_Hazy = 'Hazy';
$Tr_Mostly_cloudy = 'Mostly cloudy';
$Tr_Partly_cloudy = 'Partly cloudy';
$Tr_Mostly_sunny = 'Mostly sunny';
$Tr_Rain = 'Rain';
$Tr_Sleet = 'Sleet';
$Tr_Snow = 'Snow';
$Tr_Sunny = 'Sunny';
$Tr_Thunderstorms = 'Thunderstorms';
with the LL target language replacing the English word(s) in the variable definitions.

Like for French in text_standard_fr.php,

$Tr_Clear = 'Ciel dégagé';

and remember to use UTF-8 character set for the translation.

Then download the attached Saratoga-translation.php.txt file and upload it as Saratoga-translation.php  to your ./include/ directory.

Then change your forecast_wu.php page from
Code: [Select]
<?php
// That is what we call a php file inclusion
// WU forecast is takin place in that "hole" in your page
include('include/WU-forecast.php');
?>

to
Code: [Select]
<?php
// That is what we call a php file inclusion
// WU forecast is takin place in that "hole" in your page
$_REQUEST['lang'] = $lang// send WUforecast the language
include_once("include/Saratoga-translate.php");
include('include/WU-forecast.php');
?>

and your forecast should support the translations.

You can also specify multiple forecasts by using
Code: [Select]
<?php
// That is what we call a php file inclusion
// WU forecast is takin place in that "hole" in your page
$_REQUEST['lang'] = $lang// send WUforecast the language
include_once("include/Saratoga-translate.php");
global $SITE;
$SITE['WUforecasts'] = array(
 
// Location|forecast-URL  (separated by | characters
'Saratoga|http://www.wunderground.com/cgi-bin/findweather/hdfForecast?query=95070',
'Vamdrup|http://www.wunderground.com/global/stations/06108.html'// Vamdrup, Denmark
'Amsterdam|http://www.wunderground.com/cgi-bin/findweather/getForecast?query=Amsterdam%2C+Netherlands',
'Paris|http://www.wunderground.com/cgi-bin/findweather/getForecast?query=Paris%2C+France',
'Stockholm|http://www.wunderground.com/cgi-bin/findweather/getForecast?query=Stockholm%2C+Sweden',
'Oslo|http://www.wunderground.com/cgi-bin/findweather/getForecast?query=Oslo%2C+Norway',
'Moscow|http://www.wunderground.com/cgi-bin/findweather/getForecast?query=Moscow%2C+Russia',
'Athens|http://www.wunderground.com/cgi-bin/findweather/getForecast?query=Athens%2C+Greece',
'Tel Aviv|http://www.wunderground.com/cgi-bin/findweather/getForecast?query=Tel+Aviv%2C+Israel',
'Madrid|http://www.wunderground.com/cgi-bin/findweather/getForecast?query=Madrid%2C+Spain',
'Helsinki|http://www.wunderground.com/cgi-bin/findweather/getForecast?query=Helsinki%2C+Finland',
 
'Krakow|http://polish.wunderground.com/cgi-bin/findweather/getForecast?query=Krakow%2C+Poland',
 
'Florence|http://www.wunderground.com/cgi-bin/findweather/getForecast?query=zmw:00000.1.16170',
); 

include('include/WU-forecast.php');
?>
and the first entry will be the default forecast location.

You can see my working copy at http://saratoga-weather.org/WB2/forecast_wu.php

Enjoy...

Best regards,
Ken



Title: Re: WeatherUnderground forecast with translations...
Post by: Mr.Meteo on October 16, 2012, 10:12:08 PM
Hi Ken,

Thanks to take time to do this adaptation!

You're doing a so great job appreciated by a wide community!
Taking time to adapt your wonderful job to other templates prove
your "greatnesss" in all amateur weather personnal sites
(not only on Cumulus as I seen elsewhere!)

A lot of thanks  you're a great guy!  ;)

Kind regards,
Jacques
Title: Re: WeatherUnderground forecast with translations...
Post by: saratogaWX on October 16, 2012, 10:58:18 PM
Hi Jacques,

Thank you very much for the high praise  :-[

I am always pleased to have my scripts be useful for weather enthusiasts worldwide, and my template set is just one vehicle that has helped many get started with a functional weather website -- your Weather Blues template is very good and I'm glad to support the functionality of it .. it was about a 2 hour exercise to generate the 'shim' code to release the multi-lingual capabilities of the WU-forecast.php script for use with your template set.

Feel free to include the Saratoga-translation.php script in your distribution if you like, and I'm assuming you will get your translation partners to add the translations to the supported language sets.

Best regards,
Ken
Title: Re: WeatherUnderground forecast with translations...
Post by: asujikungzx on September 02, 2014, 04:21:18 AM
It is interesting to me. Because it is a lot of good information on this subject up.
Title: Re: WeatherUnderground forecast with translations...
Post by: Mr.Meteo on September 03, 2014, 05:11:29 PM
Hi,

Ken is very kind to help us with the integration of its wonderful work!  ^-^

Regards,
Jacques