Commit c3155e78 by Denis Chenu

[dev] Move to po/mo for translation

parent cdbe0e53
<?php
/**
* A class for language
*
* @author Denis Chenu <denis@sondages.pro>
* @copyright 2016 Denis Chenu <http://www.sondages.pro>
* @license GPL v3
* @version 0.0.1
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
class translate
{
/**
* @var array[] translation text : 1st jey is string, second key is lang
*/
private $aTranslation=array(
'fr'=>array(
'Mails sent'=>'Nombre d\'envoi',
'Daily participation'=>'Participation journalière',
'Daily participation (cumulative)'=>'Participation journalière cumulée',
'Participation rate'=>'Taux de participations',
'Total responses: %s'=>'Nombre total : %s',
'Total Population'=>'Population Totale',
'Population'=>'Population',
),
);
/**
* Quick translate function
*/
public function gT($string)
{
if(isset($this->aTranslation[App()->language][$string])){
return $this->aTranslation[App()->language][$string];
}
return gT($string);
}
}
......@@ -48,14 +48,14 @@
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="sr-only"><?php \Yii::t('',"Toggle navigation",array(),$className); ?></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<?php echo CHtml::link(
CHtml::tag("span",array("class"=>''),Yii::app()->getConfig("sitename")),
array("plugins/direct","plugin"=>"adminStats","function"=>"list"),
array("plugins/direct","plugin"=>$className,"function"=>"list"),
array("class"=>'navbar-brand')
); ?>
</div>
......@@ -82,7 +82,7 @@
</nav>
<div class="container">
<?php
Yii::app()->getController()->renderPartial("adminStats.views.{$subview}",$_data_);
Yii::app()->getController()->renderPartial("{$className}.views.{$subview}",$_data_);
?>
</div> <!-- /container -->
</body>
......@@ -4,8 +4,8 @@
<tr class="bg-primary">
<?php
echo CHtml::tag("th",array("class"=>'answer'),"");
echo CHtml::tag("td",array("class"=>"cell population"),$translate->gT("Population"));
echo CHtml::tag("td",array("class"=>"cell satisfaction"),$translate->gT("Satisfaction"));
echo CHtml::tag("td",array("class"=>"cell population"),\Yii::t('',"Population",array(),$className));
echo CHtml::tag("td",array("class"=>"cell satisfaction"),\Yii::t('',"Satisfaction",array(),$className));
?>
</tr>
</thead>
......
......@@ -24,7 +24,7 @@
'sortable'=>true,
'header'=>gT("ID"),
'type' => 'raw',
'value'=>'CHtml::link($data["sid"],array("plugins/direct","plugin"=>"adminStats","function"=>"participation","sid"=>$data["sid"]))',
'value'=>'CHtml::link($data["sid"],array("plugins/direct","plugin"=>"'.$className.'","function"=>"participation","sid"=>$data["sid"]))',
),
array(
'name'=>'surveyls_title',
......@@ -35,13 +35,13 @@
array(
'name'=>'responsesCount',
'sortable'=>true,
'header'=>$translate->gT("Responses"),
'header'=>\Yii::t('',"Responses",array(),$className),
'value'=>'$data["responsesCount"]',
),
array(
'name'=>'tokensCount',
'sortable'=>true,
'header'=>$translate->gT("Mails sent"),
'header'=>\Yii::t('',"Expected participants",array(),$className),
'value'=>'($data["tokensCount"] ? $data["tokensCount"] : "/");',
),
),
......
<h1><?php echo $titre; ?></h1>
<ul class="nav nav-tabs">
<li role="presentation" class="active"><a href="#"><?php echo gT("Participation") ?></a></li>
<li role="presentation" class="active"><a href="#"><?php echo \Yii::t('',"Participation",array(),$className) ?></a></li>
<?php if($showSatisfaction) { ?>
<li role="presentation"><?php echo CHtml::link(gT("Satisfaction"),array("plugins/direct","plugin"=>"adminStats","function"=>"satisfaction","sid"=>$oSurvey->sid)) ?></li>
<li role="presentation"><?php echo CHtml::link(\Yii::t('',"Satisfaction",array(),$className),array("plugins/direct","plugin"=>"{$className}","function"=>"satisfaction","sid"=>$oSurvey->sid)) ?></li>
<?php } ?>
<?php if($showAdminSurvey) { ?>
<li role="presentation"><?php echo CHtml::link(gT("Administration"),array("admin/survey","sa"=>"editsurveysettings","surveyid"=>$oSurvey->sid,'#'=>'pluginsettings')); ?></a></li>
<li role="presentation"><?php echo CHtml::link(gT("Administration"),array("admin/survey","sa"=>"view","surveyid"=>$oSurvey->sid)); ?></a></li>
<?php } ?>
</ul>
<?php
......@@ -15,56 +15,56 @@
}
?>
<?php if(!empty($aDailyResponses)){
Yii::app()->getController()->renderPartial("adminStats.views.subviews.participation_rate",array(
'title'=>$translate->gT("Daily participation"),
Yii::app()->getController()->renderPartial("{$className}.views.subviews.participation_rate",array(
'title'=>\Yii::t('',"Daily participation",array(),$className),
'type'=>'',
'aResponses'=>$aDailyResponses,
'oSurvey'=>$oSurvey,
'showExport'=>$showAdmin,
'showSum'=>true,
'translate'=>$translate,
'className'=>$className,
));
}?>
<?php if(!empty($aDailyResponsesCumulative)){
Yii::app()->getController()->renderPartial("adminStats.views.subviews.participation_rate",array(
'title'=>$translate->gT("Daily participation (cumulative)"),
Yii::app()->getController()->renderPartial("{$className}.views.subviews.participation_rate",array(
'title'=>\Yii::t('',("Daily participation (cumulative)"),array(),$className),
'type'=>'cumul',
'aResponses'=>$aDailyResponsesCumulative,
'oSurvey'=>$oSurvey,
'showExport'=>false,
'translate'=>$translate,
'className'=>$className,
));
}?>
<?php if(!empty($aDailyEnter)){
Yii::app()->getController()->renderPartial("adminStats.views.subviews.participation_rate",array(
'title'=>$translate->gT("Nombre de connexions"),
Yii::app()->getController()->renderPartial("{$className}.views.subviews.participation_rate",array(
'title'=>\Yii::t('',("Number of connections"),array(),$className),
'type'=>'enter',
'aResponses'=>$aDailyEnter,
'oSurvey'=>$oSurvey,
'showExport'=>$showAdmin,
'translate'=>$translate,
'className'=>$className,
));
}?>
<?php if(!empty($aDailyAction)){
Yii::app()->getController()->renderPartial("adminStats.views.subviews.participation_rate",array(
'title'=>$translate->gT("Taux d'action journalier"),
Yii::app()->getController()->renderPartial("{$className}.views.subviews.participation_rate",array(
'title'=>\Yii::t('',("Daily participation rate"),array(),$className),
'type'=>'action',
'aResponses'=>$aDailyAction,
'oSurvey'=>$oSurvey,
'showExport'=>$showAdmin,
'translate'=>$translate,
'className'=>$className,
));
}?>
<h2><?php echo $translate->gT("Participation rate"); ?></h2>
<h2><?php echo \Yii::t('',"Participation rate",array(),$className); ?></h2>
<?php foreach($aResponses as $aResponse){ ?>
<table class="table table-bordered <?php echo ($aResponse['max']>0) ? "" :" nopercentage"; ?>">
<thead>
<tr class="header">
<?php
echo CHtml::tag("th",array("class"=>'answer'),$aResponse['title']);
echo CHtml::tag("td",array("class"=>"cell nbsend"),($aResponse['max']>0) ? $translate->gT("Mails sent") :"");
echo CHtml::tag("td",array("class"=>"cell nbsend"),($aResponse['max']>0) ? \Yii::t('',"Expected participants",array(),$className) :"");
echo CHtml::tag("td",array("class"=>"cell response"),gT("Responses"));
echo CHtml::tag("td",array("class"=>"cell rate"),($aResponse['max']>0) ? $translate->gT("Participation rate") :"");
echo CHtml::tag("td",array("class"=>"cell rate"),($aResponse['max']>0) ? \Yii::t('',"Participation rate",array(),$className) :"");
?>
</tr>
</thead>
......
......@@ -2,10 +2,10 @@
echo CHtml::tag("h2",array("class"=>''),$title);
if(!empty($showSum))
{
echo CHtml::tag("h4",array("class"=>''),sprintf($translate->gT("Total responses: %s"),array_sum($aResponses)));
echo CHtml::tag("h4",array("class"=>''),sprintf(\Yii::t('',"Total responses: %s",array(),$className),array_sum($aResponses)));
}
echo CHtml::tag("div",array("id"=>"chart-daily{$type}",'class'=>'chart-day graph jqplot-line'),"",true);
echo CHtml::link(gT("Export"),App()->createUrl('plugins/direct', array('plugin' => 'adminStats', 'function' => 'export','sid'=>$oSurvey->sid,'export'=>"dayresponse",'state'=>$type)),array());
echo CHtml::link(gT("Export"),App()->createUrl('plugins/direct', array('plugin' => $className, 'function' => 'export','sid'=>$oSurvey->sid,'export'=>"dayresponse",'state'=>$type)),array());
?>
<script>
$(document).ready(function(){
......
<h1><?php echo $titre; ?></h1>
<ul class="nav nav-tabs">
<li role="presentation"><?php echo CHtml::link($translate->gT("Participation"),array("plugins/direct","plugin"=>"adminStats","function"=>"participation","sid"=>$oSurvey->sid)); ?></li>
<li role="presentation"><?php echo CHtml::link(\Yii::t('',"Participation",array(),$className),array("plugins/direct","plugin"=>$className,"function"=>"participation","sid"=>$oSurvey->sid)); ?></li>
<?php if($showSatisfaction) { ?>
<li role="presentation" class="active"><a href="#"><?php echo $translate->gT("Satisfaction") ?></a></li>
<li role="presentation" class="active"><a href="#"><?php echo \Yii::t('',"Satisfaction",array(),$className); ?></a></li>
<?php } ?>
<?php if($showAdminSurvey) { ?>
<li role="presentation"><?php echo CHtml::link($translate->gT("Administration"),array("admin/survey","sa"=>"editsurveysettings","surveyid"=>$oSurvey->sid,'#'=>'pluginsettings')); ?></a></li>
<li role="presentation"><?php echo CHtml::link(\Yii::t('',"Administration",array(),$className),array("admin/survey","sa"=>"view","surveyid"=>$oSurvey->sid)); ?></a></li>
<?php } ?>
</ul>
<?php
......@@ -40,20 +40,20 @@
<?php
switch($aResponse['type']){
case 'table':
echo Yii::app()->controller->renderPartial("adminStats.views.subviews.inc_satisfaction_table",array(
echo Yii::app()->controller->renderPartial("{$className}.views.subviews.inc_satisfaction_table",array(
'repKey'=>$repKey,
'iSatId'=>$iSatId,
'aResponse'=>$aResponse,
'translate'=>$translate,
'className'=>$className,
),true);
break;
case 'graph':
default:
echo Yii::app()->controller->renderPartial("adminStats.views.subviews.inc_satisfaction_graph",array(
echo Yii::app()->controller->renderPartial("{$className}.views.subviews.inc_satisfaction_graph",array(
'repKey'=>$repKey,
'iSatId'=>$iSatId,
'aResponse'=>$aResponse,
'translate'=>$translate,
'className'=>$className,
),true);
break;
}
......
<h1><?php echo $titre; ?></h1>
<ul class="nav nav-tabs">
<li role="presentation"><?php echo CHtml::link($translate->gT("Participation"),array("plugins/direct","plugin"=>"adminStats","function"=>"participation","sid"=>$oSurvey->sid)); ?></li>
<li role="presentation" class="active"><a href="#"><?php echo $translate->gT("Satisfaction") ?></a></li>
</ul>
<?php foreach($aResponses as $repKey=>$aResponse){ ?>
<h2><?php echo $aResponse['title'] ?></h2>
<?php foreach($aResponse['aSatisfactions'] as $iSatId=>$aSatisfaction){ ?>
<h3><?php echo $aSatisfaction['title'] ?></h2>
<?php
echo CHtml::tag("canvas",array("id"=>"chart-r{$repKey}-s{$iSatId}","width"=>"400","height"=>"100"),"",true);
?>
<?php
$aLabels=array();
$aAverage=array();
foreach($aSatisfaction['datas'] as $aDatas) {
$aLabels[]="{$aDatas['title']} ({$aDatas['count']})";
$aAverage[]=$aDatas['average'];
} ?>
<script>
var data = {
labels: <?php echo json_encode($aLabels) ?>,
datasets: [
{
label: "",
backgroundColor: "#0092dd",
data: <?php echo json_encode($aAverage) ?>,
}
]
};
var ctx = document.getElementById('<?php echo "chart-r{$repKey}-s{$iSatId}" ?>');
var myBarChart = new Chart(ctx, {
type: 'bar',
data: data,
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
},
onAnimationComplete: function()
{
console.log("complete");
this.showTooltip(this.datasets[0].bars, true);
}
}
});
</script>
<?php } ?>
<?php } ?>
<h1><?php echo $titre; ?></h1>
<ul class="nav nav-tabs">
<li role="presentation"><?php echo CHtml::link($translate->gT("Participation"),array("plugins/direct","plugin"=>"adminStats","function"=>"participation","sid"=>$oSurvey->sid)); ?></li>
<?php if($showSatisfaction) { ?>
<li role="presentation" class="active"><a href="#"><?php echo $translate->gT("Satisfaction") ?></a></li>
<?php } ?>
<?php if($showAdminSurvey) { ?>
<li role="presentation"><?php echo CHtml::link($translate->gT("Administration"),array("admin/survey","sa"=>"editsurveysettings","surveyid"=>$oSurvey->sid,'#'=>'pluginsettings')); ?></a></li>
<?php } ?>
</ul>
<?php foreach($aResponses as $repKey=>$aResponse){ ?>
<h2><?php echo $aResponse['title'] ?></h2>
<?php foreach($aResponse['aSatisfactions'] as $iSatId=>$aSatisfaction){ ?>
<h3><?php echo $aSatisfaction['title'] ?></h2>
<?php
echo CHtml::tag("div",array("id"=>"chart-r{$repKey}-s{$iSatId}",'class'=>'graph'),"",true);
?>
<?php
$aLabels=array();
$aAverage=array();
foreach($aSatisfaction['datas'] as $aDatas) {
$aLabels[]="{$aDatas['title']} ({$aDatas['count']})";
$aAverage[]=$aDatas['average'];
} ?>
<?php $angle=(count($aLabels)>6 ? -15:0); // Evaluat number of columns ?>
<script>
$(document).ready(function(){
$.jqplot.config.enablePlugins = true;
var s1 = <?php echo json_encode($aAverage); ?>;
var ticks = <?php echo json_encode($aLabels); ?>;
<?php echo "plotr{$repKey}s{$iSatId}" ?> = $.jqplot('<?php echo "chart-r{$repKey}-s{$iSatId}"; ?>', [s1], {
animate: false,
seriesColors:['#0092dd'],
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
pointLabels: {
show: true,
location: 's',
formatString: "%#.2f"
}
},
grid:{
background : '#ffffff'
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ticks,
tickOptions: {
angle: <?php echo $angle; ?>,
textColor: '#000'
},
labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
tickRenderer: $.jqplot.CanvasAxisTickRenderer
},
yaxis:{
min:<?php echo $aSatisfaction['min']; ?>,
max:<?php echo $aSatisfaction['max']; ?>
}
},
highlighter: { show: false }
});
});
</script>
<?php } ?>
<?php } ?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment