コード例 #1
0
 /**
  * @param int|null $id
  * @return array
  */
 public static function getStatus(int $id = null) : array
 {
     $statuses = [self::STATUS_TRANSLATED => Module::t('Translated'), self::STATUS_NOT_TRANSLATED => Module::t('Not translated')];
     if ($id !== null) {
         return ArrayHelper::getValue($statuses, $id, null);
     }
     return $statuses;
 }
コード例 #2
0
 /**
  * @param array|integer $id
  * @return SourceMessage|SourceMessage[]
  * @throws NotFoundHttpException
  */
 protected function findModel($id)
 {
     $query = SourceMessage::find()->where('id = :id', [':id' => $id]);
     $models = is_array($id) ? $query->all() : $query->one();
     if (!empty($models)) {
         return $models;
     } else {
         throw new NotFoundHttpException(Module::t('The requested page does not exist'));
     }
 }
コード例 #3
0
ファイル: Message.php プロジェクト: wancer/yii2-i18n-module
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['id' => Module::t('ID'), 'language' => Module::t('Language'), 'translation' => Module::t('Translation')];
 }
コード例 #4
0
ファイル: index.php プロジェクト: wancer/yii2-i18n-module
">Remove untranslated</a>
	</div>

	<h3><?php 
echo Html::encode($this->title);
?>
</h3>
	<?php 
Pjax::begin();
echo GridView::widget(['filterModel' => $searchModel, 'dataProvider' => $dataProvider, 'columns' => [['attribute' => 'id', 'value' => function ($model) {
    return $model->id;
}, 'filter' => false], ['attribute' => 'message', 'format' => 'raw', 'value' => function (SourceMessage $model) {
    return Html::a($model->message, ['update', 'id' => $model->id], ['data' => ['pjax' => 0]]);
}], ['attribute' => 'category', 'value' => function (SourceMessage $model) {
    return $model->category;
}, 'filter' => ArrayHelper::map($searchModel::getCategories(), 'category', 'category')], ['attribute' => 'status', 'value' => function (SourceMessage $model) use($languagesCount) {
    $count = 0;
    foreach ($model->messages as $message) {
        $count += (bool) (!empty($message->translation));
    }
    if ($count == $languagesCount) {
        $text = Module::t('Translated');
    } else {
        $text = Module::t('Not translated');
    }
    return $text;
}, 'filter' => $searchModel->getStatus()]]]);
Pjax::end();
?>
</div>
コード例 #5
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['id' => Module::t('ID'), 'category' => Module::t('Category'), 'message' => Module::t('Message'), 'status' => Module::t('Translation status')];
 }
コード例 #6
0
ファイル: update.php プロジェクト: wancer/yii2-i18n-module
 * @var View $this
 * @var SourceMessage $model
 */
use yii\helpers\Html;
use yii\web\View;
use Wancer\yii\modules\I18n\models\SourceMessage;
use Wancer\yii\modules\I18n\Module;
$this->title = Module::t('Update') . ': ' . $model->message;
echo \yii\widgets\Breadcrumbs::widget(['links' => [['label' => Module::t('Translations'), 'url' => ['index']], ['label' => $this->title]]]);
?>
<div class="message-update">
	<div class="message-form">

		<div class="form-group">
			<label class="control-label"><?php 
echo Module::t('Source message');
?>
</label>
			<input type="text" disabled class="form-control" value="<?php 
echo Html::encode($model->message);
?>
">
		</div>

		<?php 
$form = \yii\bootstrap\ActiveForm::begin();
?>
		<div class="field">
			<div class="ui grid">
				<?php 
foreach ($model->messages as $language => $message) {