Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Multi-lingual em_manager_helper.php

  • Winocll_48635
  • Winocll_48635's Avatar Topic Author
  • Offline
  • Banned
  • Banned
More
7 years 1 month ago #148826 by Winocll_48635
Multi-lingual em_manager_helper.php was created by Winocll_48635
So i am trying to do a survey test in English and Spanish. Everything is working great EXCEPT for the expression manager helper. I put in custom text some time ago under the "DETECT ANY VIOLATIONS OF MANDATORY RULES" section where it says, "Please answer this question to continue" if they try to skip a mandatory question. The thing is, i don't see anywhere in the em_manager_helper.php file where multiple languages can be used.

The bottom line is that i want the Spanish version of my test survey to give all of these kinds of violation errors in Spanish instead of English. Any help?
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 1 month ago #148934 by holch
Replied by holch on topic Multi-lingual em_manager_helper.php
Shouldn't you be able to customize each of these error messages in the interface and the translation interface? I don't think it is necessary to hack any of the standard error messages in Limesurvey.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • Winocll_48635
  • Winocll_48635's Avatar Topic Author
  • Offline
  • Banned
  • Banned
More
7 years 1 month ago #148947 by Winocll_48635
Replied by Winocll_48635 on topic Multi-lingual em_manager_helper.php
I don't see where i can change it in the 'interface'...can you direct me to the proper place?
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 1 month ago #148965 by DenisChenu
Replied by DenisChenu on topic Multi-lingual em_manager_helper.php
Where do you want to use language in Expression Manager , what place ?

Currently : use
Code:
{if(LANG=="en","String in english","")}
{if(LANG=="fr","Phrase en français","")}

But : where did you want different sentence depend on language ? And what version did you use ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: Winocll_48635
The topic has been locked.
  • Winocll_48635
  • Winocll_48635's Avatar Topic Author
  • Offline
  • Banned
  • Banned
More
7 years 1 month ago #149022 by Winocll_48635
Replied by Winocll_48635 on topic Multi-lingual em_manager_helper.php
By 'Expression Manager Helper' i mean this file: application/helpers/expressions/em_manager_helper.php
It looks like when a question is 'mandatory', if the respondent tries to move past it without answering they get a message: "Please answer question to continue". The problem is that it comes up in English even when it is a Spanish (es) survey.

The same issue is happening in this file: application/helpers/qanda_helper.php with a dialog box that pops up in English even with the Spanish survey...with the verbiage 'Please answer the question(s) to continue'

The code for the popup dialog box in qanda_helper.php looks like this:

// TMSW Validation -> EM
function mandatory_popup($ia, $notanswered=null)
{

//This sets the mandatory popup message to show if required
//Called from question.php, group.php or survey.php
if ($notanswered === null) {unset($notanswered);}
if (isset($notanswered) && is_array($notanswered)) //ADD WARNINGS TO QUESTIONS IF THEY WERE MANDATORY BUT NOT ANSWERED
{
global $mandatorypopup, $popup;
//POPUP WARNING
if (!isset($mandatorypopup) && ($ia[4] == 'T' || $ia[4] == 'S' || $ia[4] == 'U'))
{
$popup=gT("Please enter some text for the question(s) to continue.");
$mandatorypopup="Y";
}else
{
$popup=gT("Please answer the question(s) to continue.");
$mandatorypopup="Y";
}
return array($mandatorypopup, $popup);
}
else
{
return false;
}
}


The code for the em_manager_helper.php is ...

