2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-14 05:46:35 +00:00

98_weekprofile: new attribute widgetTranslations for translations

git-svn-id: https://svn.fhem.de/fhem/trunk@13978 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Risiko 2017-04-12 21:02:36 +00:00
parent 205335236a
commit 757c9b6b49
3 changed files with 34 additions and 3 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # 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. # Do not insert empty lines here, update check depends on it.
- feature: 98_weekprofile: new attribute widgetTranslations for translations
- bugfix: 98_weekprofile: handle csrfToken - bugfix: 98_weekprofile: handle csrfToken
- bugfix: 02_HTTPSRV: strip parameters from filename - bugfix: 02_HTTPSRV: strip parameters from filename
- bugfix: 88_HMCCURPC: fixed binary RPC init procedure - bugfix: 88_HMCCURPC: fixed binary RPC init procedure

View File

@ -422,7 +422,7 @@ sub weekprofile_Initialize($)
$hash->{StateFn} = "weekprofile_State"; $hash->{StateFn} = "weekprofile_State";
$hash->{NotifyFn} = "weekprofile_Notify"; $hash->{NotifyFn} = "weekprofile_Notify";
$hash->{AttrFn} = "weekprofile_Attr"; $hash->{AttrFn} = "weekprofile_Attr";
$hash->{AttrList} = "useTopics:0,1 widgetWeekdays widgetEditOnNewPage:0,1 widgetEditDaysInRow:1,2,3,4,5,6,7 tempON tempOFF configFile ".$readingFnAttributes; $hash->{AttrList} = "useTopics:0,1 widgetTranslations widgetWeekdays widgetEditOnNewPage:0,1 widgetEditDaysInRow:1,2,3,4,5,6,7 tempON tempOFF configFile ".$readingFnAttributes;
$hash->{FW_summaryFn} = "weekprofile_SummaryFn"; $hash->{FW_summaryFn} = "weekprofile_SummaryFn";
@ -1296,6 +1296,10 @@ sub weekprofile_getEditLNK_MasterDev($$)
<a name="weekprofileattr"></a> <a name="weekprofileattr"></a>
<b>Attributes</b> <b>Attributes</b>
<ul> <ul>
<li>widgetTranslations<br>
Comma seperated list of texts translations <german>:<translation>
<code>attr name widgetTranslations Abbrechen:Cancel,Speichern:Save</code>
</li>
<li>widgetWeekdays<br> <li>widgetWeekdays<br>
Comma seperated list of week days starting at Monday Comma seperated list of week days starting at Monday
<code>attr name widgetWeekdays Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday</code> <code>attr name widgetWeekdays Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday</code>
@ -1448,6 +1452,10 @@ sub weekprofile_getEditLNK_MasterDev($$)
<a name="weekprofileattr"></a> <a name="weekprofileattr"></a>
<b>Attribute</b> <b>Attribute</b>
<ul> <ul>
<li>widgetTranslations<br>
Liste von Übersetzungen der Form <german>:<Übersetzung> getrennt durch ',' um Texte im Widget zu übersetzen.
<code>attr name widgetTranslations Abbrechen:Abbr,Speichern:Save</code>
</li>
<li>widgetWeekdays<br> <li>widgetWeekdays<br>
Liste von Wochentagen getrennt durch ',' welche im Widget angzeigt werden. Liste von Wochentagen getrennt durch ',' welche im Widget angzeigt werden.
Beginnend bei Montag. z.B. Beginnend bei Montag. z.B.

View File

@ -132,6 +132,18 @@ function FW_weekprofileMultiSelDialog(title, elementNames, elementLabels, select
}); });
} }
function FW_GetTranslation(widget,translate)
{
if (widget.TRANSLATIONS == null)
return translate;
var translated = widget.TRANSLATIONS[translate];
if (translated.length == 0)
return translate;
return translated;
}
function weekprofile_DoEditWeek(devName,newPage) function weekprofile_DoEditWeek(devName,newPage)
{ {
var widget = $('div[informid="'+devName+'"]').get(0); var widget = $('div[informid="'+devName+'"]').get(0);
@ -607,8 +619,9 @@ function FW_weekprofileEditWeek(widget)
tr.append("<td><table><tr>"); tr.append("<td><table><tr>");
tr = tr.find("tr:last"); tr = tr.find("tr:last");
tr.append("<td><input type=\"button\" value=\"Speichern\" onclick=\"FW_weekprofilePrepAndSendProf('"+widget.DEVICE+"')\">");
tr.append("<td><input type=\"button\" value=\"Abbrechen\" onclick=\"FW_weekprofileEditAbort('"+widget.DEVICE+"')\">"); tr.append("<td><input type=\"button\" value=\""+FW_GetTranslation(widget,'Speichern')+"\" onclick=\"FW_weekprofilePrepAndSendProf('"+widget.DEVICE+"')\">");
tr.append("<td><input type=\"button\" value=\""+FW_GetTranslation(widget,'Abbrechen')+"\" onclick=\"FW_weekprofileEditAbort('"+widget.DEVICE+"')\">");
} }
function FW_weekprofileSendCallback(devName, data) function FW_weekprofileSendCallback(devName, data)
@ -767,6 +780,14 @@ function FW_weekprofileGetValues(devName,what,data)
widget.CURTOPIC = widget.TOPICNAMES[0]; widget.CURTOPIC = widget.TOPICNAMES[0];
} }
FW_weekprofileChacheTo(devName,widget.CURTOPIC,null); FW_weekprofileChacheTo(devName,widget.CURTOPIC,null);
} else if (what == "TRANSLATE") {
var arr = data.split(',');
widget.TRANSLATIONS = new Array();
for (var k = 0; k < arr.length; ++k) {
var trans = arr[k].split(':');
if (trans.length == 2)
widget.TRANSLATIONS[trans[0].trim()] = trans[1].trim();
}
} }
} }
@ -832,6 +853,7 @@ FW_weekprofileCreate(elName, devName, vArr, currVal, set, params, cmd)
widget.activateFn = function(arg){ widget.activateFn = function(arg){
FW_queryValue('get '+devName+' profile_data '+widget.CURTOPIC+':'+widget.CURPRF, widget); FW_queryValue('get '+devName+' profile_data '+widget.CURTOPIC+':'+widget.CURPRF, widget);
FW_cmd(FW_root+'?cmd={AttrVal("'+devName+'","widgetWeekdays","")}&XHR=1',function(data){FW_weekprofileGetValues(devName,"WEEKDAYS",data);}); FW_cmd(FW_root+'?cmd={AttrVal("'+devName+'","widgetWeekdays","")}&XHR=1',function(data){FW_weekprofileGetValues(devName,"WEEKDAYS",data);});
FW_cmd(FW_root+'?cmd={AttrVal("'+devName+'","widgetTranslations","")}&XHR=1',function(data){FW_weekprofileGetValues(devName,"TRANSLATE",data);});
if (widget.USETOPICS == 1) { if (widget.USETOPICS == 1) {
FW_cmd(FW_root+'?cmd=get '+devName+' topic_names&XHR=1',function(data){FW_weekprofileGetValues(devName,"TOPICNAMES",data);}); FW_cmd(FW_root+'?cmd=get '+devName+' topic_names&XHR=1',function(data){FW_weekprofileGetValues(devName,"TOPICNAMES",data);});
} else { } else {