Skip to content

Commit

Permalink
Fixed issue #13212: missing translation frontend survey
Browse files Browse the repository at this point in the history
  • Loading branch information
lacrioque committed Jan 19, 2018
1 parent 07b2926 commit 12fa8a2
Show file tree
Hide file tree
Showing 24 changed files with 149 additions and 129 deletions.
2 changes: 1 addition & 1 deletion application/config/internal.php
Expand Up @@ -249,7 +249,7 @@
),
'filters' => array(
'jencode' => 'CJSON::encode',
't' => 'eT',
't' => 'gT',
'gT' => 'gT',
),

Expand Down
143 changes: 100 additions & 43 deletions application/core/LsDefaultDataSets.php

Large diffs are not rendered by default.

54 changes: 4 additions & 50 deletions application/helpers/common_helper.php
Expand Up @@ -911,59 +911,13 @@ function templateDefaultTexts($sLanguage, $mode = 'html', $sNewlines = 'text')
{
$sOldLanguage = App()->language;
App()->setLanguage($sLanguage);
$aDefaultTexts = array(
'admin_detailed_notification_subject'=>gT("Response submission for survey {SURVEYNAME} with results", $mode),
'admin_detailed_notification'=>gT("Hello,\n\nA new response was submitted for your survey '{SURVEYNAME}'.\n\nClick the following link to see the individual response:\n{VIEWRESPONSEURL}\n\nClick the following link to edit the individual response:\n{EDITRESPONSEURL}\n\nView statistics by clicking here:\n{STATISTICSURL}\n\n\nThe following answers were given by the participant:\n{ANSWERTABLE}", $mode),
'admin_detailed_notification_css'=>'<style type="text/css">
.printouttable {
margin:1em auto;
}
.printouttable th {
text-align: center;
}
.printouttable td {
border-color: #ddf #ddf #ddf #ddf;
border-style: solid;
border-width: 1px;
padding:0.1em 1em 0.1em 0.5em;
}
.printouttable td:first-child {
font-weight: 700;
text-align: right;
padding-right: 5px;
padding-left: 5px;
}
.printouttable .printanswersquestion td{
background-color:#F7F8FF;
}
.printouttable .printanswersquestionhead td{
text-align: left;
background-color:#ddf;
}
.printouttable .printanswersgroup td{
text-align: center;
font-weight:bold;
padding-top:1em;
}
</style>',
'admin_notification_subject'=>gT("Response submission for survey {SURVEYNAME}", $mode),
'admin_notification'=>gT("Hello,\n\nA new response was submitted for your survey '{SURVEYNAME}'.\n\nClick the following link to see the individual response:\n{VIEWRESPONSEURL}\n\nClick the following link to edit the individual response:\n{EDITRESPONSEURL}\n\nView statistics by clicking here:\n{STATISTICSURL}", $mode),
'confirmation_subject'=>gT("Confirmation of your participation in our survey"),
'confirmation'=>gT("Dear {FIRSTNAME},\n\nthis email is to confirm that you have completed the survey titled {SURVEYNAME} and your response has been saved. Thank you for participating.\n\nIf you have any further questions about this email, please contact {ADMINNAME} on {ADMINEMAIL}.\n\nSincerely,\n\n{ADMINNAME}", $mode),
'invitation_subject'=>gT("Invitation to participate in a survey", $mode),
'invitation'=>gT("Dear {FIRSTNAME},\n\nyou have been invited to participate in a survey.\n\nThe survey is titled:\n\"{SURVEYNAME}\"\n\n\"{SURVEYDESCRIPTION}\"\n\nTo participate, please click on the link below.\n\nSincerely,\n\n{ADMINNAME} ({ADMINEMAIL})\n\n----------------------------------------------\nClick here to do the survey:\n{SURVEYURL}", $mode)."\n\n".gT("If you do not want to participate in this survey and don't want to receive any more invitations please click the following link:\n{OPTOUTURL}", $mode)."\n\n".gT("If you are blacklisted but want to participate in this survey and want to receive invitations please click the following link:\n{OPTINURL}", $mode),
'reminder_subject'=>gT("Reminder to participate in a survey", $mode),
'reminder'=>gT("Dear {FIRSTNAME},\n\nRecently we invited you to participate in a survey.\n\nWe note that you have not yet completed the survey, and wish to remind you that the survey is still available should you wish to take part.\n\nThe survey is titled:\n\"{SURVEYNAME}\"\n\n\"{SURVEYDESCRIPTION}\"\n\nTo participate, please click on the link below.\n\nSincerely,\n\n{ADMINNAME} ({ADMINEMAIL})\n\n----------------------------------------------\nClick here to do the survey:\n{SURVEYURL}", $mode)."\n\n".gT("If you do not want to participate in this survey and don't want to receive any more invitations please click the following link:\n{OPTOUTURL}", $mode),
'registration_subject'=>gT("Survey registration confirmation", $mode),
'registration'=>gT("Dear {FIRSTNAME},\n\nYou, or someone using your email address, have registered to participate in an online survey titled {SURVEYNAME}.\n\nTo complete this survey, click on the following URL:\n\n{SURVEYURL}\n\nIf you have any questions about this survey, or if you did not register to participate and believe this email is in error, please contact {ADMINNAME} at {ADMINEMAIL}.", $mode)
);

$aDefaultTexts = LsDefaultDataSets::getTemplateDefaultTexts($mode);

if ($sNewlines == 'html') {
$aDefaultTexts = array_map('nl2br', $aDefaultTexts);
}

App()->setLanguage($sOldLanguage);
return $aDefaultTexts;
}
Expand Down
7 changes: 6 additions & 1 deletion application/models/Surveymenu.php
Expand Up @@ -333,6 +333,9 @@ public function onAfterSave($event)
*/
public function restoreDefaults()
{
$sOldLanguage = App()->language;
App()->setLanguage($sLanguage);

$oDB = Yii::app()->db;
$oTransaction = $oDB->beginTransaction();
try {
Expand All @@ -345,9 +348,11 @@ public function restoreDefaults()

$oTransaction->commit();
} catch (Exception $e) {
App()->setLanguage($sOldLanguage);
return false;
}


App()->setLanguage($sOldLanguage);
return true;
}

Expand Down
4 changes: 4 additions & 0 deletions application/models/SurveymenuEntries.php
Expand Up @@ -508,6 +508,8 @@ public function search()
*/
public function restoreDefaults()
{
$sOldLanguage = App()->language;
App()->setLanguage($sLanguage);
$oDB = Yii::app()->db;
$oTransaction = $oDB->beginTransaction();
try {
Expand All @@ -522,10 +524,12 @@ public function restoreDefaults()
$oTransaction->commit();

} catch (Exception $e) {
App()->setLanguage($sOldLanguage);
throw $e;
return false;
}

App()->setLanguage($sOldLanguage);
return true;
}

Expand Down
Expand Up @@ -37,7 +37,7 @@
{% if sumEqn %}
<li class="form-group ls-group-total ls-group-dynamic">
<div class="control-label col-xs-12 col-sm-{{sLabelWidth}}">
{{ gT('Total: ') }}
{{ 'Total: ' | t }}
</div>
<div class="ls-input-group col-xs-12 col-sm-{{sInputContainerWidth}}">
{% if prefix %}
Expand Down
Expand Up @@ -14,7 +14,7 @@
<li class="form-group ls-group-remaining ls-group-dynamic">
<div class="col-xs-12 col-sm-{{ sInputContainerWidth }} col-md-offset-{{ sLabelWidth }}">
<div class="control-label">
{{ gT('Remaining: ') }}
{{ 'Remaining: ' | t }}
</div>
{% if prefix %}
<div class="prefix-text prefix hidden"><!-- Suffix prefix are not shown inline, but only in the slider: completely diofferent concept : set hidden -->
Expand Down
Expand Up @@ -52,7 +52,7 @@
{% if slider_reset %}
<div class="ls-input-group-extra ls-no-js-hidden ls-input-group-reset">
<button id="answer{{ myfname }}_resetslider" class='btn btn-default btn-sm btn-slider-reset'>
<i class='fa fa-times slider-reset-icon' aria-hidden='true'></i><span class="slider-reset-text">&nbsp;{{gT("Reset")}}</span>
<i class='fa fa-times slider-reset-icon' aria-hidden='true'></i><span class="slider-reset-text">&nbsp;{{ "Reset" | t }}</span>
</button>
</div>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion themes/survey/bootswatch/options/options.twig
Expand Up @@ -225,7 +225,7 @@
<label class="btn btn-default col-xs-8" for="upload_image_frontend">
<input class="hidden" id="upload_image_frontend" name="upload_image_frontend" type="file">
<i class="fa fa-upload ls-space margin right-10"></i>
{{ gT("Upload") }}
{{ "Upload" | t }}
</label>
</span>

