Skip to content

Commit

Permalink
Dev Refactoring translations to use the Yii system
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Oct 17, 2014
1 parent 8032837 commit 274f10a
Show file tree
Hide file tree
Showing 450 changed files with 5,122 additions and 20,776 deletions.
8 changes: 4 additions & 4 deletions application/config/internal.php
Expand Up @@ -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(
Expand All @@ -28,7 +28,7 @@
'rules' => require('routes.php'),
'showScriptName' => true,
),

'clientScript' => array(
'packages' => require('third_party.php')
),
Expand Down Expand Up @@ -60,9 +60,9 @@
'schemaCachingDuration' => 3600,
),
'messages' => array(
'class' => 'GettextMessageSource',
'class' => 'CGettextMessageSource',
'useMoFile' => true,
'basePath' => __DIR__ . '/../../locale'
'basePath' => __DIR__ . DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale'
)

)
Expand Down
48 changes: 16 additions & 32 deletions application/controllers/AdminController.php
Expand Up @@ -14,7 +14,6 @@

class AdminController extends LSYii_Controller
{
public $lang = null;
public $layout = false;
protected $user_id = 0;

Expand Down Expand Up @@ -59,15 +58,14 @@ protected function _init()
*/
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']))
{
Expand All @@ -77,21 +75,21 @@ public function error($message, $sURL = array())
}
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";
$sOutput .= '</div>'."\n";
$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;
}
Expand All @@ -103,7 +101,6 @@ public function error($message, $sURL = array())
*/
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')
Expand All @@ -120,9 +117,7 @@ protected function _sessioncontrol()
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);
Expand Down Expand Up @@ -163,7 +158,7 @@ public function run($action)
Yii::app()->session->close();
$this->redirect(array('/admin/authentication/sa/login'));
}

}

return parent::run($action);
Expand Down Expand Up @@ -264,15 +259,13 @@ public function _getAdminHeader($meta = false, $return = false)
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;
Expand All @@ -293,8 +286,8 @@ public function _getAdminHeader($meta = false, $return = false)
$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();
Expand All @@ -303,8 +296,8 @@ public function _getAdminHeader($meta = false, $return = false)
$aData['formatdata'] = getDateFormatData(Yii::app()->session['dateformat']);

$sOutput = $this->renderPartial("/admin/super/header", $aData, true);


if ($return)
{
return $sOutput;
Expand All @@ -326,9 +319,6 @@ public function _getAdminHeader($meta = false, $return = false)
*/
public function _getAdminFooter($url, $explanation, $return = false)
{
$clang = $this->lang;
$aData['clang'] = $clang;

$aData['versionnumber'] = Yii::app()->getConfig("versionnumber");

$aData['buildtext'] = "";
Expand All @@ -345,7 +335,7 @@ public function _getAdminFooter($url, $explanation, $return = false)
}
else
{
$aData['versiontitle'] = $clang->gT('Version');
$aData['versiontitle'] = gT('Version');
}

$aData['imageurl'] = Yii::app()->getConfig("imageurl");
Expand All @@ -369,8 +359,6 @@ public function _showMessageBox($title,$message,$class="header ui-widget-header"
$aData['title'] = $title;
$aData['message'] = $message;
$aData['class'] = $class;
$aData['clang'] = $this->lang;

$this->renderPartial('/admin/super/messagebox', $aData);
}

Expand All @@ -388,12 +376,8 @@ public function _showMessageBox($title,$message,$class="header ui-widget-header"
*/
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") );
Expand All @@ -405,7 +389,7 @@ public function _showadminmenu($surveyid = false)
{
$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');
Expand Down

0 comments on commit 274f10a

Please sign in to comment.