Commit 274f10ae authored by Carsten Schmitz's avatar Carsten Schmitz

Dev Refactoring translations to use the Yii system

parent 8032837e
......@@ -3,7 +3,7 @@
/**
* This file contains configuration parameters for the Yii framework.
* Do not change these unless you know what you are doing.
*
*
*/
@date_default_timezone_set(@date_default_timezone_get());
$internalConfig = array(
......@@ -28,7 +28,7 @@ $internalConfig = array(
'rules' => require('routes.php'),
'showScriptName' => true,
),
'clientScript' => array(
'packages' => require('third_party.php')
),
......@@ -60,9 +60,9 @@ $internalConfig = array(
'schemaCachingDuration' => 3600,
),
'messages' => array(
'class' => 'GettextMessageSource',
'class' => 'CGettextMessageSource',
'useMoFile' => true,
'basePath' => __DIR__ . '/../../locale'
'basePath' => __DIR__ . DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale'
)
)
......
......@@ -14,7 +14,6 @@
class AdminController extends LSYii_Controller
{
public $lang = null;
public $layout = false;
protected $user_id = 0;
......@@ -59,15 +58,14 @@ class AdminController extends LSYii_Controller
*/
public function error($message, $sURL = array())
{
$clang = $this->lang;
$this->_getAdminHeader();
$sOutput = "<div class='messagebox ui-corner-all'>\n";
$sOutput .= '<div class="warningheader">'.$clang->gT('Error').'</div><br />'."\n";
$sOutput .= '<div class="warningheader">'.gT('Error').'</div><br />'."\n";
$sOutput .= $message . '<br /><br />'."\n";
if (!empty($sURL) && !is_array($sURL))
{
$sTitle = $clang->gT('Back');
$sTitle = gT('Back');
}
elseif (!empty($sURL['url']))
{
......@@ -77,13 +75,13 @@ class AdminController extends LSYii_Controller
}
else
{
$sTitle = $clang->gT('Back');
$sTitle = gT('Back');
}
$sURL = $sURL['url'];
}
else
{
$sTitle = $clang->gT('Main Admin Screen');
$sTitle = gT('Main Admin Screen');
$sURL = $this->createUrl('/admin');
}
$sOutput .= '<input type="submit" value="'.$sTitle.'" onclick=\'window.open("'.$sURL.'", "_top")\' /><br /><br />'."\n";
......@@ -91,7 +89,7 @@ class AdminController extends LSYii_Controller
$sOutput .= '</div>'."\n";
echo $sOutput;
$this->_getAdminFooter('http://manual.limesurvey.org', $clang->gT('LimeSurvey online manual'));
$this->_getAdminFooter('http://manual.limesurvey.org', gT('LimeSurvey online manual'));
die;
}
......@@ -103,7 +101,6 @@ class AdminController extends LSYii_Controller
*/
protected function _sessioncontrol()
{
Yii::import('application.libraries.Limesurvey_lang');
// From personal settings
if (Yii::app()->request->getPost('action') == 'savepersonalsettings') {
if (Yii::app()->request->getPost('lang')=='auto')
......@@ -120,9 +117,7 @@ class AdminController extends LSYii_Controller
if (empty(Yii::app()->session['adminlang']))
Yii::app()->session["adminlang"] = Yii::app()->getConfig("defaultlang");
global $clang; // Needed so EM can localize equation hints until a better solution is found
$this->lang = $clang = new Limesurvey_lang(Yii::app()->session['adminlang']);
Yii::app()->setLang($this->lang);
Yii::app()->setLanguage(Yii::app()->session["adminlang"]);
if (!empty($this->user_id))
$this->_GetSessionUserRights($this->user_id);
......@@ -163,7 +158,7 @@ class AdminController extends LSYii_Controller
Yii::app()->session->close();
$this->redirect(array('/admin/authentication/sa/login'));
}
}
return parent::run($action);
......@@ -264,15 +259,13 @@ class AdminController extends LSYii_Controller
Yii::app()->session["adminlang"] = Yii::app()->getConfig("defaultlang");
$aData = array();
$aData['adminlang'] = $this->lang->getlangcode();
//$data['admin'] = getLanguageRTL;
$aData['test'] = "t";
$aData['adminlang'] = Yii::app()->language;
$aData['languageRTL']="";
$aData['styleRTL']="";
Yii::app()->loadHelper("surveytranslator");
if (getLanguageRTL($aData['adminlang']))
if (getLanguageRTL(Yii::app()->language))
{
$aData['languageRTL'] = " dir=\"rtl\" ";
$aData['bIsRTL']=true;
......@@ -293,8 +286,8 @@ class AdminController extends LSYii_Controller
$aData['datepickerlang']="";
if ($aData['adminlang'] != 'en')
Yii::app()->getClientScript()->registerScriptFile(App()->baseUrl . "/third_party/jqueryui/development-bundle/ui/i18n/jquery.ui.datepicker-" . $aData['adminlang'] .".js");
$aData['sitename'] = Yii::app()->getConfig("sitename");
$aData['admintheme'] = Yii::app()->getConfig("admintheme");
$aData['firebug'] = useFirebug();
......@@ -303,8 +296,8 @@ class AdminController extends LSYii_Controller
$aData['formatdata'] = getDateFormatData(Yii::app()->session['dateformat']);
$sOutput = $this->renderPartial("/admin/super/header", $aData, true);
if ($return)
{
return $sOutput;
......@@ -326,9 +319,6 @@ class AdminController extends LSYii_Controller
*/
public function _getAdminFooter($url, $explanation, $return = false)
{
$clang = $this->lang;
$aData['clang'] = $clang;
$aData['versionnumber'] = Yii::app()->getConfig("versionnumber");
$aData['buildtext'] = "";
......@@ -345,7 +335,7 @@ class AdminController extends LSYii_Controller
}
else
{
$aData['versiontitle'] = $clang->gT('Version');
$aData['versiontitle'] = gT('Version');
}
$aData['imageurl'] = Yii::app()->getConfig("imageurl");
......@@ -369,8 +359,6 @@ class AdminController extends LSYii_Controller
$aData['title'] = $title;
$aData['message'] = $message;
$aData['class'] = $class;
$aData['clang'] = $this->lang;
$this->renderPartial('/admin/super/messagebox', $aData);
}
......@@ -388,12 +376,8 @@ class AdminController extends LSYii_Controller
*/
public function _showadminmenu($surveyid = false)
{
$clang = $this->lang;
$aData['clang']= $clang;
if (Yii::app()->session['pw_notify'] && Yii::app()->getConfig("debug")<2) {
Yii::app()->session['flashmessage'] = $clang->gT("Warning: You are still using the default password ('password'). Please change your password and re-login again.");
Yii::app()->session['flashmessage'] = gT("Warning: You are still using the default password ('password'). Please change your password and re-login again.");
}
$aData['showupdate'] = (Yii::app()->session['USER_RIGHT_SUPERADMIN'] == 1 && getGlobalSetting("updatenotification")!='never' && getGlobalSetting("updateavailable")==1 && Yii::app()->getConfig("updatable") );
......@@ -405,7 +389,7 @@ class AdminController extends LSYii_Controller
{
$aUpdateTexts[]=$aVersion['versionnumber'].'('.$aVersion['build'].')';
}
$aData['sUpdateText']=implode(' '.$clang->gT('or').' ',$aUpdateTexts);
$aData['sUpdateText']=implode(' '.gT('or').' ',$aUpdateTexts);
}
$aData['surveyid'] = $surveyid;
$aData['iconsize'] = Yii::app()->getConfig('adminthemeiconsize');
......
......@@ -63,7 +63,7 @@ class OptinController extends LSYii_Controller {
if ($aSurveyInfo == false || !tableExists("{{tokens_{$iSurveyID}}}"))
{
$sMessage = $clang->gT('This survey does not seem to exist.');
$sMessage = gT('This survey does not seem to exist.');
}
else
{
......@@ -71,7 +71,7 @@ class OptinController extends LSYii_Controller {
if (!isset($oToken))
{
$sMessage = $clang->gT('You are not a participant in this survey.');
$sMessage = gT('You are not a participant in this survey.');
}
else
{
......@@ -79,15 +79,15 @@ class OptinController extends LSYii_Controller {
{
$oToken->emailstatus = 'OK';
$oToken->save();
$sMessage = $clang->gT('You have been successfully added back to this survey.');
$sMessage = gT('You have been successfully added back to this survey.');
}
elseif ($oToken->emailstatus == 'OK')
{
$sMessage = $clang->gT('You are already a part of this survey.');
$sMessage = gT('You are already a part of this survey.');
}
else
{
$sMessage = $clang->gT('You have been already removed from this survey.');
$sMessage = gT('You have been already removed from this survey.');
}
}
}
......
......@@ -61,7 +61,7 @@ class OptoutController extends LSYii_Controller {
$aSurveyInfo=getSurveyInfo($iSurveyID,$sBaseLanguage);
if ($aSurveyInfo==false || !tableExists("{{tokens_{$iSurveyID}}}")){
$sMessage = $clang->gT('This survey does not seem to exist.');
$sMessage = gT('This survey does not seem to exist.');
}
else
{
......@@ -69,7 +69,7 @@ class OptoutController extends LSYii_Controller {
if (!isset($oToken))
{
$sMessage = $clang->gT('You are not a participant in this survey.');
$sMessage = gT('You are not a participant in this survey.');
}
else
{
......@@ -77,11 +77,11 @@ class OptoutController extends LSYii_Controller {
{
$oToken->emailstatus = 'OptOut';
$oToken->save();
$sMessage = $clang->gT('You have been successfully removed from this survey.');
$sMessage = gT('You have been successfully removed from this survey.');
}
else
{
$sMessage = $clang->gT('You have been already removed from this survey.');
$sMessage = gT('You have been already removed from this survey.');
}
}
}
......@@ -137,14 +137,14 @@ class OptoutController extends LSYii_Controller {
$aSurveyInfo=getSurveyInfo($iSurveyID,$sBaseLanguage);
if ($aSurveyInfo==false || !tableExists("{{tokens_{$iSurveyID}}}")){
$sMessage = $clang->gT('This survey does not seem to exist.');
$sMessage = gT('This survey does not seem to exist.');
}
else
{
$oToken = Token::model($iSurveyID)->findByAttributes(array('token' => $sToken));
if (!isset($oToken))
{
$sMessage = $clang->gT('You are not a participant in this survey.');
$sMessage = gT('You are not a participant in this survey.');
}
else
{
......@@ -152,11 +152,11 @@ class OptoutController extends LSYii_Controller {
{
$oToken->emailstatus = 'OptOut';
$oToken->save();
$sMessage = $clang->gT('You have been successfully removed from this survey.');
$sMessage = gT('You have been successfully removed from this survey.');
}
else
{
$sMessage = $clang->gT('You have been already removed from this survey.');
$sMessage = gT('You have been already removed from this survey.');
}
if(!empty($oToken->participant_id))
{
......@@ -165,13 +165,13 @@ class OptoutController extends LSYii_Controller {
if($oParticipant->blacklisted=="Y")
{
$sMessage .= "<br />";
$sMessage .= $clang->gT("You have already been removed from the central participants list for this site");
$sMessage .= gT("You have already been removed from the central participants list for this site");
} else
{
$oParticipant->blacklisted='Y';
$oParticipant->save();
$sMessage .= "<br />";
$sMessage .= $clang->gT("You have been removed from the central participants list for this site");
$sMessage .= gT("You have been removed from the central participants list for this site");
}
}
}
......
......@@ -79,9 +79,9 @@
doHeader();
echo templatereplace(file_get_contents(getTemplatePath($sTemplate).'/startpage.pstpl'),array());
echo "<center><br />\n"
."\t<font color='RED'><strong>".$clang->gT("Error")."</strong></font><br />\n"
."\t".$clang->gT("We are sorry but your session has expired.")."<br />".$clang->gT("Either you have been inactive for too long, you have cookies disabled for your browser, or there were problems with your connection.")."<br />\n"
."\t".sprintf($clang->gT("Please contact %s ( %s ) for further assistance."), Yii::app()->getConfig("siteadminname"), Yii::app()->getConfig("siteadminemail"))."\n"
."\t<font color='RED'><strong>".gT("Error")."</strong></font><br />\n"
."\t".gT("We are sorry but your session has expired.")."<br />".gT("Either you have been inactive for too long, you have cookies disabled for your browser, or there were problems with your connection.")."<br />\n"
."\t".sprintf(gT("Please contact %s ( %s ) for further assistance."), Yii::app()->getConfig("siteadminname"), Yii::app()->getConfig("siteadminemail"))."\n"
."</center><br />\n";
echo templatereplace(file_get_contents(getTemplatePath($sTemplate).'/endpage.pstpl'),array());
doFooter();
......@@ -101,7 +101,7 @@
//OK. IF WE GOT THIS FAR, THEN THE SURVEY EXISTS AND IT IS ACTIVE, SO LETS GET TO WORK.
//SHOW HEADER
$sOutput = CHtml::form(array("printanswers/view/surveyid/{$iSurveyID}/printableexport/pdf"), 'post')
."<center><input type='submit' value='".$clang->gT("PDF export")."'id=\"exportbutton\"/><input type='hidden' name='printableexport' /></center></form>";
."<center><input type='submit' value='".gT("PDF export")."'id=\"exportbutton\"/><input type='hidden' name='printableexport' /></center></form>";
if($sExportType == 'pdf')
{
//require (Yii::app()->getConfig('rootdir').'/application/config/tcpdf.php');
......@@ -109,7 +109,7 @@
Yii::import('application.helpers.pdfHelper');
$aPdfLanguageSettings=pdfHelper::getPdfLanguageSettings($clang->langcode);
$oPDF = new pdf();
$oPDF->SetTitle($clang->gT("Survey name (ID)",'unescaped').": {$sSurveyName} ({$iSurveyID})");
$oPDF->SetTitle(gT("Survey name (ID)",'unescaped').": {$sSurveyName} ({$iSurveyID})");
$oPDF->SetSubject($sSurveyName);
$oPDF->SetDisplayMode('fullpage', 'two');
$oPDF->setLanguageArray($aPdfLanguageSettings['lg']);
......@@ -117,9 +117,9 @@
$oPDF->setFooterFont(Array($aPdfLanguageSettings['pdffont'], '', PDF_FONT_SIZE_DATA));
$oPDF->SetFont($aPdfLanguageSettings['pdffont'], '', $aPdfLanguageSettings['pdffontsize']);
$oPDF->AddPage();
$oPDF->titleintopdf($clang->gT("Survey name (ID)",'unescaped').": {$sSurveyName} ({$iSurveyID})");
$oPDF->titleintopdf(gT("Survey name (ID)",'unescaped').": {$sSurveyName} ({$iSurveyID})");
}
$sOutput .= "\t<div class='printouttitle'><strong>".$clang->gT("Survey name (ID):")."</strong> $sSurveyName ($iSurveyID)</div><p>&nbsp;\n";
$sOutput .= "\t<div class='printouttitle'><strong>".gT("Survey name (ID):")."</strong> $sSurveyName ($iSurveyID)</div><p>&nbsp;\n";
LimeExpressionManager::StartProcessingPage(true); // means that all variables are on the same page
// Since all data are loaded, and don't need JavaScript, pretend all from Group 1
LimeExpressionManager::StartProcessingGroup(1,($aSurveyInfo['anonymized']!="N"),$iSurveyID);
......
......@@ -134,7 +134,7 @@ class RegisterController extends LSYii_Controller {
$sSecAnswer=(isset($_SESSION['survey_'.$iSurveyId]['secanswer']))?$_SESSION['survey_'.$iSurveyId]['secanswer']:"";
if ($sLoadsecurity!=$sSecAnswer)
{
$this->aRegisterErrors[] = $clang->gT("The answer to the security question is incorrect.");
$this->aRegisterErrors[] = gT("The answer to the security question is incorrect.");
}
}
......@@ -143,16 +143,16 @@ class RegisterController extends LSYii_Controller {
//Check that the email is a valid style address
if($aFieldValue['sEmail']==""){
$this->aRegisterErrors[]= $clang->gT("You must enter a valid email. Please try again.");
$this->aRegisterErrors[]= gT("You must enter a valid email. Please try again.");
}elseif (!validateEmailAddress($aFieldValue['sEmail'])){
$this->aRegisterErrors[]= $clang->gT("The email you used is not valid. Please try again.");
$this->aRegisterErrors[]= gT("The email you used is not valid. Please try again.");
}
//Check and validate attribute
foreach ($aRegisterAttributes as $key => $aAttribute)
{
if ($aAttribute['show_register'] == 'Y' && $aAttribute['mandatory'] == 'Y' && empty($aFieldValue['aAttribute'][$key]))
{
$this->aRegisterErrors[]= sprintf($clang->gT("%s cannot be left empty").".", $aAttribute['caption']);
$this->aRegisterErrors[]= sprintf(gT("%s cannot be left empty").".", $aAttribute['caption']);
}
}
}
......@@ -191,11 +191,11 @@ class RegisterController extends LSYii_Controller {
$sRegisterError='';
$aReplacement['REGISTERERROR'] = $sRegisterError;
$aReplacement['REGISTERMESSAGE1'] = $clang->gT("You must be registered to complete this survey");
$aReplacement['REGISTERMESSAGE1'] = gT("You must be registered to complete this survey");
if($sStartDate=$this->getStartDate($iSurveyId))
$aReplacement['REGISTERMESSAGE2'] = sprintf($clang->gT("You may register for this survey but you have to wait for the %s before starting the survey."),$sStartDate)."<br />\n".$clang->gT("Enter your details below, and an email containing the link to participate in this survey will be sent immediately.");
$aReplacement['REGISTERMESSAGE2'] = sprintf(gT("You may register for this survey but you have to wait for the %s before starting the survey."),$sStartDate)."<br />\n".gT("Enter your details below, and an email containing the link to participate in this survey will be sent immediately.");
else
$aReplacement['REGISTERMESSAGE2'] = $clang->gT("You may register for this survey if you wish to take part.")."<br />\n".$clang->gT("Enter your details below, and an email containing the link to participate in this survey will be sent immediately.");
$aReplacement['REGISTERMESSAGE2'] = gT("You may register for this survey if you wish to take part.")."<br />\n".gT("Enter your details below, and an email containing the link to participate in this survey will be sent immediately.");
$aData['thissurvey'] = $aSurveyInfo;
Yii::app()->setConfig('surveyID',$iSurveyId);//Needed for languagechanger
......@@ -276,17 +276,17 @@ class RegisterController extends LSYii_Controller {
$oToken->sent=$today;
$oToken->save();
$this->sMessage="<div id='wrapper' class='message tokenmessage'>"
. "<p>".$clang->gT("Thank you for registering to participate in this survey.")."</p>\n"
. "<p>".gT("Thank you for registering to participate in this survey.")."</p>\n"
. "<p>{$this->sMailMessage}</p>\n"
. "<p>".sprintf($clang->gT("Survey administrator %s (%s)"),$aSurveyInfo['adminname'],$aSurveyInfo['adminemail'])."</p>"
. "<p>".sprintf(gT("Survey administrator %s (%s)"),$aSurveyInfo['adminname'],$aSurveyInfo['adminemail'])."</p>"
. "</div>\n";
}
else
{
$this->sMessage="<div id='wrapper' class='message tokenmessage'>"
. "<p>".$clang->gT("Thank you for registering to participate in this survey.")."</p>\n"
. "<p>".$clang->gT("You are registred but an error happen when trying to send the email, please contact the survey administrator.")."</p>\n"
. "<p>".sprintf($clang->gT("Survey administrator %s (%s)"),$aSurveyInfo['adminname'],$aSurveyInfo['adminemail'])."</p>"
. "<p>".gT("Thank you for registering to participate in this survey.")."</p>\n"
. "<p>".gT("You are registred but an error happen when trying to send the email, please contact the survey administrator.")."</p>\n"
. "<p>".sprintf(gT("Survey administrator %s (%s)"),$aSurveyInfo['adminname'],$aSurveyInfo['adminemail'])."</p>"
. "</div>\n";
}
// Allways return true : if we come here, we allways trye to send an email
......@@ -311,19 +311,19 @@ class RegisterController extends LSYii_Controller {
{
if($oToken->usesleft<1 && $aSurveyInfo['alloweditaftercompletion']!='Y')
{
$this->aRegisterErrors[]=$clang->gt("The mail address you have entered is already registered an the survey has been completed.");
$this->aRegisterErrors[]=gT("The mail address you have entered is already registered an the survey has been completed.");
}
elseif(strtolower(substr(trim($oToken->emailstatus),0,6))==="optout")// And global blacklisting ?
{
$this->aRegisterErrors[]=$clang->gt("This email address is already registered but someone ask to not receive new email again.");
$this->aRegisterErrors[]=gT("This email address is already registered but someone ask to not receive new email again.");
}
elseif(!$oToken->emailstatus && $oToken->emailstatus!="OK")
{
$this->aRegisterErrors[]=$clang->gt("This email address is already registered but the email adress was bounced.");
$this->aRegisterErrors[]=gT("This email address is already registered but the email adress was bounced.");
}
else
{
$this->sMailMessage=$clang->gt("The address you have entered is already registered. An email has been sent to this address with a link that gives you access to the survey.");
$this->sMailMessage=gT("The address you have entered is already registered. An email has been sent to this address with a link that gives you access to the survey.");
return $oToken->tid;
}
}
......@@ -348,7 +348,7 @@ class RegisterController extends LSYii_Controller {
}
$oToken->save();
TokenDynamic::model($iSurveyId)->createToken($oToken->tid);// Review if really create a token
$this->sMailMessage=$clang->gT("An email has been sent to the address you provided with access details for this survey. Please follow the link in that email to proceed.");
$this->sMailMessage=gT("An email has been sent to the address you provided with access details for this survey. Please follow the link in that email to proceed.");
return $oToken->tid;
}
}
......
......@@ -265,7 +265,7 @@ class Statistics_userController extends LSYii_Controller {
break;
case "A": // ARRAY OF 5 POINT CHOICE QUESTIONS
case "B": // ARRAY OF 10 POINT CHOICE QUESTIONS
case "C": // ARRAY OF YES\No\$clang->gT("Uncertain") QUESTIONS
case "C": // ARRAY OF YES\No\gT("Uncertain") QUESTIONS
case "E": // ARRAY OF Increase/Same/Decrease QUESTIONS
case "F": // FlEXIBLE ARRAY
case "H": // ARRAY (By Column)
......@@ -385,9 +385,9 @@ class Statistics_userController extends LSYii_Controller {
$prb->setFrame(); // set ProgressBar Frame
$prb->frame['left'] = 50; // Frame position from left
$prb->frame['top'] = 80; // Frame position from top
$prb->addLabel('text','txt1',$clang->gT("Please wait ...")); // add Text as Label 'txt1' and value 'Please wait'
$prb->addLabel('text','txt1',gT("Please wait ...")); // add Text as Label 'txt1' and value 'Please wait'
$prb->addLabel('percent','pct1'); // add Percent as Label 'pct1'
$prb->addButton('btn1',$clang->gT('Go back'),'?action=statistics&amp;sid='.$iSurveyID); // add Button as Label 'btn1' and action '?restart=1'
$prb->addButton('btn1',gT('Go back'),'?action=statistics&amp;sid='.$iSurveyID); // add Button as Label 'btn1' and action '?restart=1'
//progress bar starts with 35%
$process_status = 35;
......@@ -396,7 +396,7 @@ class Statistics_userController extends LSYii_Controller {
// 1: Get list of questions with answers chosen
//"Getting Questions and Answer ..." is shown above the bar
$prb->setLabelValue('txt1',$clang->gT('Getting questions and answers ...'));
$prb->setLabelValue('txt1',gT('Getting questions and answers ...'));
$prb->moveStep(5);
// creates array of post variable names
......@@ -418,7 +418,7 @@ class Statistics_userController extends LSYii_Controller {
if (isset($summary) && $summary)