2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

59_Weather: italian translations and other (forum #87080)

git-svn-id: https://svn.fhem.de/fhem/trunk@16641 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
borisneubert 2018-04-21 12:28:38 +00:00
parent 24338c303a
commit dd66265a2b
8 changed files with 206 additions and 139 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- feature: 59_Weather: italian translations and other (forum #87080)
- feature: 49_SSCam: V3.9.1, PTZ control panel added, please consider
attributes "ptzPanel_.*" and command "createPTZcontrol"
- bugfix: 93_DbRep: V7.17.1, sqlCmd can't use §timestamp_begin§

View File

@ -36,20 +36,34 @@ my %pressure_trend_txt_de = ( 0 => "gleichbleibend", 1 => "steigend", 2 => "fall
my %pressure_trend_txt_nl = ( 0 => "stabiel", 1 => "stijgend", 2 => "dalend" );
my %pressure_trend_txt_fr = ( 0 => "stable", 1 => "croissant", 2 => "décroissant" );
my %pressure_trend_txt_pl = ( 0 => "stabilne", 1 => "rośnie", 2 => "spada" );
my %pressure_trend_txt_it = ( 0 => "stabile", 1 => "in aumento", 2 => "in diminuzione" );
my %pressure_trend_sym = ( 0 => "=", 1 => "+", 2 => "-" );
my @directions_txt_en = ('N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW');
my @directions_txt_de = ('N', 'NNO', 'NO', 'ONO', 'O', 'OSO', 'SO', 'SSO', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW');
my @directions_txt_nl = ('N', 'NNO', 'NO', 'ONO', 'O', 'OZO', 'ZO', 'ZZO', 'Z', 'ZZW', 'ZW', 'WZW', 'W', 'WNW', 'NW', 'NNW');
my @directions_txt_fr = ('N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSO', 'SO', 'OSO', 'O', 'ONO', 'NO', 'NNO');
my @directions_txt_pl = ('N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW');
my @directions_txt_it = ('N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSO', 'SO', 'OSO', 'O', 'ONO', 'NO', 'NNO');
my %wdays_txt_en = ('Mon' => 'Mon', 'Tue' => 'Tue', 'Wed'=> 'Wed', 'Thu' => 'Thu', 'Fri' => 'Fri', 'Sat' => 'Sat', 'Sun' => 'Sun');
my %wdays_txt_de = ('Mon' => 'Mo', 'Tue' => 'Di', 'Wed'=> 'Mi', 'Thu' => 'Do', 'Fri' => 'Fr', 'Sat' => 'Sa', 'Sun' => 'So');
my %wdays_txt_nl = ('Mon' => 'Maa', 'Tue' => 'Din', 'Wed'=> 'Woe', 'Thu' => 'Don', 'Fri' => 'Vri', 'Sat' => 'Zat', 'Sun' => 'Zon');
my %wdays_txt_fr= ('Mon' => 'Lun', 'Tue' => 'Mar', 'Wed'=> 'Mer', 'Thu' => 'Jeu', 'Fri' => 'Ven', 'Sat' => 'Sam', 'Sun' => 'Dim');
my %wdays_txt_pl = ('Mon' => 'Pon', 'Tue' => 'Wt', 'Wed'=> 'Śr', 'Thu' => 'Czw', 'Fri' => 'Pt', 'Sat' => 'Sob', 'Sun' => 'Nie');
my %wdays_txt_it = ('Mon' => 'Lun', 'Tue' => 'Mar', 'Wed'=> 'Mer', 'Thu' => 'Gio', 'Fri' => 'Ven', 'Sat' => 'Sab', 'Sun' => 'Dom');
my %status_items_txt_en = ( 0 => "Wind", 1 => "Humidity", 2 => "Temperature", 3 => "Right Now", 4 => "Weather forecast for " );
my %status_items_txt_de = ( 0 => "Wind", 1 => "Feuchtigkeit", 2 => "Temperatur", 3 => "Jetzt Sofort", 4 => "Wettervorhersage für " );
my %status_items_txt_nl = ( 0 => "Wind", 1 => "Vochtigheid", 2 => "Temperatuur", 3 => "Direct", 4 => "Weersvoorspelling voor " );
my %status_items_txt_fr = ( 0 => "Vent", 1 => "Humidité", 2 => "Température", 3 => "Maintenant", 4 => "Prévisions météo pour " );
my %status_items_txt_pl = ( 0 => "Wiatr", 1 => "Wilgotność", 2 => "Temperatura", 3 => "Teraz", 4 => "Prognoza pogody w " );
my %status_items_txt_it = ( 0 => "Vento", 1 => "Umidità", 2 => "Temperatura", 3 => "Adesso", 4 => "Previsioni del tempo per " );
my %wdays_txt_i18n;
my @directions_txt_i18n;
my %pressure_trend_txt_i18n;
my %status_items_txt_i18n;
my @iconlist = (
'storm', 'storm', 'storm', 'thunderstorm', 'thunderstorm', 'rainsnow',
@ -61,6 +75,43 @@ my @iconlist = (
'sunny', 'scatteredthunderstorms', 'scatteredthunderstorms', 'scatteredthunderstorms', 'scatteredshowers', 'heavysnow',
'chance_of_snow', 'heavysnow', 'partly_cloudy', 'heavyrain', 'chance_of_snow', 'scatteredshowers');
###################################
sub Weather_LanguageInitialize($) {
my ($lang) = @_;
if($lang eq "de") {
%wdays_txt_i18n= %wdays_txt_de;
@directions_txt_i18n= @directions_txt_de;
%pressure_trend_txt_i18n= %pressure_trend_txt_de;
%status_items_txt_i18n= %status_items_txt_de;
} elsif($lang eq "nl") {
%wdays_txt_i18n= %wdays_txt_nl;
@directions_txt_i18n= @directions_txt_nl;
%pressure_trend_txt_i18n= %pressure_trend_txt_nl;
%status_items_txt_i18n= %status_items_txt_nl;
} elsif($lang eq "fr") {
%wdays_txt_i18n= %wdays_txt_fr;
@directions_txt_i18n= @directions_txt_fr;
%pressure_trend_txt_i18n= %pressure_trend_txt_fr;
%status_items_txt_i18n= %status_items_txt_fr;
} elsif($lang eq "pl") {
%wdays_txt_i18n= %wdays_txt_pl;
@directions_txt_i18n= @directions_txt_pl;
%pressure_trend_txt_i18n= %pressure_trend_txt_pl;
%status_items_txt_i18n= %status_items_txt_pl;
} elsif($lang eq "it") {
%wdays_txt_i18n= %wdays_txt_it;
@directions_txt_i18n= @directions_txt_it;
%pressure_trend_txt_i18n= %pressure_trend_txt_it;
%status_items_txt_i18n= %status_items_txt_it;
} else {
%wdays_txt_i18n= %wdays_txt_en;
@directions_txt_i18n= @directions_txt_en;
%pressure_trend_txt_i18n= %pressure_trend_txt_en;
%status_items_txt_i18n= %status_items_txt_en;
}
}
###################################
sub Weather_DebugCodes($) {
@ -173,31 +224,6 @@ sub Weather_RetrieveDataFinished($$$) {
#
my $lang= $hash->{LANG};
my %wdays_txt_i18n;
my @directions_txt_i18n;
my %pressure_trend_txt_i18n;
if($lang eq "de") {
%wdays_txt_i18n= %wdays_txt_de;
@directions_txt_i18n= @directions_txt_de;
%pressure_trend_txt_i18n= %pressure_trend_txt_de;
} elsif($lang eq "nl") {
%wdays_txt_i18n= %wdays_txt_nl;
@directions_txt_i18n= @directions_txt_nl;
%pressure_trend_txt_i18n= %pressure_trend_txt_nl;
} elsif($lang eq "fr") {
%wdays_txt_i18n= %wdays_txt_fr;
@directions_txt_i18n= @directions_txt_fr;
%pressure_trend_txt_i18n= %pressure_trend_txt_fr;
} elsif($lang eq "pl") {
%wdays_txt_i18n= %wdays_txt_pl;
@directions_txt_i18n= @directions_txt_pl;
%pressure_trend_txt_i18n= %pressure_trend_txt_pl;
} else {
%wdays_txt_i18n= %wdays_txt_en;
@directions_txt_i18n= @directions_txt_en;
%pressure_trend_txt_i18n= %pressure_trend_txt_en;
}
my @YahooCodes_i18n= YahooWeatherAPI_getYahooCodes($lang);
my $item= $data->{item};
@ -211,8 +237,6 @@ sub Weather_RetrieveDataFinished($$$) {
delete($hash->{READINGS}{unit_pressuree}) if(defined($hash->{READINGS}{unit_pressuree}));
delete($hash->{READINGS}{unit_temperature}) if(defined($hash->{READINGS}{unit_temperature}));
# convert to metric units as far as required
my $isConverted= YahooWeatherAPI_ConvertChannelData($data);
@ -256,7 +280,6 @@ sub Weather_RetrieveDataFinished($$$) {
readingsBulkUpdate($hash, "pressure_trend_txt", $pressure_trend_txt_i18n{$pressure_trend});
readingsBulkUpdate($hash, "pressure_trend_sym", $pressure_trend_sym{$pressure_trend});
# condition
my $date= $item->{condition}{date};
readingsBulkUpdate($hash, "current_date_time", $date);
@ -285,11 +308,11 @@ sub Weather_RetrieveDataFinished($$$) {
readingsBulkUpdate($hash, $f . "icon", $iconlist[$fccode]);
}
#my $val= "T:$temp°C " . substr($status_items_txt_i18n{1}, 0, 1) .":$humidity% " . substr($status_items_txt_i18n{0}, 0, 1) . ":$windspeed km/h P:$pressure mbar";
my $val= "T: $temp H: $humidity W: $windspeed P: $pressure";
Log3 $hash, 4, "$name: $val";
readingsBulkUpdate($hash, "state", $val);
readingsEndUpdate($hash, $doTrigger);
Weather_RearmTimer($hash, gettimeofday()+$hash->{INTERVAL});
@ -429,7 +452,7 @@ sub Weather_Define($$) {
} else {
my @a = split("[ \t][ \t]*", $def);
return "syntax: define <name> Weather <location> [interval [en|de|nl]]"
return "syntax: define <name> Weather <location> [interval [en|de|nl|fr|pl|it]]"
if(int(@a) < 3 && int(@a) > 5);
$name = $a[0];
@ -461,6 +484,8 @@ sub Weather_Define($$) {
$hash->{fhem}{allowCache}= 1;
Weather_LanguageInitialize($lang);
Weather_GetUpdate($hash) if($init_done);
return undef;
@ -496,29 +521,45 @@ WeatherIconIMGTag($) {
}
# number of items for forecast
# 6 => 5 days, 11 => 10 days
# day 0 is 'now', 1 to 10 are forecast
#
use constant FORECASTSIZE => 11;
use constant MAXFORECASTS => 11;
#####################################
sub
WeatherAsHtmlV($;$)
WeatherAsHtmlV($;$;$)
{
my ($d,$items) = @_;
my ($d,$items,$pt) = @_;
$d = "<none>" if(!$d);
$items = 10 if( !$items );
return "$d is not a Weather instance<br>"
$items = int(FORECASTSIZE) if( !$items );
# check number of items
$items = int(FORECASTSIZE) if( $items > int(MAXFORECASTS));
return "$d is not a Weather instance<br/>"
if(!$defs{$d} || $defs{$d}{TYPE} ne "Weather");
$pt = 0 if( !$pt );
my $width= int(ICONSCALE*ICONWIDTH);
my $ret = '<table class="weather">';
$ret .= sprintf('<tr><td class="weatherIcon" width=%d>%s</td><td class="weatherValue">%s<br>%s°C %s%%<br>%s</td></tr>',
my $ret = '<table class="block">'; #class="weather" style="table-layout:fixed"
$ret .= sprintf('<tr><td style="text-align:left" colspan=2>%s%s</td></tr>', "$status_items_txt_i18n{4}", ReadingsVal($d, "city", ""))
if ($pt ne 0);
$ret .= sprintf('<tr><td class="weatherIcon" style="width:%dpx;text-align:center">%s</td><td class="weatherValue">%s: %s<br>%s°C %s%%<br>%s</td></tr>',
$width,
WeatherIconIMGTag(ReadingsVal($d, "icon", "")),
"$status_items_txt_i18n{3}",
ReadingsVal($d, "condition", ""),
ReadingsVal($d, "temp_c", ""), ReadingsVal($d, "humidity", ""),
"$status_items_txt_i18n{2}: " . ReadingsVal($d, "temp_c", ""),
"$status_items_txt_i18n{1}: " . ReadingsVal($d, "humidity", ""),
ReadingsVal($d, "wind_condition", ""));
for(my $i=1; $i<$items; $i++) {
$ret .= sprintf('<tr><td class="weatherIcon" width=%d>%s</td><td class="weatherValue"><span class="weatherDay">%s: %s</span><br><span class="weatherMin">min %s°C</span> <span class="weatherMax">max %s°C</span></td></tr>',
$ret .= sprintf('<tr><td class="weatherIcon" style="width:%dpx;text-align:left">%s</td><td class="weatherValue"><span class="weatherDay">%s: %s</span><br><span class="weatherMin">min %s°C</span> <span class="weatherMax">max %s°C</span></td></tr>',
$width,
WeatherIconIMGTag(ReadingsVal($d, "fc${i}_icon", "")),
ReadingsVal($d, "fc${i}_day_of_week", ""),
@ -526,44 +567,46 @@ WeatherAsHtmlV($;$)
ReadingsVal($d, "fc${i}_low_c", ""), ReadingsVal($d, "fc${i}_high_c", ""));
}
$ret .= "</table>";
$ret .= "</table><br/>";
return $ret;
}
sub
WeatherAsHtml($;$)
WeatherAsHtml($;$;$)
{
my ($d,$i) = @_;
WeatherAsHtmlV($d,$i);
my ($d,$i,$p) = @_;
WeatherAsHtmlV($d,$i,$p);
}
sub
WeatherAsHtmlH($;$)
WeatherAsHtmlH($;$;$)
{
my ($d,$items) = @_;
my ($d,$items,$pt) = @_;
$d = "<none>" if(!$d);
$items = 10 if( !$items );
$items = int(FORECASTSIZE) if( !$items );
#chek number of items
$items = int(FORECASTSIZE) if( $items > int(MAXFORECASTS));
return "$d is not a Weather instance<br>"
if(!$defs{$d} || $defs{$d}{TYPE} ne "Weather");
$pt = 0 if( !$pt );
my $width= int(ICONSCALE*ICONWIDTH);
my $ret = '<table class="block wide" style="table-layout:fixed">'; #class="weather"
my $format= '<td><table border=1><tr><td class="weatherIcon" width=%d>%s</td></tr><tr><td class="weatherValue">%s</td></tr><tr><td class="weatherValue">%s°C %s%%</td></tr><tr><td class="weatherValue">%s</td></tr></table></td>';
my $ret = '<table class="weather">';
$ret .= sprintf('<tr><td style="text-align:left" colspan=%d>%s%s</td></tr>', $items, "$status_items_txt_i18n{4}", ReadingsVal($d, "city", ""))
if ($pt ne 0);
# icons
$ret .= sprintf('<tr><td class="weatherIcon" width=%d>%s</td>', $width, WeatherIconIMGTag(ReadingsVal($d, "icon", "")));
$ret .= sprintf('<tr><td class="weatherIcon" style="width:%dpx;text-align:center">%s</td>', $width, WeatherIconIMGTag(ReadingsVal($d, "icon", "")));
for(my $i=1; $i<$items; $i++) {
$ret .= sprintf('<td class="weatherIcon" width=%d>%s</td>', $width, WeatherIconIMGTag(ReadingsVal($d, "fc${i}_icon", "")));
$ret .= sprintf('<td class="weatherIcon" style="width:%dpx;text-align:center">%s</td>', $width, WeatherIconIMGTag(ReadingsVal($d, "fc${i}_icon", "")));
}
$ret .= '</tr>';
# condition
$ret .= sprintf('<tr><td class="weatherDay">%s</td>', ReadingsVal($d, "condition", ""));
$ret .= sprintf('<tr><td class="weatherDay">%s: %s</td>', "$status_items_txt_i18n{3}", ReadingsVal($d, "condition", ""));
for(my $i=1; $i<$items; $i++) {
$ret .= sprintf('<td class="weatherDay">%s: %s</td>', ReadingsVal($d, "fc${i}_day_of_week", ""),
ReadingsVal($d, "fc${i}_condition", ""));
@ -571,7 +614,7 @@ WeatherAsHtmlH($;$)
$ret .= '</tr>';
# temp/hum | min
$ret .= sprintf('<tr><td class="weatherMin">%s°C %s%%</td>', ReadingsVal($d, "temp_c", ""), ReadingsVal($d, "humidity", ""));
$ret .= sprintf('<tr><td class="weatherMin">%s°C %s%%</td>', "$status_items_txt_i18n{2}: " . ReadingsVal($d, "temp_c", ""), "$status_items_txt_i18n{1}: " . ReadingsVal($d, "humidity", ""));
for(my $i=1; $i<$items; $i++) {
$ret .= sprintf('<td class="weatherMin">min %s°C</td>', ReadingsVal($d, "fc${i}_low_c", ""));
}
@ -583,18 +626,19 @@ WeatherAsHtmlH($;$)
$ret .= sprintf('<td class="weatherMax">max %s°C</td>', ReadingsVal($d, "fc${i}_high_c", ""));
}
$ret .= "</tr></table>";
$ret .= "</table><br/>";
return $ret;
}
sub
WeatherAsHtmlD($;$)
WeatherAsHtmlD($;$;$)
{
my ($d,$i) = @_;
my ($d,$i,$p) = @_;
if($FW_ss) {
WeatherAsHtmlV($d,$i);
WeatherAsHtmlV($d,$i,$p);
} else {
WeatherAsHtmlH($d,$i);
WeatherAsHtmlH($d,$i,$p);
}
}
@ -637,6 +681,7 @@ WeatherAsHtmlD($;$)
<code>pl</code>,
<code>fr</code>,
<code>nl</code>,
<code>it</code>,
It determines the natural language in which the forecast information appears.
It defaults to <code>en</code>. If you want to set the language you also have to set the interval.<br><br>

View File

@ -131,6 +131,25 @@ my @YahooCodes_pl = (
'gorąco', 'gdzieniegdzie burze', 'burze', 'burze', 'przelotne opady śniegu', 'duże opady śniegu',
'ciężkie opady śniegu', 'dużo śniegu', 'częściowe zachmurzenie', 'burze z deszczem', 'opady śniegu', 'przejściowo burze');
my @YahooCodes_it = (
'tromba d\'aria', 'tempesta tropicale', 'uragano', 'temporali di grande intensità', 'temporali', 'pioggia mista e neve',
'pioggia mista e nevischio', 'neve mista e nevischio', 'pioggia gelata', 'pioggia leggera', 'grandine' ,'rovesci',
'piogge', 'raffiche di neve', 'deboli nevicate', 'bufera di neve', 'neve', 'grandine',
'nevischio', 'pulviscolo', 'nebbia', 'foschia', 'smog', 'ventoso',
'ventoso', 'freddo', 'nuvoloso',
'parzialmente nuvoloso', # night
'parzialmente nuvoloso', # day
'parzialmente nuvoloso', # night
'parzialmente nuvoloso', # day
'sereno',
'soleggiato',
'bel tempo', #night
'bel tempo', #day
'pioggia mista a grandine',
'caldo', 'temporali isolati', 'temporali sparsi', 'temporali sparsi', 'piogge sparse', 'forti nevicate',
'nevicate sparse', 'forti nevicate', 'parzialmente nuvoloso', 'rovesci temporaleschi', 'rovesci di neve', 'temporali isolati');
###################################
# Cache
@ -343,6 +362,8 @@ sub YahooWeatherAPI_getYahooCodes($) {
return @YahooCodes_fr;
} elsif($lang eq "pl") {
return @YahooCodes_pl;
} elsif($lang eq "it") {
return @YahooCodes_it;
} else {
return @YahooCodes_en;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 13 KiB