Expand Down
2 changes: 1 addition & 1 deletion themes/survey/fruity/options/options.twig
Expand Up @@ -907,7 +907,7 @@
<label class="btn btn-default col-xs-8" for="upload_image_frontend">
<input class="hidden" id="upload_image_frontend" name="upload_image_frontend" type="file">
<i class="fa fa-upload ls-space margin right-10"></i>
{{ gT("Upload") }}
{{ "Upload" | t }}
</label>
</span>

Expand Down
2 changes: 1 addition & 1 deletion themes/survey/vanilla/options/options.twig
Expand Up @@ -244,7 +244,7 @@
<label class="btn btn-default col-xs-8" for="upload_image_frontend">
<input class="hidden" id="upload_image_frontend" name="upload_image_frontend" type="file">
<i class="fa fa-upload ls-space margin right-10"></i>
{{ gT("Upload") }}
{{ "Upload" | t }}
</label>
</span>

Expand Down
Expand Up @@ -36,12 +36,12 @@
<div class="row">
<div class="col-sm-6">
{{ C.Html.form(aSurveyInfo.printAnswersHeadFormUrl, 'post') }}
{{ gT("Export this responses as PDF:") }} <button class="btn btn-default" type="submit">{{ gT("PDF export") }}</button>
{{ "Export this responses as PDF:" | t }} <button class="btn btn-default" type="submit">{{ "PDF export" | t }}</button>
{{ C.Html.endForm }}
</div>
<div class="col-sm-6">
{{ C.Html.form(aSurveyInfo.printAnswersHeadFormQueXMLUrl, 'post') }}
{{ gT("Export this responses as PDF:") }} <button class="btn btn-default" type="submit">{{ gT("queXMLPDF export") }}</button>
{{ "Export this responses as PDF:" | t }} <button class="btn btn-default" type="submit">{{ "queXMLPDF export" | t }}</button>
{{ C.Html.endForm }}
</div>
</div>
Expand Down
Expand Up @@ -2,7 +2,7 @@
{% block question_name %}
<div class="col-md-4">
<b>{{question.question}} ({{question.qid}})</b><br/>
<small>{{gT("Type:")}} ({{question.type}}/{{question.questionclass}})</small>
<small>{{ "Type:" | t }} ({{question.type}}/{{question.questionclass}})</small>
</div>
{% endblock %}
{% block question_answer %}
Expand Down
Expand Up @@ -2,7 +2,7 @@
{% if (aSurveyInfo.printPdf != 1) %}
<div class="row">
<div class="col-sm-12">
<h2>{{ gT("Survey name (ID):") }} {{aSurveyInfo.surveyls_title}} ({{aSurveyInfo.sid}})</h2>
<h2>{{ "Survey name (ID):" | t }} {{aSurveyInfo.surveyls_title}} ({{aSurveyInfo.sid}})</h2>
</div>
</div>
{% endif %}
Expand Down
Expand Up @@ -5,11 +5,11 @@
<div class="row">
<div class="col-md-4 text-right">
{% if subquestion.answervalue is sameas("I") %}
{{ gT("Increase") }} <i class="fa fa-plus"></i>
{{ "Increase" | t }} <i class="fa fa-plus"></i>
{% elseif subquestion.answervalue is sameas("S") %}
{{ gT("Same") }} <i class="fa fa-circle"></i>
{{ "Same" | t }} <i class="fa fa-circle"></i>
{% elseif subquestion.answervalue is sameas("D") %}
{{ gT("Decrease") }} <i class="fa fa-minus"></i>
{{ "Decrease" | t }} <i class="fa fa-minus"></i>
{% else %}

{% endif %}
Expand Down
Expand Up @@ -5,11 +5,11 @@
<div class="row">
<div class="col-md-4 text-right">
{% if subquestion.answervalue is sameas("Y") %}
{{ gT("Yes") }} <i class="fa fa-check-square-o"></i>
{{ "Yes" | t }} <i class="fa fa-check-square-o"></i>
{% elseif subquestion.answervalue is sameas("N") %}
{{ gT("No") }} <i class="fa fa-square-o"></i>
{{ "No" | t }} <i class="fa fa-square-o"></i>
{% elseif subquestion.answervalue is sameas("U") %}
{{ gT("Uncertain") }} <i class="fa fa-minus-square-o"></i>
{{ "Uncertain" | t }} <i class="fa fa-minus-square-o"></i>
{% else %}

{% endif %}
Expand Down
Expand Up @@ -3,7 +3,7 @@
{% block question_name %}
<div class="col-xs-10">
<p>({{question.qid}}) <br/>{{question.question}}</p>
<small>{{gT("Type:")}} ({{question.questionclass}})</small>
<small>{{ "Type:" | t }} ({{question.questionclass}})</small>
</div>
{% endblock %}
{% block question_answer %}
Expand Down
Expand Up @@ -6,9 +6,9 @@
</div>
<div class="col-md-8 text-left">
{% if question.answervalue is sameas("M") %}
{{ gT("Male") }} <i class="fa fa-mars"></i>
{{ "Male" | t }} <i class="fa fa-mars"></i>
{% elseif question.answervalue is sameas("F") %}
{{ gT("Female") }} <i class="fa fa-venus"></i>
{{ "Female" | t }} <i class="fa fa-venus"></i>
{% else %}
{{question.answervalue}}
{% endif %}
Expand Down
Expand Up @@ -10,7 +10,7 @@
{{file.comment == '' ? gT('No comment') : file.comment}}
</div>
<div class="col-md-4 text-right">
{{gT("File of Type")}} "{{file.ext}}"
{{ "File of Type" | t }} "{{file.ext}}"
</div>
<div class="col-md-8 text-left">
</div>
Expand Down
Expand Up @@ -6,9 +6,9 @@
</div>
<div class="col-md-8 text-left">
{% if question.answervalue is sameas("Y") %}
{{ gT("Yes") }} <i class="fa fa-check"></i>
{{ "Yes" | t }} <i class="fa fa-check"></i>
{% elseif question.answervalue is sameas("N") %}
{{ gT("No") }} <i class="fa fa-close"></i>
{{ "No" | t }} <i class="fa fa-close"></i>
{% else %}
{{question.answervalue}}
{% endif %}
Expand Down
Expand Up @@ -23,23 +23,23 @@
<div class='{{ aSurveyInfo.class.registerformcol }} col-md-8 col-md-offset-2' {{ aSurveyInfo.attr.registerformcol }}>
{# Participants first name #}
<div class='{{ aSurveyInfo.class.registerformcolrow }} form-group row' {{ aSurveyInfo.attr.registerformcolrow }}>
<label for='register_firstname' class='{{ aSurveyInfo.class.registerformcolrowlabel }} control-label '>{{ gT("First name:") }}</label>
<label for='register_firstname' class='{{ aSurveyInfo.class.registerformcolrowlabel }} control-label '>{{ "First name:" | t }}</label>
<div class="">
{{ C.Html.textField('register_firstname', aSurveyInfo.sFirstName, ({'id' : 'register_firstname','class' : 'form-control'})) }}
</div>
</div>

{# Participants last name #}
<div class='{{ aSurveyInfo.class.registerformcolrowb }} form-group row' {{ aSurveyInfo.attr.registerformcolrowb }}>
<label {{ aSurveyInfo.attr.registerformcolrowblabel }} class='{{ aSurveyInfo.class.registerformcolrowblabel }} control-label '>{{ gT("Last name:") }}</label>
<label {{ aSurveyInfo.attr.registerformcolrowblabel }} class='{{ aSurveyInfo.class.registerformcolrowblabel }} control-label '>{{ "Last name:" | t }}</label>
<div {{ aSurveyInfo.attr.registerformcolrowbdiv }} >
{{ C.Html.textField('register_lastname', aSurveyInfo.sLastName, ({'id' : 'register_lastname', 'class' : 'form-control'})) }}
</div>
</div>

{# Participants email #}
<div class='{{ aSurveyInfo.class.registerformcolrowc }} form-group row' {{ aSurveyInfo.attr.registerformcolrowc }}>
<label {{ aSurveyInfo.attr.registerformcolrowclabel }} class='{{ aSurveyInfo.class.registerformcolrowclabel }} control-label'> {{ gT("Email address:") }} {{ include('./subviews/registration/required.twig') }}</label>
<label {{ aSurveyInfo.attr.registerformcolrowclabel }} class='{{ aSurveyInfo.class.registerformcolrowclabel }} control-label'> {{ "Email address:" | t }} {{ include('./subviews/registration/required.twig') }}</label>
<div {{ aSurveyInfo.attr.registerformcolrowcdiv }} >
{{ C.Html.textField('register_email', aSurveyInfo.sEmail, ({'id' : 'register_email','class' : 'form-control input-sm','required' : true})) }}
</div>
Expand All @@ -59,7 +59,7 @@
{# Captcha box #}
{% if aSurveyInfo.bCaptcha %}
<div class='{{ aSurveyInfo.class.registerformcaptcha }} form-group row ' {{ aSurveyInfo.attr.registerformcaptcha }}>
<label class='{{ aSurveyInfo.class.registerformcaptchalabel }} control-label ' {{ aSurveyInfo.attr.registerformcaptchalabel }} >{{ gT("Please enter the letters you see:") }} {{ include('./subviews/registration/required.twig') }}</label>
<label class='{{ aSurveyInfo.class.registerformcaptchalabel }} control-label ' {{ aSurveyInfo.attr.registerformcaptchalabel }} >{{ "Please enter the letters you see:" | t }} {{ include('./subviews/registration/required.twig') }}</label>
<div {{ aSurveyInfo.attr.registerformcaptchadiv }}>
<div class='{{ aSurveyInfo.class.registerformcaptchadivb }} input-group' {{ aSurveyInfo.attr.registerformcaptchadivb }}>
<div class='{{ aSurveyInfo.class.registerformcaptchadivc }} control-label' {{ aSurveyInfo.attr.registerformcaptchadivc }}>
Expand Down
Expand Up @@ -16,12 +16,12 @@
#}

{% if registerSuccess %}
<p {{ aSurveyInfo.attr.registermessageb }} >{{ gT("Thank you for registering You will receive an email shortly") }}</p>
<p {{ aSurveyInfo.attr.registermessageb }} >{{ "Thank you for registering You will receive an email shortly" | t }}</p>
{% else %}
{% if sStartDate %}
<p {{ aSurveyInfo.attr.registermessagea }} > {{ gT("You may register for this survey but you have to wait for the {{sStartDate}} before starting the survey.") }}</p>
<p {{ aSurveyInfo.attr.registermessagea }} > {{ "You may register for this survey but you have to wait for the {{sStartDate}} before starting the survey." | t }}</p>
{% else %}
<p {{ aSurveyInfo.attr.registermessageb }} >{{ gT("You may register for this survey if you wish to take part.") }}</p>
<p {{ aSurveyInfo.attr.registermessageb }} >{{ "You may register for this survey if you wish to take part." | t }}</p>
{% endif %}
<p {{ aSurveyInfo.attr.registermessagec }} >{{ gT("Enter your details below, and an email containing the link to participate in this survey will be sent immediately.") }}</p>
<p {{ aSurveyInfo.attr.registermessagec }} >{{ "Enter your details below, and an email containing the link to participate in this survey will be sent immediately." | t }}</p>
{% endif %}

0 comments on commit 12fa8a2

Please sign in to comment.