//////////////////////////////////////////////
// DETECT ANY VIOLATIONS OF MANDATORY RULES //
//////////////////////////////////////////////
$qmandViolation = false; // assume there is no mandatory violation until discover otherwise
$mandatoryTip = '';
if ($qrel && !$qhidden && ($qInfo == 'Y'))
{
$mandatoryTip = "<strong><br /><span class='errormandatory'>".$LEM->gT('Please answer this question to continue.').'. ';
switch ($qInfo)
{
case 'M':
case 'P':
case '!': //List - dropdown
case 'L': //LIST drop-down/radio-button list
// If at least one checkbox is checked, we're OK
if (count($relevantSQs) > 0 && (count($relevantSQs) == count($unansweredSQs)))
{
$qmandViolation = true;
}
if (!($qInfo == '!' || $qInfo == 'L'))
{
$mandatoryTip .= $LEM->gT('Please check at least one item.');
}
if ($qInfo=='Y')
{
$qattr = isset($LEM->qattr[$qid]) ? $LEM->qattr[$qid] : array();
if (isset($qattr) && trim($qattr) != '') {
$othertext = trim($qattr);
}
else {
$othertext = $LEM->gT('Other:');
}
$mandatoryTip .= "<br />\n".sprintf($this->gT("If you choose '%s' please also specify your choice in the accompanying text field."),$othertext);
}
break;
case 'X': // Boilerplate can never be mandatory
case '*': // Equation is auto-computed, so can't violate mandatory rules
break;
case 'A':
case 'B':
case 'C':
case 'Q':
case 'K':
case 'E':
case 'F':
case 'J':
case 'H':
case ';':
case '1':
// In general, if any relevant questions aren't answered, then it violates the mandatory rule
if (count($unansweredSQs) > 0)
{
$qmandViolation = true; // TODO - what about 'other'?
}
$mandatoryTip .= $LEM->gT(' ').'.';
break;
case ':':
$qattr = isset($LEM->qattr[$qid]) ? $LEM->qattr[$qid] : array();
if (isset($qattr) && $qattr == 1)
{
// Need to check whether there is at least one checked box per row
foreach ($LEM->q2subqInfo[$qid] as $sq)
{
if (!isset($_SESSION[$LEM->sessid][$sq]) || $_SESSION[$LEM->sessid][$sq])
{
$rowCount=0;
$numUnanswered=0;
foreach ($sgqas as $s)
{
if (strpos($s, $sq."_") !== false) // Test complete subquestion code (#09493)
{
++$rowCount;
if (array_search($s,$unansweredSQs) !== false) {
++$numUnanswered;
}
}
}
if ($rowCount > 0 && $rowCount == $numUnanswered)
{
$qmandViolation = true;
}
}
}
$mandatoryTip .= $LEM->gT('Please check at least one box per row').'.';
}
else
{
if (count($unansweredSQs) > 0)
{
$qmandViolation = true; // TODO - what about 'other'?
}
$mandatoryTip .= $LEM->gT(' ').'.';
}
break;
case 'R':
if (count($unansweredSQs) > 0)
{
$qmandViolation = true; // TODO - what about 'other'?
}
$mandatoryTip .= $LEM->gT('Please rank all items').'.';
break;
case 'O': //LIST WITH COMMENT drop-down/radio-button list + textarea
$_count=0;
for ($i=0;$i<count($unansweredSQs);++$i)
{
if (preg_match("/comment$/",$unansweredSQs[$i])) {
continue;
}
++$_count;
}
if ($_count > 0)
{
$qmandViolation = true;
}
break;
default:
if (count($unansweredSQs) > 0)
{
$qmandViolation = true;
}
break;
}
$mandatoryTip .= "</span></strong>\n";
}

The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 1 month ago #149023 by DenisChenu
Replied by DenisChenu on topic Multi-lingual em_manager_helper.php
Last version of LimeSurvey ? If not : version + buil number.

If yes : a way to reproduce it ? A little lss file to report the bug ?

Stangely i don't found this sentence in translate.limesurvey.org/projects/limesurvey-25/es/default/ bu spanish seems to be at 100%

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • Winocll_48635
  • Winocll_48635's Avatar Topic Author
  • Offline
  • Banned
  • Banned
More
7 years 1 month ago #149025 by Winocll_48635
Replied by Winocll_48635 on topic Multi-lingual em_manager_helper.php
A variation of these if conditions solved the issue...

{if(LANG=="en","String in english","")}
{if(LANG=="fr","Phrase en français","")}

Thank you!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose